Skip to content

Commit

Permalink
feat: Update pixi to 6.5.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayfri committed Aug 30, 2022
1 parent 692a3f8 commit 1e24018
Show file tree
Hide file tree
Showing 31 changed files with 284 additions and 196 deletions.
30 changes: 15 additions & 15 deletions pixi/src/main/kotlin/pixi/externals/events/_DisplayObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import pixi.typings.interaction.InteractionEvent


sealed interface DisplayObjectInteractionEvents<T : Any> {
object added : DisplayObjectInteractionEvents<Container>
object added : DisplayObjectInteractionEvents<Container<DisplayObject>>
object click : DisplayObjectInteractionEvents<InteractionEvent>
object destroyed : DisplayObjectInteractionEvents<Nothing>
object mousedown : DisplayObjectInteractionEvents<InteractionEvent>
Expand All @@ -29,8 +29,8 @@ sealed interface DisplayObjectInteractionEvents<T : Any> {
object pointertap : DisplayObjectInteractionEvents<InteractionEvent>
object pointerup : DisplayObjectInteractionEvents<InteractionEvent>
object pointerupoutside : DisplayObjectInteractionEvents<InteractionEvent>
object removed : DisplayObjectInteractionEvents<Container>
object removedFrom : DisplayObjectInteractionEvents<Tuple<DisplayObject, Container, Int>>
object removed : DisplayObjectInteractionEvents<Container<DisplayObject>>
object removedFrom : DisplayObjectInteractionEvents<Tuple<DisplayObject, Container<DisplayObject>, Int>>
object rightclick : DisplayObjectInteractionEvents<InteractionEvent>
object rightdown : DisplayObjectInteractionEvents<InteractionEvent>
object rightup : DisplayObjectInteractionEvents<InteractionEvent>
Expand All @@ -48,10 +48,10 @@ fun <T : Any> DisplayObject.on(event: DisplayObjectInteractionEvents<T>, callbac
fun <T : Any> DisplayObject.once(event: DisplayObjectInteractionEvents<T>, callback: (T) -> Unit) = once(event::class.simpleName!!, callback.unsafeCast<ListenerFn>(), null)
fun <T : Any> DisplayObject.off(event: DisplayObjectInteractionEvents<T>, callback: (T) -> Unit) = off(event::class.simpleName!!, callback.unsafeCast<ListenerFn>(), null)

fun DisplayObject.emitAdded(container: Container) = emit(DisplayObjectInteractionEvents.added, container)
fun DisplayObject.onAdded(callback: (Container) -> Unit) = on(DisplayObjectInteractionEvents.added, callback)
fun DisplayObject.onceAdded(callback: (Container) -> Unit) = once(DisplayObjectInteractionEvents.added, callback)
fun DisplayObject.offAdded(callback: (Container) -> Unit) = off(DisplayObjectInteractionEvents.added, callback)
fun DisplayObject.emitAdded(container: Container<DisplayObject>) = emit(DisplayObjectInteractionEvents.added, container)
fun DisplayObject.onAdded(callback: ( Container<DisplayObject>) -> Unit) = on(DisplayObjectInteractionEvents.added, callback)
fun DisplayObject.onceAdded(callback: ( Container<DisplayObject>) -> Unit) = once(DisplayObjectInteractionEvents.added, callback)
fun DisplayObject.offAdded(callback: ( Container<DisplayObject>) -> Unit) = off(DisplayObjectInteractionEvents.added, callback)

fun DisplayObject.emitClick(event: InteractionEvent) = emit(DisplayObjectInteractionEvents.click, event)
fun DisplayObject.onClick(callback: (InteractionEvent) -> Unit) = on(DisplayObjectInteractionEvents.click, callback)
Expand Down Expand Up @@ -153,15 +153,15 @@ fun DisplayObject.onPointerUpOutside(callback: (InteractionEvent) -> Unit) = on(
fun DisplayObject.oncePointerUpOutside(callback: (InteractionEvent) -> Unit) = once(DisplayObjectInteractionEvents.pointerupoutside, callback)
fun DisplayObject.offPointerUpOutside(callback: (InteractionEvent) -> Unit) = off(DisplayObjectInteractionEvents.pointerupoutside, callback)

fun DisplayObject.emitRemoved(container: Container) = emit(DisplayObjectInteractionEvents.removed, container)
fun DisplayObject.onRemoved(callback: (Container) -> Unit) = on(DisplayObjectInteractionEvents.removed, callback)
fun DisplayObject.onceRemoved(callback: (Container) -> Unit) = once(DisplayObjectInteractionEvents.removed, callback)
fun DisplayObject.offRemoved(callback: (Container) -> Unit) = off(DisplayObjectInteractionEvents.removed, callback)
fun DisplayObject.emitRemoved(container: Container<DisplayObject>) = emit(DisplayObjectInteractionEvents.removed, container)
fun DisplayObject.onRemoved(callback: ( Container<DisplayObject>) -> Unit) = on(DisplayObjectInteractionEvents.removed, callback)
fun DisplayObject.onceRemoved(callback: ( Container<DisplayObject>) -> Unit) = once(DisplayObjectInteractionEvents.removed, callback)
fun DisplayObject.offRemoved(callback: ( Container<DisplayObject>) -> Unit) = off(DisplayObjectInteractionEvents.removed, callback)

fun DisplayObject.emitRemovedFrom(child: DisplayObject, container: Container, index: Int) = emit(DisplayObjectInteractionEvents.removedFrom, child, container, index)
fun DisplayObject.onRemovedFrom(callback: (Tuple<DisplayObject, Container, Int>) -> Unit) = on(DisplayObjectInteractionEvents.removedFrom, callback)
fun DisplayObject.onceRemovedFrom(callback: (Tuple<DisplayObject, Container, Int>) -> Unit) = once(DisplayObjectInteractionEvents.removedFrom, callback)
fun DisplayObject.offRemovedFrom(callback: (Tuple<DisplayObject, Container, Int>) -> Unit) = off(DisplayObjectInteractionEvents.removedFrom, callback)
fun DisplayObject.emitRemovedFrom(child: DisplayObject, container: Container<DisplayObject>, index: Int) = emit(DisplayObjectInteractionEvents.removedFrom, child, container, index)
fun DisplayObject.onRemovedFrom(callback: (Tuple<DisplayObject, Container<DisplayObject>, Int>) -> Unit) = on(DisplayObjectInteractionEvents.removedFrom, callback)
fun DisplayObject.onceRemovedFrom(callback: (Tuple<DisplayObject, Container<DisplayObject>, Int>) -> Unit) = once(DisplayObjectInteractionEvents.removedFrom, callback)
fun DisplayObject.offRemovedFrom(callback: (Tuple<DisplayObject, Container<DisplayObject>, Int>) -> Unit) = off(DisplayObjectInteractionEvents.removedFrom, callback)

fun DisplayObject.emitRightClick(event: InteractionEvent) = emit(DisplayObjectInteractionEvents.rightclick, event)
fun DisplayObject.onRightClick(callback: (InteractionEvent) -> Unit) = on(DisplayObjectInteractionEvents.rightclick, callback)
Expand Down
6 changes: 3 additions & 3 deletions pixi/src/main/kotlin/pixi/externals/extensions/_Rectangle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fun Rectangle.ceil() {
}

infix fun Rectangle.collidesWith(other: Rectangle) = x + width >= other.x && x <= other.x + other.width && y + height >= other.y && y <= other.y + other.height
infix fun Rectangle.collidesWith(other: Container) = x + width >= other.x && x <= other.x + other.width && y + height >= other.y && y <= other.y + other.height
infix fun Rectangle.collidesWith(other: Container<*>) = x + width >= other.x && x <= other.x + other.width && y + height >= other.y && y <= other.y + other.height

fun Rectangle.floor() {
x = floor(x)
Expand Down Expand Up @@ -212,12 +212,12 @@ fun Rectangle.setSize(point: IPointData) {
fun Rectangle(first: IPointData, second: IPointData) = Rectangle(first.x, first.y, second.x - first.x, second.y - first.y)
fun Rectangle(x: Number, y: Number, width: Number, height: Number) = Rectangle(x.toDouble(), y.toDouble(), width.toDouble(), height.toDouble())
fun Rectangle(bounds: Bounds) = bounds.getRectangle()
fun Rectangle(container: Container) = Rectangle(container.x, container.y, container.width, container.height)
fun Rectangle(container: Container<*>) = Rectangle(container.x, container.y, container.width, container.height)
fun Rectangle(window: Window) = Rectangle(0.0, 0.0, window.innerWidth.toDouble(), window.innerHeight.toDouble())

fun Rectangle.Companion.fromApplication(app: Application) = app.screen
fun Rectangle.Companion.fromBounds(bounds: Bounds) = bounds.getRectangle()
fun Rectangle.Companion.fromContainer(container: Container) = Rectangle(container.x, container.y, container.width, container.height)
fun Rectangle.Companion.fromContainer(container: Container<*>) = Rectangle(container.x, container.y, container.width, container.height)
fun Rectangle.Companion.fromPoints(first: IPointData, second: IPointData) = Rectangle(first, second)
fun Rectangle.Companion.fromWindow(window: Window) = Rectangle(0.0, 0.0, window.innerWidth.toDouble(), window.innerHeight.toDouble())
val Rectangle.Companion.WINDOW get() = Rectangle(0.0, 0.0, window.innerWidth.toDouble(), window.innerHeight.toDouble())
5 changes: 5 additions & 0 deletions pixi/src/main/kotlin/pixi/typings/accessibility/typings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.w3c.dom.HTMLElement
import pixi.typings.core.AbstractRenderer
import pixi.typings.core.Renderer
import pixi.typings.display.DisplayObject
import pixi.typings.extensions.ExtensionMetadata
import pixi.typings.math.Rectangle

open external class AccessibilityManager(renderer: AbstractRenderer) {
Expand All @@ -18,6 +19,10 @@ open external class AccessibilityManager(renderer: AbstractRenderer) {
open fun updateDebugHTML(div: IAccessibleHTMLElement)
open fun capHitArea(hitArea: Rectangle)
open fun destroy()

companion object {
var extension: ExtensionMetadata
}
}

external val accessibleTarget: IAccessibleTarget
Expand Down
5 changes: 5 additions & 0 deletions pixi/src/main/kotlin/pixi/typings/app/typeAliases.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pixi.typings.app

interface ResizeableRenderer {
fun resize(desiredScreenWidth: Int, desiredScreenHeight: Int)
}
20 changes: 19 additions & 1 deletion pixi/src/main/kotlin/pixi/typings/app/typings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import org.w3c.dom.HTMLCanvasElement
import pixi.typings.core.AbstractRenderer
import pixi.typings.core.IRendererOptionsAuto
import pixi.typings.display.Container
import pixi.typings.display.DisplayObject
import pixi.typings.display.IDestroyOptions
import pixi.typings.extensions.ExtensionMetadata
import pixi.typings.math.Rectangle

open external class Application(options: IApplicationOptions = definedExternally) {
open var stage: Container
open var stage: Container<DisplayObject>
open var renderer: AbstractRenderer
open val view: HTMLCanvasElement
open val screen: Rectangle
Expand All @@ -20,6 +22,9 @@ open external class Application(options: IApplicationOptions = definedExternally
open fun destroy(removeView: Boolean = definedExternally, stageOptions: Boolean = definedExternally)

companion object {
var _plugins: Array<IApplicationPlugin>

@Deprecated("Use extensions.add(plugin) instead", ReplaceWith("extensions.add"))
fun registerPlugin(plugin: IApplicationPlugin)
}
}
Expand All @@ -32,3 +37,16 @@ external interface IApplicationPlugin {
fun init(options: IApplicationOptions)
fun destroy()
}

external class ResizePlugin {
companion object {
var extension: ExtensionMetadata
var resizeTo: dynamic /* Window | HTMLElement */
var resize: () -> Unit
var renderer: ResizeableRenderer
var queueResize: () -> Unit

fun init(options: IApplicationOptions = definedExternally)
fun destroy()
}
}
10 changes: 10 additions & 0 deletions pixi/src/main/kotlin/pixi/typings/compressed_textures/typings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import pixi.typings.core.IAutoDetectOptions
import pixi.typings.core.Renderer
import pixi.typings.core.Resource
import pixi.typings.core.ViewableBuffer
import pixi.typings.extensions.ExtensionMetadata
import pixi.typings.loaders.LoaderResource
import webgl.WEBGL_compressed_texture_astc
import webgl.WEBGL_compressed_texture_s3tc
import webgl.WEBGL_compressed_texture_s3tc_srgb
import kotlin.js.Promise

abstract external class BlobResource(source: String, options: IBlobOptions = definedExternally) : BufferResource {
Expand Down Expand Up @@ -63,6 +67,8 @@ external interface CompressedTextureExtensionsPartial {

open external class CompressedTextureLoader {
companion object {
var extension: ExtensionMetadata

var textureExtensions: CompressedTextureExtensionsPartial
var textureFormats: Object<INTERNAL_FORMATS, Number>
fun use(resource: LoaderResource, next: VarArgFun<Any?, Unit>)
Expand Down Expand Up @@ -93,6 +99,8 @@ open external class CompressedTextureResource(source: String, options: ICompress

external class DDSLoader {
companion object {
var extension: ExtensionMetadata

fun use(resource: LoaderResource, next: VarArgFun<Any?, Unit>)
}
}
Expand All @@ -117,6 +125,8 @@ external val INTERNAL_FORMAT_TO_BYTES_PER_PIXEL: Object<INTERNAL_FORMATS, Double

external class KTXLoader {
companion object {
var extension: ExtensionMetadata

var loadKeyValueData: Boolean
fun use(resource: LoaderResource, next: VarArgFun<Any?, Unit>)
}
Expand Down
19 changes: 18 additions & 1 deletion pixi/src/main/kotlin/pixi/typings/constants/typings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ external enum class CLEAR_MODES {
BLIT
}

external enum class COLOR_MASK_BITS {
@JsInt(0x1)
RED,

@JsInt(0x2)
GREEN,

@JsInt(0x4)
BLUE,

@JsInt(0x8)
ALPHA
}

external enum class DRAW_MODES {
@JsInt(0)
POINTS,
Expand Down Expand Up @@ -263,7 +277,10 @@ external enum class MASK_TYPES {
STENCIL,

@JsInt(3)
SPRITE
SPRITE,

@JsInt(4)
COLOR
}

external enum class MIPMAP_MODES {
Expand Down
71 changes: 28 additions & 43 deletions pixi/src/main/kotlin/pixi/typings/core/typings.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
@file:Suppress("PropertyName")
@file:Suppress("PropertyName", "unused")
@file:JsModule("@pixi/core")

package pixi.typings.core

import org.khronos.webgl.*
import org.khronos.webgl.WebGLBuffer
import org.khronos.webgl.WebGLContextAttributes
import org.khronos.webgl.WebGLContextEvent
import org.khronos.webgl.WebGLFramebuffer
import org.khronos.webgl.WebGLProgram
import org.khronos.webgl.WebGLRenderbuffer
import org.khronos.webgl.WebGLTexture
import org.khronos.webgl.WebGLUniformLocation
import org.w3c.dom.ErrorEvent
import org.w3c.dom.HTMLCanvasElement
import org.w3c.dom.HTMLImageElement
Expand All @@ -13,9 +21,6 @@ import pixi.externals.Color
import pixi.externals.ColorArr
import pixi.externals.WEBGLVersion
import pixi.typings.Object
import pixi.typings.compressed_textures.WEBGL_compressed_texture_astc
import pixi.typings.compressed_textures.WEBGL_compressed_texture_s3tc
import pixi.typings.compressed_textures.WEBGL_compressed_texture_s3tc_srgb
import pixi.typings.constants.*
import pixi.typings.math.IPointData
import pixi.typings.math.ISize
Expand All @@ -25,6 +30,7 @@ import pixi.typings.math.Rectangle
import pixi.typings.runner.Runner
import pixi.typings.utils.Dict
import pixi.typings.utils.EventEmitter
import webgl.*
import kotlin.js.Promise
import kotlin.js.RegExp

Expand Down Expand Up @@ -871,7 +877,7 @@ external interface IMaskTarget : IFilterTarget {
var isSprite: Boolean?
var worldTransform: Matrix
var isFastRect: (() -> Boolean)?
override fun getBounds(skipUpdate: Boolean): Rectangle
fun getBounds(skipUpdate: Boolean, rect: Rectangle = definedExternally): Rectangle
fun render(renderer: Renderer)
}

Expand Down Expand Up @@ -1011,11 +1017,13 @@ open external class MaskData(maskObject: IMaskTarget = definedExternally) {
open var resolution: Double?
open var multisample: MSAA_QUALITY
open var enabled: Boolean
open var colorMask: COLOR_MASK_BITS
open var _filters: Array<ISpriteMaskFilter>
open var _stencilCounter: Int
open var _scissorCounter: Int
open var _scissorRect: Rectangle?
open var _scissorRectLocal: Rectangle
open var _colorMask: Number
open var _target: IMaskTarget

open var filter: ISpriteMaskFilter
Expand All @@ -1028,13 +1036,15 @@ open external class MaskSystem(renderer: Renderer) : ISystem {
open var enableScissor: Boolean
protected open val alphaMaskPool: Array<Array<SpriteMaskFilter>>
protected open var alphaMaskIndex: Double
fun setMaskStack(maskStack: Array<MaskData>)
fun push(target: IMaskTarget, maskDataOrTarget: MaskData)
fun push(target: IMaskTarget, maskDataOrTarget: IMaskTarget)
fun pop(target: IMaskTarget)
fun detect(maskData: MaskData)
fun pushSpriteMask(maskData: MaskData)
fun popSpriteMask(maskData: MaskData)
open fun setMaskStack(maskStack: Array<MaskData>)
open fun push(target: IMaskTarget, maskDataOrTarget: MaskData)
open fun push(target: IMaskTarget, maskDataOrTarget: IMaskTarget)
open fun pop(target: IMaskTarget)
open fun detect(maskData: MaskData)
open fun pushColorMask(maskData: MaskData)
open fun popColorMask(maskData: MaskData)
open fun pushSpriteMask(maskData: MaskData)
open fun popSpriteMask(maskData: MaskData)
override fun destroy()
}

Expand Down Expand Up @@ -1143,6 +1153,8 @@ open external class Renderer(options: IRendererOptions = definedExternally) : Ab
var __plugins: IRendererPlugins

fun create(options: IRendererOptions = definedExternally): AbstractRenderer

@Deprecated("Use extensions.add(plugin) instead", ReplaceWith("extensions.add"))
fun registerPlugin(pluginName: String, ctor: IRendererPluginConstructor)
}
}
Expand Down Expand Up @@ -1200,6 +1212,7 @@ open external class RenderTextureSystem(renderer: Renderer) : ISystem {
}

abstract external class Resource(width: Int = definedExternally, height: Int = definedExternally) {
open var src: String
open var destroyed: Boolean
open var internal: Boolean
protected open var _width: Int
Expand Down Expand Up @@ -1244,7 +1257,7 @@ open external class ScissorsSystem(renderer: Renderer) : AbstractMaskSystem {
open fun calcScissorRect(maskData: MaskData)
open fun testScissor(maskData: MaskData)
open fun push(maskData: MaskData)
open fun pop()
open fun pop(maskData: MaskData = definedExternally)
override fun _useCurrent()
}

Expand Down Expand Up @@ -1604,6 +1617,8 @@ open external class UniformGroup<LAYOUT /* = Dict<Any> */>(uniforms: LAYOUT, isS

external val uniformParers: Array<IUniformParser>

external val VERSION: String

open external class VideoResource(source: HTMLVideoElement, options: IVideoResourceOptions = definedExternally) : BaseImageResource {
constructor(source: Array<String>, options: IVideoResourceOptions = definedExternally)
constructor(source: Array<IVideoResourceOptionsElement>, options: IVideoResourceOptions = definedExternally)
Expand Down Expand Up @@ -1648,36 +1663,6 @@ open external class ViewableBuffer(length: Int) {
}
}

external interface WEBGL_compressed_texture_atc {
var COMPRESSED_RGB_ATC_WEBGL: Int
var COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: Int
var COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: Int
}

external interface WEBGL_compressed_texture_etc {
var COMPRESSED_R11_EAC: Int
var COMPRESSED_SIGNED_R11_EAC: Int
var COMPRESSED_RG11_EAC: Int
var COMPRESSED_SIGNED_RG11_EAC: Int
var COMPRESSED_RGB8_ETC2: Int
var COMPRESSED_RGBA8_ETC2_EAC: Int
var COMPRESSED_SRGB8_ETC2: Int
var COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: Int
var COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: Int
var COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: Int
}

external interface WEBGL_compressed_texture_etc1 {
var COMPRESSED_RGB_ETC1_WEBGL: Int
}

external interface WEBGL_compressed_texture_pvrtc {
var COMPRESSED_RGB_PVRTC_4BPPV1_IMG: Int
var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: Int
var COMPRESSED_RGB_PVRTC_2BPPV1_IMG: Int
var COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: Int
}

external interface WebGLExtensions {
var drawBuffers: WEBGL_draw_buffers?
var depthTexture: OES_texture_float?
Expand Down
Loading

0 comments on commit 1e24018

Please sign in to comment.