// // global functions - // - enable // - disable // - hideall // - toggle // // dragLook // openMenu // toggle // playback // makeMini // switchMode // playlist // playlistScrollBtn // dragBar // spectrumAnim // // jobs: // - major fiddle with playlist // - make dragBar check if srcoff is set, and if so, update the rendermap for progBar // must remember - // look_getFillcolor() // look_getFontcolor() // bool look_isaot() section color list darkblue int { 255 12 48 69 } list ghostblue int { 90 14 48 69 } list ghostgray int { 25 0 0 0 } list solidgray int { 255 40 40 40 } list ghostlightgray int { 35 145 145 145 } list ghostwhite int { 60 255 255 255 } list black int { 255 0 0 0 } list white int { 255 255 255 255 } list null int { 0 0 0 0 } section states list roll int { 0 1 0 0 0 0 1 0 0 0 } list press int { 0 0 1 1 0 0 0 1 1 0 } list rollpress int { 0 1 2 2 0 0 1 2 2 0 } list rollpress1 int { 0 1 1 1 0 0 1 1 1 0 } list presstogg int { 0 0 1 1 0 1 1 1 1 0 } section tagz string plEntry "$num(%_playlist_number%,2). $replace($caps2($if(%title%,[%artist% - ]%title%,%_filename%)),_, )" string title "$if(%artist%,$ifgreater($strcmp(%title%,),0,stopped.,$if2(''$replace(%title%,-, - )'',''untitled'')),$lower($directory(%_path%,1))\)" string visText "$replace($if(%title%,$ifgreater($strcmp(%artist%,),0,,%artist% - )%title%,%_filename%),_, , , )" string miniText "$upper($replace($if(%title%,$ifgreater($strcmp(%artist%,),0,,%artist% - )%title%,%_filename%),_, , , ))" section globals string script " plgrp = { report, plupdate, ple_1, ple_2,ple_3, ple_4,ple_5,ple_6, nowPlaying, playlistUp, playlistDown, nowArrow, jumpfocus, jumpcurrent } id3grp = { report, artist, title, songtime, songtime2, progBox, progBar } visgrp = { report, spectrum, progBox2, progBar2, visText } minigrp = { report, miniText, miniTime, miniprev, miniplay, ministop, mininext, progBox2, progBar2 } plygrp = { prevbutton, playbutton, stopbutton, nextbutton } miniplaybackgrp = { miniprev, miniplay, ministop, mininext } prg2grp = { progBox2, progBar2 } pln = { ple_1, ple_2, ple_3, ple_4, ple_5, ple_6 } tabgrp = { pltab, id3tab, vistab } menugrp = { playbackmenu, playlistmenu, componentsmenu, leftMask, rightMask, bignumber } -- global functions function enable(group) look_setVisible(group,true) look_setEnabled(group,true) end function disable(group) look_setVisible(group,false) look_setEnabled(group,false) end function constrain(variable,min,max) temp = variable if variable < min then temp = min elseif variable > max then temp = max end return temp; end function hideAll(this) disable(plgrp) disable(id3grp) disable(visgrp) disable(minigrp) --disable(tabgrp) --disable(menugrp) end function toggle(this) local temp = look_getToggle(this) local temp2 = 0 if temp == 0 then look_setToggle(this, 1) temp2 = 1 else look_setToggle(this, 0) end end " //// basic utility scripts //// lua textscroll origRect, textRect = nil delay, toobig, scrollRate = 0 currText = "" function onattach(this) delay = 25 origRect = look_getRect(this) updateWidth(this) end function updateWidth(this) if (look_getText(this) == currText) then return else currText = look_getText(this) end textRect = look_measureTextAbs(this) look_setWidth(this, textRect.width + 1) if textRect.width > origRect.width then toobig = 1 look_setX(this, origRect.x) scrollRate = -2 else toobig = 0 look_setX(this, origRect.x + (origRect.width - textRect.width)) end delay = 25 end function onplaybacknewtrack(this) updateWidth(this) end function onupdateplayerstatus(this) updateWidth(this) end function scroll(this,amt) look_setX(this, look_getX(this) + amt) end function onupdate(this) if toobig == 1 then if delay > 0 then delay = delay - 1 else scroll(this,scrollRate) if (look_getX(this) + look_getWidth(this) < origRect.x + origRect.width) then scrollRate = 2 delay = 25 elseif (look_getX(this) >= origRect.x) then scrollRate = -2 delay = 25 end end end end endlua lua blackOnRoll oldcolor = 0 function onmouseenter(this) oldcolor = look_color( 255, 0,0,0) look_setFontColor(this, oldcolor) end function onmouseleave(this) oldcolor = look_color( 255, 150,150,150) look_setFontColor(this, oldcolor) end endlua lua draglook function onleftbuttondown(this) look_drag() end endlua lua openMenu menu = nil function onleftbuttonup(this) fb2k_mainMenu(menu) end endlua lua toggle init = 0 target = nil function onattach(this) look_setToggle(this, init) end function onleftbuttonup(this) local current = 0 if target then current = look_getToggle(target) else current = look_getToggle(this) end local switch = abs((current + 1) - 2) if target then look_setToggle(target, switch) else look_setToggle(this, switch) end end endlua //// playback specific ///// lua playback type = nil function playPause(this) if fb2k_isPlaying() then fb2k_playPause() else fb2k_playStart() end end function onleftbuttonup(this) if type == 'prev' then fb2k_playSkipStart(-1) elseif type == 'playpause' then playPause(this) elseif type == 'stop' then fb2k_playStop() elseif type == 'next' then fb2k_playSkipStart(1) end end function onrightbuttonup(this) if type == 'prev' then fb2k_playStart() elseif type == 'playpause' then fb2k_playStart() elseif type == 'next' then fb2k_menuCommand('Playback/Random') end end endlua // skin modes // lua switchMode init = nil i = 0 function resetTabs(this) look_setToggle(tabgrp,0) end function setTab(tab) if tab ~= 0 then resetTabs() if tab == 1 then look_setToggle(pltab,1) elseif tab == 2 then look_setToggle(id3tab,1) elseif tab == 3 then look_setToggle(vistab,1) end end end function showMode(mode) if mode == 1 then enable(plgrp) elseif mode == 2 then enable(id3grp) elseif mode == 3 then enable(visgrp) end end function onattach(this) if init ~= nil then hideAll() showMode(init) setTab(init) end end function onleftbuttonup(this) if i ~= 0 then hideAll() end if i == 1 then enable(plgrp) elseif i== 2 then enable(id3grp) elseif i == 3 then enable(visgrp) end setTab(i) end endlua lua makeMini minisrc = { x=2, y=264 } miniRect = { x=0, y=0, width=244, height=34 } bigsrc = { x=26, y=14 } bigRect = { x=0, y=0, width=244, height=109 } init = 0 prevstate = 2 function doMini() look_moveSizeWindow(-1,-1,244,34) look_setRect(background,miniRect) look_setSrcX(background,minisrc.x) look_setSrcY(background,minisrc.y) hideAll() disable(menugrp) enable(minigrp) look_setY(miniplaybackgrp,3) look_setX(miniprev,20) look_setX(miniplay,32) look_setX(ministop,44) look_setX(mininext,53) look_setX(prg2grp,70) look_setY(prg2grp,2) look_setHeight(prg2grp,8) look_setWidth(progBox2,125) end function doBig() look_moveSizeWindow(-1,-1,244,109) look_setRect(background,bigRect) look_setSrcX(background,bigsrc.x) look_setSrcY(background,bigsrc.y) look_setY(miniplaybackgrp,98) look_setX(miniprev,154) look_setX(miniplay,166) look_setX(ministop,178) look_setX(mininext,187) hideAll() enable(menugrp) look_callScript(pltab,'showMode',prevstate) look_callScript(pltab,'setTab',prevstate) look_setX(prg2grp,8) look_setY(prg2grp,18) look_setHeight(prg2grp,10) look_setWidth(progBox2,219) end function onleftbuttondown(this) local temp = look_getToggle(this) local temp2 = 0 if temp == 1 then doBig() end if temp == 0 then doMini() temp2 = 1 end look_setToggle(this,temp2) end function onattach(this) look_setToggle(this,init) if init == 1 then doMini() end end endlua lua doubleMini function onleftbuttondoubleclick(this) if look_getToggle(this) == 0 then look_callScript(makemini,'doMini') look_setToggle(this,1) else look_callScript(makemini,'doBig') look_setToggle(this,0) end end function onattach(this) if look_getValue('presets','startsize') == 1 then look_setToggle(this,1) else look_setToggle(this,0) end end endlua /// playlist specific /// lua playlistControl function onleftbuttondoubleclick(this) fb2k_playlistPlay(look_getPlaylistIndex(this)) end function onleftbuttonup(this) fb2k_playlistSetFocusSel(look_getPlaylistIndex(this)) end function onrightbuttonup(this) fb2k_playlistSetFocusSel(look_getPlaylistIndex(this)) fb2k_playlistContextMenu() end function onmousewheel(this, delta) if delta < 0 then look_callScript(nowPlaying,'scrollPlaylist',1) elseif delta > 0 then look_callScript(nowPlaying,'scrollPlaylist',-1) end end endlua // lua playlist playlistScrollPos = 0 function updateIndicators() for i=0, 5 do s = playlistScrollPos + i look_setPlaylistIndex(pln[i+1],s) if s == fb2k_getNowPlaying() then look_setFontStyle(pln[i+1], look_getValue("fontstyle","italic")) look_setFillColor(pln[i+1],look_color(105, 255, 255, 100)) -- local temp = look_getY(pln[i+1]) -- updateArrow(temp) else look_setFontStyle(pln[i+1], look_getValue("fontstyle","regular")) look_setFillColor(pln[i+1],look_color(0, 0, 0, 0)) end if s == fb2k_playlistGetFocus() then look_setBorderWidth(pln[i+1], 1) -- look_setFillColor(pln[i+1],look_color(35, 50, 40, 80)) else look_setBorderWidth(pln[i+1], 0) -- look_setFillColor(pln[i+1],look_color(0, 0, 0, 0)) end end end function scrollPlaylist(dir) if (dir < 0 and playlistScrollPos == 0) then return end if (dir > 0 and playlistScrollPos >= fb2k_playlistGetCount()-1) then return end playlistScrollPos = playlistScrollPos + dir updateIndicators() look_updateTagz() end function scrollTo(index) if (index >= 0) then playlistScrollPos = index -- fb2k_playlistSetFocusSel(playlistScrollPos) scrollPlaylist(0) end end function initScrollPos() playlistScrollPos = fb2k_getNowPlaying() if playlistScrollPos == -1 then playlistScrollPos = fb2k_playlistGetFocus() end if playlistScrollPos == -1 then playlistScrollPos = 0 end scrollPlaylist(0) end function onplaybacknewtrack(this) scrollPlaylist(0) end function onplaylistfocuschange(this,from,to) scrollPlaylist(0) end function onattach(this) initScrollPos() end endlua lua playlistScrollBtn dir, count = 0 bdown = false function onleftbuttondown(this) look_callScript(nowPlaying,'scrollPlaylist',dir) bdown = true count = -1 end function onupdate(this) if bdown then count = count + 1 if (count > -1) then count = 0 look_callScript(nowPlaying,'scrollPlaylist',dir) end end end function onleftbuttonup(this) bdown = false end function onleftbuttonupoutside(this) bdown = false end endlua // spectrum // lua spectrumAnim direction = 1 speed = 3 function onupdate(this) local temp = clock() local y = look_getSrcY(spectrum) if direction == 1 then y = y + speed else y = y - speed end if y > 140 then y = 140 direction = 0 end if y < 55 then y = 55 direction = 1 end look_setSrcY(spectrum,y) end endlua /// progress bar specific /// lua dragBar sliding = false prev = 0 gripOffset = 0 function onattach(this) boxRect = look_getRect(this) if grip then gripOffset = look_getWidth(grip) / 2 boxRect.x = boxRect.x + gripOffset boxRect.width = boxRect.width - (2 * gripOffset) end end function onupdate(this) if sliding == true then followCursor(this) elseif scanning == true then elseif fb2k_isPlaying() and not fb2k_isPaused() then setBarPercent(this, getTimePercent(this)) end end function onleftbuttondown(this) sliding = true end function onleftbuttonup(this) sliding = false setTimePercent(this) end function onleftbuttonupoutside(this) onleftbuttonup(this) end function onrightbuttondown(this) scanning = true end function onrightbuttonup(this) scanning = false end function onrightbuttonupoutside(this) onrightbuttonup(this) end function onplaybackstop(this) setBarPercent(this, 0) end function getBarPercent(this) currentWidth = look_getWidth(bar) - gripOffset maxWidth = boxRect.width return currentWidth / maxWidth end function setBarPercent(this, percent) newWidth = percent * boxRect.width + gripOffset look_setWidth(bar, newWidth) setGrip(newWidth - gripOffset) end function setGrip(newWidth) if grip then look_setX(grip, boxRect.x + newWidth - gripOffset) end end function getTimePercent(this) return fb2k_getPlayPosition() / fb2k_getSongLength(); end function setTimePercent(this) fb2k_playbackSeek(getBarPercent(this) * fb2k_getSongLength()) end function constrain(variable,min,max) temp = variable if variable < min then temp = min elseif variable > max then temp = max end return temp; end function followCursor(this) relativeMouseX = look_mouseX() - boxRect.x if newx ~= prev then temp = constrain(relativeMouseX, 0, boxRect.width) look_setWidth(bar, temp + gripOffset) setGrip(temp) prev = temp end end endlua