-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #425 from JD557/cake-subsystems
Make AllSubsystems a cake
- Loading branch information
Showing
8 changed files
with
85 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
core/shared/src/main/scala/eu/joaocosta/minart/backend/subsystem/AudioPlayerSubsystem.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package eu.joaocosta.minart.backend.subsystem | ||
|
||
import eu.joaocosta.minart.audio.AudioPlayer | ||
|
||
/** Subsystem cake with an AudioPlayer | ||
*/ | ||
trait AudioPlayerSubsystem(val audioPlayer: AudioPlayer) |
7 changes: 7 additions & 0 deletions
7
core/shared/src/main/scala/eu/joaocosta/minart/backend/subsystem/CanvasSubsystem.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package eu.joaocosta.minart.backend.subsystem | ||
|
||
import eu.joaocosta.minart.graphics.Canvas | ||
|
||
/** Subsystem cake with a Canvas | ||
*/ | ||
trait CanvasSubsystem(val canvas: Canvas) |
38 changes: 38 additions & 0 deletions
38
core/shared/src/main/scala/eu/joaocosta/minart/backend/subsystem/LowLevelAllSubsystems.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package eu.joaocosta.minart.backend.subsystem | ||
|
||
import eu.joaocosta.minart.audio._ | ||
import eu.joaocosta.minart.backend.defaults.DefaultBackend | ||
import eu.joaocosta.minart.graphics._ | ||
import eu.joaocosta.minart.input._ | ||
|
||
/** Aggregation of all subsystems. | ||
*/ | ||
case class LowLevelAllSubsystems( | ||
lowLevelCanvas: LowLevelCanvas, | ||
lowLevelAudioPlayer: LowLevelAudioPlayer | ||
) extends AllSubsystems(lowLevelCanvas, lowLevelAudioPlayer) | ||
with LowLevelSubsystem[(Canvas.Settings, AudioPlayer.Settings)] { | ||
def settings: (Canvas.Settings, AudioPlayer.Settings) = (lowLevelCanvas.settings, lowLevelAudioPlayer.settings) | ||
def isCreated(): Boolean = lowLevelCanvas.isCreated() && lowLevelAudioPlayer.isCreated() | ||
def init(settings: (Canvas.Settings, AudioPlayer.Settings)): this.type = { | ||
lowLevelCanvas.init(settings._1) | ||
lowLevelAudioPlayer.init(settings._2) | ||
this | ||
} | ||
def changeSettings(newSettings: (Canvas.Settings, AudioPlayer.Settings)): Unit = { | ||
lowLevelCanvas.changeSettings(newSettings._1) | ||
lowLevelAudioPlayer.changeSettings(newSettings._2) | ||
} | ||
def close(): Unit = { | ||
lowLevelCanvas.close() | ||
lowLevelAudioPlayer.close() | ||
} | ||
} | ||
|
||
object LowLevelAllSubsystems { | ||
implicit def defaultLowLevelAllSubsystems(implicit | ||
c: DefaultBackend[Any, LowLevelCanvas], | ||
a: DefaultBackend[Any, LowLevelAudioPlayer] | ||
): DefaultBackend[Any, LowLevelAllSubsystems] = | ||
DefaultBackend.fromFunction((_) => LowLevelAllSubsystems(c.defaultValue(), a.defaultValue())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters