@@ -17,12 +17,15 @@ local author={
1717
1818local scene = {}
1919
20+ local playing
2021local selected -- Music selected
2122
2223local bgmList = BGM .getList ()
2324if # bgmList == 0 then bgmList = {" [NO BGM]" }end
25+
2426function scene .sceneInit ()
25- selected = TABLE .find (bgmList ,BGM .nowPlay )or 1
27+ playing = BGM .getPlaying ()[1 ]
28+ selected = TABLE .find (bgmList ,playing )or 1
2629end
2730
2831function scene .wheelMoved (_ ,y )
@@ -42,7 +45,8 @@ function scene.keyDown(key,isRep)
4245 end
4346 elseif not isRep then
4447 if key == ' return' or key == ' space' then
45- if BGM .nowPlay ~= bgmList [S ]then
48+ playing = BGM .getPlaying ()[1 ]
49+ if playing ~= bgmList [S ]then
4650 BGM .play (bgmList [S ])
4751 SFX .play (' click' )
4852 else
@@ -94,40 +98,40 @@ function scene.draw()
9498 if selected <# bgmList - 1 then GC .print (bgmList [selected + 2 ],322 ,350 + 110 )end
9599
96100 -- Title
97- if BGM . nowPlay then
101+ if playing then
98102 mDraw (TEXTURE .title ,570 ,190 ,nil ,.42 )
99103 local a =- t % 2.3 / 2.3
100104 GC .setColor (1 ,1 ,1 ,math.min (a ,1 ))
101105 mDraw (TEXTURE .title_color ,570 ,190 ,nil ,.42 + .062 - .062 * a )
102106 end
103107
104108 -- Music player
105- if BGM . nowPlay then
109+ if playing then
106110 setFont (45 )
107- GC .shadedPrint (BGM . nowPlay ,710 ,508 ,' left' ,2 )
111+ GC .shadedPrint (playing ,710 ,508 ,' left' ,2 )
108112 GC .setColor (sin (t * .5 )* .2 + .8 ,sin (t * .7 )* .2 + .8 ,sin (t )* .2 + .8 )
109- GC .print (BGM . nowPlay ,710 ,508 )
113+ GC .print (playing ,710 ,508 )
110114 setFont (35 )
111115 GC .setColor (1 ,sin (t * 2.6 )* .5 + .5 ,sin (t * 2.6 )* .5 + .5 )
112- GC .print (author [BGM . nowPlay ]or " MrZ" ,670 ,465 )
116+ GC .print (author [playing ]or " MrZ" ,670 ,465 )
113117
114118 setFont (20 )
115119 GC .setColor (COLOR .Z )
116- local cur = BGM .playing : tell ()
117- local dur = BGM .playing : getDuration ()
120+ local cur = BGM .tell ()
121+ local dur = BGM .getDuration ()
118122 GC .print (STRING .time_simp (cur % dur ).. " / " .. STRING .time_simp (dur ),480 ,626 )
119123 end
120124end
121125
122126scene .widgetList = {
123127 WIDGET .newText {name = ' title' , x = 30 ,y = 30 ,font = 80 ,align = ' L' },
124128 WIDGET .newText {name = ' arrow' , x = 270 ,y = 360 ,font = 45 ,align = ' L' },
125- WIDGET .newText {name = ' now' , x = 700 ,y = 500 ,font = 50 ,align = ' R' ,hideF = function ()return not BGM . nowPlay end },
129+ WIDGET .newText {name = ' now' , x = 700 ,y = 500 ,font = 50 ,align = ' R' ,hideF = function ()return not playing end },
126130 WIDGET .newSlider {name = ' slide' ,x = 480 ,y = 600 ,w = 400 ,
127- disp = function ()return BGM .playing : tell ()/ BGM .playing : getDuration ()% 1 end ,
131+ disp = function ()return BGM .tell ()/ BGM .getDuration ()% 1 end ,
128132 show = false ,
129- code = function (v )BGM .seek ( v * BGM .playing : getDuration ())end ,
130- hideF = function ()return not BGM . nowPlay end
133+ code = function (v )BGM .set ( ' all ' , ' seek ' , v * BGM .getDuration ())end ,
134+ hideF = function ()return not playing end
131135 },
132136 WIDGET .newSlider {name = ' bgm' , x = 760 ,y = 80 ,w = 400 ,disp = SETval (' bgm' ),code = function (v )SETTING .bgm = v BGM .setVol (SETTING .bgm )end },
133137 WIDGET .newButton {name = ' up' , x = 200 ,y = 250 ,w = 120 ,sound = false ,code = pressKey ' up' ,hideF = function ()return selected == 1 end ,font = 60 ,fText = CHAR .key .up },
0 commit comments