Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Another Seekbar for JScript Panel (Read 1117 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Another Seekbar for JScript Panel

I wrote a script for a seekbar in CUI with running green bars and gauges in it. The script was for WSH Panel mod. Script engine was JScript9.

Code: [Select]
DT_TOP = 0x00000000;
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_VCENTER = 0x00000004;
DT_BOTTOM = 0x00000008;
DT_SINGLELINE = 0x00000020;
DT_NOPREFIX = 0x00000800;

//--------

var g_font = gdi.Font("arial",18,1);
var g_font_rating = gdi.Font("Arial Unicode MS",25,0);
var g_fileinfo = null;

var g_drag = 0;
var g_drag_seek = 0;

var ww, wh, area;

//--------

function RGB(r,g,b){
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function RGBA(r,g,b,a){
return ((a<<24)|(r<<16)|(g<<8)|(b));
}

//--------

function Separator(x) {
this.left = x;

this.draw = function (gr) {
gr.FillGradRect(this.left-1,0, 1, wh-1, 90, RGB(133,133,133), RGB(0,0,0));
gr.FillGradRect(this.left,0, 1, wh-1, 90, RGB(163,163,163), RGB(163,163,163));
gr.FillGradRect(this.left+1,0, 1, wh-1, 90, RGB(60,59,59), RGB(0,0,0));
}
}

function separatorsDraw(gr) {
for (i in Separators) {
Separators[i].draw(gr);
}
}

//--------

function TimeFmt(t){
var zpad = function(n){
var str = n.toString();
return (str.length<2) ? "0"+str : str;
}

var h = Math.floor(t/3600); t-=h*3600;
var m = Math.floor(t/60); t-=m*60;
var s = Math.floor(t);
if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
return m.toString()+":"+zpad(s);
}

// --- APPLICATION START

function on_paint(gr){
var pos = 0;
var length = fb.PlaybackLength;
var txt;

if(length > 0){
if(g_drag){
pos = area * g_drag_seek;
txt = "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt(length);
}
else{
pos = area * (fb.PlaybackTime / length);  
var g_titlefmt = fb.TitleFormat("[%album artist% - ][%album% ]['['%date%']' - ]%title% >> $div($mul(100,%playback_time_seconds%),%length_seconds%) '%'");
txt = g_titlefmt.Eval();
}
}

gr.FillGradRect(4, 0, area, wh/2, 270, RGB(90, 90, 90), RGB(0, 0, 0));
gr.FillGradRect(4, wh/2, area, wh/2, 90, RGB(90, 90, 90), RGB(0, 0, 0));
gr.FillGradRect(0, 0, pos, wh/2, 270, RGB(0, 200, 200), RGB(0, 0, 0));
gr.FillGradRect(0,wh/2, pos, wh/2, 90, RGB(0, 200, 200), RGB(0, 0, 0));

gr.FillGradRect(2, 0, 1, wh-1, 90, RGB(163, 163, 163), RGB(163, 163, 163));
gr.FillGradRect(3, 0, 1, wh-1, 90, RGB(60, 59, 59), RGB(0, 0, 0));

separatorsDraw(gr);

gr.FillGradRect(ww-4, 0, 1, wh-1, 90, RGB(133, 133, 133), RGB(0, 0, 0));
gr.FillGradRect(ww-3, 0, 1, wh-1, 90, RGB(163, 163, 163), RGB(163, 163, 163));

gr.DrawRect(0, 0, ww, wh, 4.0, RGB(0,0,0));

gr.GdiDrawText(txt, g_font, RGB(255, 255, 255), 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);

var tfo_rating_a = fb.Titleformat("$if(%rating%,$repeat($char(9733),%rating%),)");
var tfo_rating_b = fb.Titleformat("$if(%rating%,$repeat($char(9734),$sub(5,%rating%)),)");
var txt_rating_a = tfo_rating_a.Eval();
var txt_rating_b = tfo_rating_b.Eval();

gr.GdiDrawText(txt_rating_a, g_font_rating, RGB(0,255,0), ww-120, 0, 110, wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
gr.GdiDrawText(txt_rating_b, g_font_rating, RGB(255,0,0), ww-120, 0, 105, wh, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
}

function on_size(){
ww = window.Width;
wh = window.Height;
area = ww - 4;

Separators = {
one: new Separator((ww-4)/10),
two: new Separator((ww-4)/5),
three: new Separator(3*(ww-4)/10),
four: new Separator(2*(ww-4)/5),
five: new Separator(ww/2),
six: new Separator(3*(ww-4)/5),
seven: new Separator(7*(ww-4)/10),
eight: new Separator(4*(ww-4)/5),
nine: new Separator(9*(ww-4)/10)
}
}

function on_mouse_lbtn_down(x,y){
g_drag = 1;
}

function on_mouse_lbtn_up(x,y){
if(g_drag){
g_drag = 0;
g_drag_seek = x / area;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
}
}

function on_mouse_move(x,y){
if(g_drag){
g_drag_seek = x / area;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
window.Repaint();
}
}

function on_playback_new_track(metadb){
window.Repaint();
}

function on_playback_stop(){
window.Repaint();
}

function on_playback_seek(time){
window.Repaint();
}

function on_playback_time(time){
window.Repaint();
}

// --- APPLICATION END

Couldn't this script be modified to work on f2k v2 32/64bit with JScript Panel. I just don't know enough about it myself.
Picture see attachment.

 

Re: Another Seekbar for JScript Panel

Reply #1
After some tests i found that foo_uie_wsh_panel_mod 1.5.10 also works in v2 32bit DUI. I haven't tried it in v2 64 bit yet.

The script (see above) can be copied into the panel and the seekbar will work. (see attachment above)