diff --git a/data/sound/Astrolabe.ogg b/data/sound/Astrolabe.ogg deleted file mode 100644 index ca45c29e..00000000 Binary files a/data/sound/Astrolabe.ogg and /dev/null differ diff --git a/data/sound/Endurance.ogg b/data/sound/Endurance.ogg deleted file mode 100644 index 7e08ea20..00000000 Binary files a/data/sound/Endurance.ogg and /dev/null differ diff --git a/data/sound/Flanked.ogg b/data/sound/Flanked.ogg deleted file mode 100644 index 801895c3..00000000 Binary files a/data/sound/Flanked.ogg and /dev/null differ diff --git a/data/sound/Groove Police.ogg b/data/sound/Groove Police.ogg deleted file mode 100644 index 14e6fd30..00000000 Binary files a/data/sound/Groove Police.ogg and /dev/null differ diff --git a/data/sound/Grudge.ogg b/data/sound/Grudge.ogg deleted file mode 100644 index cf277c07..00000000 Binary files a/data/sound/Grudge.ogg and /dev/null differ diff --git a/data/sound/MBPOldShell.ogg b/data/sound/MBPOldShell.ogg deleted file mode 100644 index 4fdd2dfb..00000000 Binary files a/data/sound/MBPOldShell.ogg and /dev/null differ diff --git a/data/sound/Metropolis.ogg b/data/sound/Metropolis.ogg deleted file mode 100644 index 77aa1ce9..00000000 Binary files a/data/sound/Metropolis.ogg and /dev/null differ diff --git a/data/sound/Pianoforte.ogg b/data/sound/Pianoforte.ogg deleted file mode 100644 index 5995c9a8..00000000 Binary files a/data/sound/Pianoforte.ogg and /dev/null differ diff --git a/data/sound/Quiet Lab.ogg b/data/sound/Quiet Lab.ogg deleted file mode 100644 index 6870d897..00000000 Binary files a/data/sound/Quiet Lab.ogg and /dev/null differ diff --git a/data/sound/Rising Temper.ogg b/data/sound/Rising Temper.ogg deleted file mode 100644 index 7d1236b2..00000000 Binary files a/data/sound/Rising Temper.ogg and /dev/null differ diff --git a/data/sound/Seaside Revisited.ogg b/data/sound/Seaside Revisited.ogg deleted file mode 100644 index 29161c2a..00000000 Binary files a/data/sound/Seaside Revisited.ogg and /dev/null differ diff --git a/data/sound/Seaside.ogg b/data/sound/Seaside.ogg deleted file mode 100644 index c4b8f329..00000000 Binary files a/data/sound/Seaside.ogg and /dev/null differ diff --git a/data/sound/The Race.ogg b/data/sound/The Race.ogg deleted file mode 100644 index e180f804..00000000 Binary files a/data/sound/The Race.ogg and /dev/null differ diff --git a/data/sound/Tim Trance.ogg b/data/sound/Tim Trance.ogg deleted file mode 100644 index 5ae3339a..00000000 Binary files a/data/sound/Tim Trance.ogg and /dev/null differ diff --git a/data/sound/beach party.ogg b/data/sound/beach party.ogg deleted file mode 100644 index 0939a0c1..00000000 Binary files a/data/sound/beach party.ogg and /dev/null differ diff --git a/data/sound/classic vibe.ogg b/data/sound/classic vibe.ogg deleted file mode 100644 index 0ab5f9af..00000000 Binary files a/data/sound/classic vibe.ogg and /dev/null differ diff --git a/data/sound/music/Astrolabe.ogg b/data/sound/music/Astrolabe.ogg new file mode 100644 index 00000000..37a8fe49 Binary files /dev/null and b/data/sound/music/Astrolabe.ogg differ diff --git a/data/sound/music/Beach Party.ogg b/data/sound/music/Beach Party.ogg new file mode 100644 index 00000000..675dfb1f Binary files /dev/null and b/data/sound/music/Beach Party.ogg differ diff --git a/data/sound/music/Challenge.ogg b/data/sound/music/Challenge.ogg new file mode 100644 index 00000000..7a6c7e6b Binary files /dev/null and b/data/sound/music/Challenge.ogg differ diff --git a/data/sound/music/Classic Vibe.ogg b/data/sound/music/Classic Vibe.ogg new file mode 100644 index 00000000..dd795b39 Binary files /dev/null and b/data/sound/music/Classic Vibe.ogg differ diff --git a/data/sound/music/Comforting Mystery.ogg b/data/sound/music/Comforting Mystery.ogg new file mode 100644 index 00000000..6cf250e0 Binary files /dev/null and b/data/sound/music/Comforting Mystery.ogg differ diff --git a/data/sound/music/Endurance.ogg b/data/sound/music/Endurance.ogg new file mode 100644 index 00000000..9066e4f3 Binary files /dev/null and b/data/sound/music/Endurance.ogg differ diff --git a/data/sound/music/Flanked.ogg b/data/sound/music/Flanked.ogg new file mode 100644 index 00000000..64a3a7df Binary files /dev/null and b/data/sound/music/Flanked.ogg differ diff --git a/data/sound/music/Groove Police.ogg b/data/sound/music/Groove Police.ogg new file mode 100644 index 00000000..2b831ed1 Binary files /dev/null and b/data/sound/music/Groove Police.ogg differ diff --git a/data/sound/music/Grudge.ogg b/data/sound/music/Grudge.ogg new file mode 100644 index 00000000..b47c52bf Binary files /dev/null and b/data/sound/music/Grudge.ogg differ diff --git a/data/sound/music/MBP Old Shell.ogg b/data/sound/music/MBP Old Shell.ogg new file mode 100644 index 00000000..ddbe41f4 Binary files /dev/null and b/data/sound/music/MBP Old Shell.ogg differ diff --git a/data/sound/music/Metropolis.ogg b/data/sound/music/Metropolis.ogg new file mode 100644 index 00000000..a9f6688b Binary files /dev/null and b/data/sound/music/Metropolis.ogg differ diff --git a/data/sound/music/Pianoforte.ogg b/data/sound/music/Pianoforte.ogg new file mode 100644 index 00000000..d90da0ac Binary files /dev/null and b/data/sound/music/Pianoforte.ogg differ diff --git a/data/sound/music/Quiet Lab.ogg b/data/sound/music/Quiet Lab.ogg new file mode 100644 index 00000000..7f542d42 Binary files /dev/null and b/data/sound/music/Quiet Lab.ogg differ diff --git a/data/sound/music/Rising Temper.ogg b/data/sound/music/Rising Temper.ogg new file mode 100644 index 00000000..51b57ead Binary files /dev/null and b/data/sound/music/Rising Temper.ogg differ diff --git a/data/sound/music/Seaside Revisited.ogg b/data/sound/music/Seaside Revisited.ogg new file mode 100644 index 00000000..a7ae3b62 Binary files /dev/null and b/data/sound/music/Seaside Revisited.ogg differ diff --git a/data/sound/music/Shell.ogg b/data/sound/music/Shell.ogg new file mode 100644 index 00000000..80723135 Binary files /dev/null and b/data/sound/music/Shell.ogg differ diff --git a/data/sound/music/The Race.ogg b/data/sound/music/The Race.ogg new file mode 100644 index 00000000..d44a5134 Binary files /dev/null and b/data/sound/music/The Race.ogg differ diff --git a/data/sound/music/Tim Trance.ogg b/data/sound/music/Tim Trance.ogg new file mode 100644 index 00000000..4341d97a Binary files /dev/null and b/data/sound/music/Tim Trance.ogg differ diff --git a/data/sound/music/Xmas Trance.ogg b/data/sound/music/Xmas Trance.ogg new file mode 100644 index 00000000..fb322a52 Binary files /dev/null and b/data/sound/music/Xmas Trance.ogg differ diff --git a/data/sound/shell.ogg b/data/sound/shell.ogg deleted file mode 100644 index 173fa750..00000000 Binary files a/data/sound/shell.ogg and /dev/null differ diff --git a/src/AudioManager.hx b/src/AudioManager.hx index 51306ffd..108bb753 100644 --- a/src/AudioManager.hx +++ b/src/AudioManager.hx @@ -58,7 +58,7 @@ class AudioManager { public static function playShell() { AudioManager.manager.stopByName("music"); - var sndres = ResourceLoader.getAudio("data/sound/pianoforte.ogg"); + var sndres = ResourceLoader.getAudio("data/sound/music/Pianoforte.ogg"); if (sndres == null) return; sndres.acquire(); diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 35e9d52c..23324c88 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -228,7 +228,7 @@ class MarbleWorld extends Scheduler { } public function loadMusic(onFinish:Void->Void) { - var musicFileName = 'sound/' + this.mission.missionInfo.music; + var musicFileName = 'sound/music/' + this.mission.missionInfo.music; ResourceLoader.load(musicFileName).entry.load(onFinish); } @@ -238,7 +238,7 @@ class MarbleWorld extends Scheduler { this._ready = true; this.playGui.init(this.scene2d); - var musicFileName = 'data/sound/' + this.mission.missionInfo.music; + var musicFileName = 'data/sound/music/' + this.mission.missionInfo.music; AudioManager.playMusic(ResourceLoader.getResource(musicFileName, ResourceLoader.getAudio, this.soundResources), this.mission.missionInfo.music); MarbleGame.canvas.clearContent(); this.endPad.generateCollider(); diff --git a/src/gui/GuiTextListCtrl.hx b/src/gui/GuiTextListCtrl.hx index f069dba3..adad28ca 100644 --- a/src/gui/GuiTextListCtrl.hx +++ b/src/gui/GuiTextListCtrl.hx @@ -88,6 +88,7 @@ class GuiTextListCtrl extends GuiControl { public override function render(scene2d:Scene) { var renderRect = this.getRenderRectangle(); + var htr = this.getHitTestRect(); if (scene2d.contains(g)) scene2d.removeChild(g); @@ -97,8 +98,6 @@ class GuiTextListCtrl extends GuiControl { if (scrollable) { this.flow = new Flow(); - var htr = this.getHitTestRect(); - this.flow.maxWidth = cast htr.extent.x; this.flow.maxHeight = cast htr.extent.y; this.flow.multiline = true; @@ -134,7 +133,7 @@ class GuiTextListCtrl extends GuiControl { } } - redrawSelectionRect(renderRect); + redrawSelectionRect(htr); super.render(scene2d); } diff --git a/src/gui/JukeboxDlg.hx b/src/gui/JukeboxDlg.hx index 9d88a89f..6c2a518d 100644 --- a/src/gui/JukeboxDlg.hx +++ b/src/gui/JukeboxDlg.hx @@ -32,12 +32,10 @@ class JukeboxDlg extends GuiImage { var markerFelt24 = markerFelt32b.toSdfFont(cast 18 * Settings.uiScale, MultiChannel); var markerFelt18 = markerFelt32b.toSdfFont(cast 14 * Settings.uiScale, MultiChannel); - var songList = [ - "Astrolabe", "Beach Party", "Challenge", "Classic Vibe", "Comforting Mystery", "Endurance", "Flanked", "Groove Police", "Grudge", "MBP Old Shell", - "Metropolis", "Pianoforte", "Quiet Lab", "Rising Temper", "Seaside Revisited", "Shell", "The Race", "Tim Trance", "Xmas Trance" - ]; + var songFiles = ResourceLoader.fileSystem.dir("data/sound/music"); + var songList = songFiles.map(x -> StringTools.replace(x.name, ".ogg", "")); - var playing:Bool = AudioManager.currentMusicPaused; + var playing:Bool = !AudioManager.currentMusicPaused; var selectedIdx:Int = 0; var currentPlayingSong = StringTools.replace(AudioManager.currentMusicName, ".ogg", ""); @@ -71,13 +69,27 @@ class JukeboxDlg extends GuiImage { songCtrl.textYOffset = -6; songCtrl.selectedColor = 0; songCtrl._prevSelected = selectedIdx; - songCtrl.onSelectedFunc = (idx) -> { - selectedIdx = idx; - songTitle.text.text = '

Title: ${songList[idx]}

'; - }; scroll.addChild(songCtrl); scroll.setScrollMax(songCtrl.calculateFullHeight()); + function setCurrentSong(idx:Int) { + selectedIdx = idx; + songCtrl._prevSelected = idx; + songTitle.text.text = '

Title: ${songList[idx]}

'; + songCtrl.redrawSelectionRect(songCtrl.getHitTestRect()); + + if (playing) { + songFiles[idx].load(() -> { + var audiores = ResourceLoader.getAudio(songFiles[idx].path).resource; + AudioManager.playMusic(audiores, songList[idx]); + }); + } + } + + songCtrl.onSelectedFunc = (idx) -> { + setCurrentSong(idx); + }; + var stopBtn = new GuiButton(loadButtonImages("data/ui/jukebox/stop")); stopBtn.position = new Vector(219, 306); stopBtn.extent = new Vector(96, 45); @@ -93,6 +105,7 @@ class JukeboxDlg extends GuiImage { playBtn.render(MarbleGame.canvas.scene2d); playing = false; songStatus.text.text = '

${playing ? "Playing" : "Stopped"}

'; + AudioManager.pauseMusic(true); }; playBtn.pressedAction = (e) -> { @@ -101,14 +114,25 @@ class JukeboxDlg extends GuiImage { stopBtn.render(MarbleGame.canvas.scene2d); playing = true; songStatus.text.text = '

${playing ? "Playing" : "Stopped"}

'; + if (AudioManager.currentMusicName != songList[selectedIdx]) { + songFiles[selectedIdx].load(() -> { + var audiores = ResourceLoader.getAudio(songFiles[selectedIdx].path).resource; + AudioManager.playMusic(audiores, songList[selectedIdx]); + }); + } else { + AudioManager.pauseMusic(false); + } }; var prevBtn = new GuiButton(loadButtonImages("data/ui/play/prev")); prevBtn.position = new Vector(145, 307); prevBtn.extent = new Vector(72, 43); prevBtn.pressedAction = (e) -> { - if (selectedIdx > 1) - songCtrl.onSelectedFunc(selectedIdx - 1); + if (selectedIdx >= 1) { + setCurrentSong(selectedIdx - 1); + } else { + setCurrentSong(songList.length - 1); + } } this.addChild(prevBtn); @@ -116,8 +140,11 @@ class JukeboxDlg extends GuiImage { nextBtn.position = new Vector(317, 307); nextBtn.extent = new Vector(72, 43); nextBtn.pressedAction = (e) -> { - if (selectedIdx < songList.length) - songCtrl.onSelectedFunc(selectedIdx + 1); + if (selectedIdx < songList.length - 1) { + setCurrentSong(selectedIdx + 1); + } else { + setCurrentSong(0); + } } this.addChild(nextBtn);