Skip to content

Commit

Permalink
Merge pull request #424 from JD557/export-subsystems
Browse files Browse the repository at this point in the history
Use export for AllSubsystems
  • Loading branch information
JD557 authored Oct 7, 2023
2 parents d1a8629 + 56ce2cc commit 688ccfe
Showing 1 changed file with 4 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,9 @@ private[minart] class AllSubsystems(canvas: LowLevelCanvas, audioPlayer: LowLeve
with Canvas
with AudioPlayer {

// Canvas
def canvasSettings: Canvas.Settings = canvas.canvasSettings
def changeSettings(newSettings: Canvas.Settings): Unit =
canvas.changeSettings(newSettings)
def clear(buffers: Set[Canvas.Buffer]): Unit = canvas.clear(buffers)
def getKeyboardInput(): KeyboardInput = canvas.getKeyboardInput()
def getPointerInput(): PointerInput = canvas.getPointerInput()
def redraw(): Unit = canvas.redraw()
private val _canvas: Canvas = canvas // Export only Canvas methods
export _canvas.*

// MutableSurface
override def fill(color: Color): Unit = canvas.fill(color)
def fillRegion(x: Int, y: Int, w: Int, h: Int, color: Color): Unit = canvas.fillRegion(x, y, w, h, color)
def unsafePutPixel(x: Int, y: Int, color: Color): Unit = canvas.unsafePutPixel(x, y, color)
override def blit(
that: Surface,
blendMode: BlendMode = BlendMode.Copy
)(x: Int, y: Int, cx: Int = 0, cy: Int = 0, cw: Int = that.width, ch: Int = that.height): Unit =
canvas.blit(that, blendMode)(x, y, cx, cy, cw, ch)

// Surface
override def getPixels(): Vector[Array[Color]] = canvas.getPixels()
def unsafeGetPixel(x: Int, y: Int): Color = canvas.unsafeGetPixel(x, y)

// AudioPlayer
def isPlaying(): Boolean = audioPlayer.isPlaying()
def isPlaying(channel: Int): Boolean = audioPlayer.isPlaying(channel)
override def play(clip: AudioClip): Unit = audioPlayer.play(clip)
def play(clip: AudioClip, channel: Int): Unit = audioPlayer.play(clip, channel)
override def play(wave: AudioWave): Unit = audioPlayer.play(wave)
override def play(wave: AudioWave, channel: Int): Unit = audioPlayer.play(wave, channel)
def stop(): Unit = audioPlayer.stop()
def stop(channel: Int): Unit = audioPlayer.stop(channel)
private val _audioPlayer: AudioPlayer = audioPlayer // Export only AudioPlayer methods
export _audioPlayer.*
}

0 comments on commit 688ccfe

Please sign in to comment.