/* SC:NowPlaying XUI Object also incorporates nested SC:FadeText pjn123, Quadhelix, SLoB 2008 this is a wip, please do not rip it without giving proper credit */ #include "lib/std.mi" Function setAllTags(); Function resizeToThis(int x, int y, int w, int h); Function FadeGroup(Group FadeGrp, Int AlphaValue); Global Group XUIGroup, cdbox, cdboxref, cdboxHolder, cdboxrefmask, ratings; Global GuiObject line0, line1, line2, line3, BGCol, CDBoxFade; Global int xs, ys, ws, hs; Global int xc, yc, wc, hc; Global layer lyrFx, lyrFxFG; global double dblSmidge; Global int reflectionheight; System.onScriptLoaded(){ XUIGroup = getScriptGroup(); ratings = XUIGroup.findObject("sc.nowplaying.ratings"); cdbox = XUIGroup.findObject("sc.nowplaying.cdbox"); cdboxref = XUIGroup.findObject("sc.nowplaying.cdbox.reflection"); cdboxrefmask = XUIGroup.findObject("sc.nowplaying.cdbox.reflection.mask"); cdboxHolder = XUIGroup.findObject("sc.nowplaying.cdbox.holder"); lyrFx = XUIGroup.findObject("main.albumart.reflection"); lyrFxFG = XUIGroup.findObject("cdbox.fg.reflection"); line0 = XUIGroup.findObject("sc.nowplaying.line0"); line1 = XUIGroup.findObject("sc.nowplaying.line1"); line2 = XUIGroup.findObject("sc.nowplaying.line2"); line3 = XUIGroup.findObject("sc.nowplaying.line3"); BGCol = XUIGroup.findObject("sc.nowplaying.bg"); CDBoxFade = XUIGroup.findObject("cdbox.fg.fademask"); lyrFx.fx_setBgFx(0); lyrFx.fx_setWrap(0); lyrFx.fx_setBilinear(1); lyrFx.fx_setAlphaMode(0); lyrFx.fx_setGridSize(1,1); lyrFx.fx_setRect(1); lyrFx.fx_setClear(0); //left as zero as cover is a static image and we dont need to redraw lyrFx.fx_setLocalized(1); lyrFx.fx_setRealtime(0); lyrFxFG.fx_setBgFx(0); lyrFxFG.fx_setWrap(0); lyrFxFG.fx_setBilinear(1); lyrFxFG.fx_setAlphaMode(0); lyrFxFG.fx_setGridSize(1,1); lyrFxFG.fx_setRect(1); lyrFxFG.fx_setClear(0); //left as zero as cover sheen is a static image and we dont need to redraw lyrFxFG.fx_setLocalized(1); lyrFxFG.fx_setRealtime(0); dblSmidge = 0; //default half height - remove ability to resize for the now reflectionheight=50; //cdboxHolder.Resize(0, 0, 190, 190); } system.onScriptUnloading() { XUIGroup = NULL; } System.onSetXuiParam(String param, String value) { if(strlower(param) == "bgcolor") { string sbgcol = strlower(value); BGCol.setXMLParam("color", sbgcol); //CDBoxFade.setXMLParam("points", "0.0=" + sbgcol + ",0;1.0=" + sbgcol + ",255"); //gradient fade to mask the reflection from image to background ie fade it to nothing //this looks good on both dark and light backgrounds CDBoxFade.setXMLParam("points", "0.0=" + sbgcol + ",0;1.0=" + sbgcol + ",255"); //slob org //hmm pieters extra points looks ok on light bgs but not dark ones //CDBoxFade.setXMLParam("points", "0.0=" + sbgcol + ",0;0.3=" + sbgcol + ",128;0.9=" + sbgcol + ",250;1.0=" + sbgcol + ",255"); //add pieters extra points } else if(strlower(param) == "reflectiontransparency") { string sreftrans = strlower(value); cdboxref.setXMLParam("alpha", sreftrans); } //just default for the now is needed else if(strlower(param) == "reflectionheightpercentage") { //default to 50 if(stringtointeger(value)>100 || stringtointeger(value)<0 || value=="") { reflectionheight = 50; } else { reflectionheight = stringtointeger(value); } } } FadeGroup(Group FadeGrp, Int AlphaValue) { FadeGrp.setTargetA(AlphaValue); FadeGrp.setTargetSpeed(1.3); FadeGrp.gotoTarget(); complete; } lyrFx.fx_onFrame() { if(dblSmidge == 0.000001) { dblSmidge = 0; } else { dblSmidge = 0.000001; } } //reflection, needs dblSmidge to activate, its on a slow timer without clear as its a static image and doesnt need to be cleared every frame lyrFx.fx_onGetPixelY(double r, double d, double x, double y) { return -y-dblSmidge; } lyrFxFG.fx_onGetPixelY(double r, double d, double x, double y) { return -y-dblSmidge; } XUIGroup.onSetVisible(boolean onOff) { if(onOff) { lyrFx.fx_setEnabled(1); lyrFxFG.fx_setEnabled(1); setAllTags(); } } XUIGroup.onResize(int x, int y, int w, int h){ ratings.setXmlParam("x", integerToString((w-ratings.getguiw())/2)); } cdboxHolder.onResize(int x, int y, int w, int h) { xs = x; ys = y; ws = w; hs = h*(300-reflectionheight)/300; resizeToThis(xs, ys, ws, hs); } resizeToThis(int x, int y, int w, int h) { //this has to be here, if below this value then album art resizes itself stupid, do not alter this value - SLoB if(h<100) h=100; int x1, y1, w1, h1; xc = x; yc=y; wc= h; hc=h/2; if(w0) rate= "Bitrate: " +rate; line1.setXmlParam("text", album); line0.setXmlParam("text", year +rate); String myartist = System.getPlayItemMetaDataString("ARTIST"); if(myartist==""){ if(strsearch(getPlayItemDisplayTitle(), "-")== -1){ myartist = "Unknown Artist"; } else{ myartist = getToken(getPlayItemDisplayTitle(), "- ", 0); } } line2.setXmlParam("text", myartist); String mytitle = System.getPlayItemMetaDataString("TITLE"); if(mytitle==""){ if(strsearch(getPlayItemDisplayTitle(), "-")== -1){ mytitle = getPlayItemDisplayTitle(); } else{ mytitle = getToken(getPlayItemDisplayTitle(), "- ", 1); } } line3.setXmlParam("text", mytitle); lyrFx.fx_setEnabled(1); lyrFxFG.fx_setEnabled(1); lyrFx.fx_restart(); lyrFxFG.fx_restart(); //for fading the album in //FadeGroup(cdboxHolder, 255); }