From 84539808d713592393d12872409fc8fb243b477d Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:45:28 -0700 Subject: [PATCH] ui audio player bassicly finished (all we need are volume bar sprites) --- assets/images/editors/charter/audio-icon.png | Bin 0 -> 200 bytes .../editors/charter/audio-time-empty.png | Bin 450 -> 347 bytes source/funkin/backend/utils/FlxClipSprite.hx | 16 ++++ source/funkin/editors/ui/UIAudioPlayer.hx | 84 +++++++++++++----- 4 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 assets/images/editors/charter/audio-icon.png create mode 100644 source/funkin/backend/utils/FlxClipSprite.hx diff --git a/assets/images/editors/charter/audio-icon.png b/assets/images/editors/charter/audio-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..2bc0a4d0da9ec57f777f335981d2a34eeafa8111 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}O`a}}AsQ3s zPQ1v=Y{=p4yS>42(qH?NQXVNh-xqtmn-o`?`?vJ~zc)k7iMu<$8%<{Tu)~;t@l4OO zA|@5fGfSs%@;u)3aPqe)st=?8^0^#Y>lymrJK(DLg=+WrwUXPe=_yJc{aGT|81;J2 y#3daZCm(yIsimpic=AqU;`V=wo(8H5FwFaTB~5ibw}A-IH4L7velF{r5}E+7uT8=L literal 0 HcmV?d00001 diff --git a/assets/images/editors/charter/audio-time-empty.png b/assets/images/editors/charter/audio-time-empty.png index 24157874f2a64485d05c493bbc77ece4dc3c4d65..d5a36361f3ece19d51f36de1ae9440157a67b07c 100644 GIT binary patch delta 307 zcmV-30nGlw1KR?SF@F_FL_t(&f$iG8ii1EDhT-oFnsz|6NS($it+$ZG>&<4bBe{&& z2o~{Y&e_5Y>n_W-2J$^%AvOd0&Wxx4Kvh+zwr$VOIjAa#XtvpGj@Rq;Q}+A)VHk!> z(=;$MnAzH6BU+t^Ktzz|IlT9^lx1o6`yHyvP>7ylD9$+)MSp>097h0vnQ`0o0yt5v zOGE(7_rW;_00V3q002ovPDHLk FV1iE8lmq|( delta 411 zcmV;M0c8H$0>T53F@Iu7L_t(&1?`&8s)A4$#J{!wG7~{8NkkAqm-+<4rJa;pmEQjy zzL<0AlJ^B#oLLN*x@nr~7{^iL zIM&nYq)`-6^uYQIfCVrCHc%w8uB!p$csyzthI%+0D0*Oh27kZ;m;f-#vZ$10X+GdW z5CqhhJ@9>BsqcC4$pDxDC{x3t$4R0!HL|y_zi-A>jhS zMRK13Fo9M9BXYT1%zhLmxvopm17^T=O``%7%pvMhgJW5L1wem9To@z|cC2exM*NfMo= zNl_$t)$0Y96$`8sUwqF1000hUSV?A0O#mtY000O802BZK0002eQ (spritePos.x)) && (mousePos.x < (spritePos.x) + timeBar.barWidth)) - && ((mousePos.y > (spritePos.y)) && (mousePos.y < (spritePos.y) + timeBar.barHeight))) { - timeBarSpr.cursor = BUTTON; - timeBarSpr.alpha = 0.3; - if (FlxG.mouse.justPressed) { - dragging = true; - wasPlaying = sound.playing; - } + for (sprite in [timeBar, volumeBar]) { + var spritePos:FlxPoint = sprite.getScreenPosition(FlxPoint.get(), __lastDrawCameras[0]); - if (FlxG.mouse.pressed && dragging) { - if (sound.playing) sound.pause(); - sound.time = FlxMath.remapToRange(mousePos.x - spritePos.x, 0, timeBar.barWidth, 0, sound.length); + if (((mousePos.x > (spritePos.x)) && (mousePos.x < (spritePos.x) + timeBar.barWidth)) + && ((mousePos.y > (spritePos.y)) && (mousePos.y < (spritePos.y) + timeBar.barHeight))) { + if (FlxG.mouse.justPressed) { + draggingObj = sprite; + wasPlaying = draggingObj == timeBar ? sound.playing : false; + } + + if (FlxG.mouse.pressed) { + if (draggingObj == timeBar) { + if (sound.playing) sound.pause(); + sound.time = FlxMath.remapToRange(mousePos.x - spritePos.x, 0, timeBar.barWidth, 0, sound.length); + } else if (draggingObj == volumeBar) { + sound.volume = FlxMath.remapToRange(mousePos.x - spritePos.x, 0, volumeBar.barWidth, 0, 1); + } + } } - } else { - timeBarSpr.cursor = ARROW; - timeBarSpr.alpha = 0; } - if (FlxG.mouse.released && dragging && wasPlaying) { - sound.play(dragging = wasPlaying = false, sound.time); + if (FlxG.mouse.released && draggingObj == timeBar && wasPlaying) { + draggingObj = null; + sound.play(wasPlaying = false, sound.time); } }