more test music play stuffs

This commit is contained in:
minjaesong
2023-10-21 18:33:13 +09:00
parent f37a28eb17
commit e88b595320
4 changed files with 30 additions and 19 deletions

View File

@@ -167,9 +167,9 @@ object SanicLoadScreen : LoadScreenBase() {
val drawHeight = getPulseEffWidthMul() * textTex.height val drawHeight = getPulseEffWidthMul() * textTex.height
it.draw(textTex, it.draw(textTex,
textX - (drawWidth - textTex.width) / 2f, textX - (drawWidth - textTex.width) / 2f,
glideDispY - 2f - (drawHeight - textTex.height) / 2f, glideDispY - 2f - (drawHeight - textTex.height) / 2f + drawHeight,
drawWidth, drawWidth,
drawHeight -drawHeight
) )

View File

@@ -413,7 +413,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
} }
override fun dispose() { override fun dispose() {
blockMarkings.dispose() // blockMarkings.dispose()
uiPenMenu.dispose() uiPenMenu.dispose()
} }

View File

@@ -3,11 +3,9 @@ package net.torvald.terrarum.modulebasegame
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.audio.Music import com.badlogic.gdx.audio.Music
import com.badlogic.gdx.utils.GdxRuntimeException import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.terrarum.App import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.IngameInstance import net.torvald.unicode.EMDASH
import net.torvald.terrarum.MusicGovernor
import net.torvald.terrarum.tryDispose
import java.io.File import java.io.File
data class MusicContainer( data class MusicContainer(
@@ -25,7 +23,7 @@ class TerrarumMusicGovernor : MusicGovernor() {
printdbg(this, "Music: ${it.absolutePath}") printdbg(this, "Music: ${it.absolutePath}")
try { try {
MusicContainer( MusicContainer(
it.nameWithoutExtension, it.nameWithoutExtension.replace('_', ' ').split(" ").map { it.capitalize() }.joinToString(" "),
it, it,
Gdx.audio.newMusic(Gdx.files.absolute(it.absolutePath)) Gdx.audio.newMusic(Gdx.files.absolute(it.absolutePath))
) )
@@ -36,10 +34,22 @@ class TerrarumMusicGovernor : MusicGovernor() {
} }
} ?: emptyList() // TODO test code } ?: emptyList() // TODO test code
private var currentMusic: MusicContainer? = null
private var musicBin: ArrayList<Int> = ArrayList(songs.indices.toList().shuffled()) private var musicBin: ArrayList<Int> = ArrayList(songs.indices.toList().shuffled())
private var currentMusic: MusicContainer? = null
private var currentAmbient: MusicContainer? = null
private var warningPrinted = false
private val musicVolume: Float
get() = (App.getConfigDouble("bgmvolume") * App.getConfigDouble("mastervolume")).toFloat()
private val ambientVolume: Float
get() = (App.getConfigDouble("sfxvolume") * App.getConfigDouble("mastervolume")).toFloat()
private fun stopMusic() { private fun stopMusic() {
printdbg(this, "Now stopping: $currentMusic") printdbg(this, "Now stopping: $currentMusic")
@@ -52,11 +62,16 @@ class TerrarumMusicGovernor : MusicGovernor() {
printdbg(this, "Intermission: $intermissionLength seconds") printdbg(this, "Intermission: $intermissionLength seconds")
} }
private fun startMusic(song: MusicContainer) {
song.gdxMusic.volume = musicVolume
song.gdxMusic.play()
printdbg(this, "Now playing: $song")
private var warningPrinted = false INGAME.sendNotification("Now Playing $EMDASH ${song.name}")
currentMusic = song
}
private val musicVolume: Float
get() = (App.getConfigDouble("musicvolume") * App.getConfigDouble("mastervolume")).toFloat()
override fun update(ingame: IngameInstance, delta: Float) { override fun update(ingame: IngameInstance, delta: Float) {
if (songs.isEmpty()) { if (songs.isEmpty()) {
@@ -82,11 +97,7 @@ class TerrarumMusicGovernor : MusicGovernor() {
musicBin = ArrayList(songs.indices.toList().shuffled()) musicBin = ArrayList(songs.indices.toList().shuffled())
} }
song.gdxMusic.volume = musicVolume startMusic(song)
song.gdxMusic.play()
printdbg(this, "Now playing: $song")
currentMusic = song
// process fadeout request // process fadeout request
if (fadeoutFired) { if (fadeoutFired) {

View File

@@ -83,7 +83,7 @@ class Notification : UICanvas() {
message.forEachIndexed { index, s -> message.forEachIndexed { index, s ->
val xoff = 6 + (displayedTextWidth - realTextWidth) / 2 val xoff = 6 + (displayedTextWidth - realTextWidth) / 2
val y = -textHeight + App.fontGame.lineHeight * index val y = -textHeight + App.fontGame.lineHeight * index
App.fontGame.draw(batch, s, LRmargin + xoff, y ) App.fontGame.draw(batch, s, LRmargin + xoff, y - 1)
} }