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: WSH Panel Mod script discussion/help (Read 1376406 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod script discussion/help

Reply #1476
Hi there,

I've written a script which displays a vertical volume bar with a tooltip showing the volume (based on "Simple Seekbar" by marc2003 and "Volbar with GdiDrawText" by T.P. Wang). The code is below if anyone is interested 

Code: [Select]
// ==PREPROCESSOR==
// @name "Volume-bar with tooltip"
// @author "rawny"
// ==/PREPROCESSOR==

// Based somewhat on:
// -> "Volbar with GdiDrawText" by T.P Wang
// -> "Simple Seekbar" by marc2003

var a = 25;
var g_drag = 0;
var g_drag_seek = 0;
var g_tooltip = window.CreateTooltip();
var g_trackingMouse = false;
var old_x;
var old_y;

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 on_size() {
    ww = window.Width;
    wh = window.Height;
}

function on_paint(gr){
    var ww = window.Width;
    var wh = window.Height;
    var pos = 0;
    var volume = fb.Volume;
    if(g_drag){
        pos = wh * g_drag_seek;
    }else{
        pos = wh * Math.exp(fb.Volume/a);
    }
    gr.FillGradRect(0, wh-pos, ww, wh, 90, RGB(0,0,255), RGB(70,90,200));
    gr.FillGradRect(0, 0, ww, wh-pos, 90, RGB(0,0,0), RGB(50,50,50));
    gr.DrawRect(0,0, ww-1, wh-1, 1.0, RGB(100,100,100));
}

function on_mouse_move(x,y){
    g_drag_seek = 1-y/wh;
    g_drag_seek = (g_drag_seek<Math.exp(-100/a)) ? Math.exp(-100/a) : (g_drag_seek<1) ? g_drag_seek : 1;
    if(x > ww){
        g_drag = 0;
    }
    if(g_drag){
        window.Repaint();
    }
    if(!g_trackingMouse){
        g_tooltip.Activate();
        g_tooltip.TrackActivate = true;
        g_trackingMouse = true;
    }
    if(x != old_x || y != old_y){
        txt = Math.ceil(a*Math.log(g_drag_seek))+"dB ("+Math.ceil(g_drag_seek*100)+"%)";
        g_tooltip.Text = txt;
        g_tooltip.TrackPosition(x,y-20);
        old_x = x;
        old_y = y;
    }
}

function on_mouse_leave(){
    g_trackingMouse = false;
    g_tooltip.TrackActivate = false;
}

function on_mouse_lbtn_down(x,y){
    g_drag = 1;
}
function on_mouse_lbtn_up(x,y){
    if(!g_drag){
        return;
    }
    g_drag = 0;
    var v = 1-y/wh;
    v = (v<Math.exp(-100/a)) ? Math.exp(-100/a) : (v<1) ? v : 1;
    fb.Volume = a*Math.log(v);
}
function on_mouse_wheel(delta){
    if(delta>0){
        fb.VolumeUp();
    }else{
        fb.VolumeDown();
    }
}

function on_volume_change(val){
    window.Repaint();
}

WSH Panel Mod script discussion/help

Reply #1477
Also, does anyone know how to produce glowing text with GdiDrawText?

As in this sample (but with GdiDrawText):
Code: [Select]
// ==PREPROCESSOR==
// @name "Glow Text Sample"
// @author "T.P Wang"
// ==/PREPROCESSOR==

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));
}

var g_font = gdi.Font("Segoe UI", 22, 1);
var g_drag = false;
var g_textrender = gdi.CreateStyleTextRender();
var g_bkclr = RGB(0, 0, 0);

function on_paint(gr) {
    gr.SetTextRenderingHint(5);
    gr.SetSmoothingMode(4);
    gr.SetInterpolationMode(7);

    var ww = window.Width;
    var wh = window.Height;

    // Draw background first
    gr.FillSolidRect(0, 0, ww, wh, g_bkclr);

    g_textrender.GlowText(RGB(0, 0, 64), RGBA(255, 255, 0, 30), 12);

    // Clear previous shadow setting
    g_textrender.EnableShadow(true);
    g_textrender.ResetShadow();

    g_textrender.RenderStringRect(gr, "Glow Text Sample", g_font, 0, 0, ww, wh, 0x11005000);
}
My current poor-man's version is to draw multiple copies of the text in the glow colour underneath the actual text:
Code: [Select]
// ==PREPROCESSOR==
// @name "Poor-man's glowing Gdi text"
// @author "rawny"
// ==/PREPROCESSOR==

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));
}

var text = "foobar2000";

var textFont = gdi.Font("Tahoma", 50, 1);

var textX = 100;
var textY = 100;

var glowSpacing = 4;

var rightGlowTextX = textX+glowSpacing;
var rightGlowTextY = textY+glowSpacing;

var actualTextX = textX+(glowSpacing/2);
var actualTextY = textY+(glowSpacing/2);

var bgColour = RGB(0,0,0);
var glowColour = RGBA(0, 0, 255, 222);
var textColour = RGBA(255, 255, 255, 222);

function on_size() {
    ww = window.Width;
    wh = window.Height;
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, bgColour);
    gr.GdiDrawText(text, textFont, glowColour, textX, textY, ww, wh);
    gr.GdiDrawText(text, textFont, glowColour, textX, rightGlowTextY, ww, wh);
    gr.GdiDrawText(text, textFont, glowColour, rightGlowTextX, textY, ww, wh);
    gr.GdiDrawText(text, textFont, glowColour, rightGlowTextX, rightGlowTextY, ww, wh);
    gr.GdiDrawText(text, textFont, textColour, actualTextX, actualTextY, ww, wh);
}
I'm fairly happy with this effect, but I was wondering if there was a way to do it properly?

WSH Panel Mod script discussion/help

Reply #1478
WSH Playlist Viewer v2 beta 5 : http://pastebin.com/u/Br3tt

example of use in a CUI config (opacity set to 0 in Properties of the panel in order to see the background which is a PanelStack Splitter that display the artist image of the current track)

WSH Panel Mod script discussion/help

Reply #1479
Playlist Viewer Beta 5. I would like to have a 1 line group header. This is what I get -

Streaming Radio - Streaming | undefinedundefined

FLAC Files - Artist | undefinedundefined

Is this how it should be? Beautiful playlist. Thank you.

WSH Panel Mod script discussion/help

Reply #1480
Playlist Viewer Beta 5. I would like to have a 1 line group header. This is what I get -

Streaming Radio - Streaming | undefinedundefined

FLAC Files - Artist | undefinedundefined

Is this how it should be? Beautiful playlist. Thank you.


nope, a small bug, sorry  will be fixed in next beta

WSH Panel Mod script discussion/help

Reply #1481
Playlist Viewer Beta 6. Group header bug fixed, thank you. In the Appearance settings I have turned off the light shadow border. But there is still a shadow border after last item in playlist. Is it possible to turn that off also? Thank you.

WSH Panel Mod script discussion/help

Reply #1482
Playlist Viewer Beta 6. Group header bug fixed, thank you. In the Appearance settings I have turned off the light shadow border. But there is still a shadow border after last item in playlist. Is it possible to turn that off also? Thank you.


no. but you can edit the script to fit your needs, just remove the lines of code that draw this shadow (near line 622)

Code: [Select]
            if (this.id == list.total - 1) {
                gr.FillSolidRect(this.x, this.y + this.h + 0, this.w - vscrollbar.w, 1, RGBA(0, 0, 0, 75));
                gr.FillSolidRect(this.x, this.y + this.h + 1, this.w - vscrollbar.w, 1, RGBA(0, 0, 0, 35));
                gr.FillSolidRect(this.x, this.y + this.h + 2, this.w - vscrollbar.w, 1, RGBA(0, 0, 0, 12))
            };

 

WSH Panel Mod script discussion/help

Reply #1483
Thank you, that worked perfectly. Excellent playlist.

WSH Panel Mod script discussion/help

Reply #1484
Whenever I try to sort either by Album or Artist using Playlistviewer Beta 6 it keeps crashing, this is what's coming up in the console:

Code: [Select]
Error: WSH Panel Mod (WSH Playlist Viewer v2 beta 6 v0.0.6.20120423.2349 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): Microsoft JScript runtime error:
Object doesn't support property or method 'SortByFormat'
File: <main>
Ln: 3482, Col: 3
<source text only available at compile time>





WSH Panel Mod script discussion/help

Reply #1489
Falstaff, i get an error at startup (with a filled autoplaylist selected):


Code: [Select]
Foobar2000 v1.1.11 + Windows Scripting Host Panel Modded v1.5.3.1 (Build: 19:48:41, Apr 20 2012)
W7x64

Console:
Error: WSH Panel Mod (WSH Playlist Viewer v2 beta 6 v0.0.6.20120423.2349 by Br3tt aka Falstaff >> [url=http://br3tt.deviantart.com):]http://br3tt.deviantart.com):[/url]
Microsoft JScript runtime error:
Object doesn't support this property or method
File: <main>
Ln: 541, Col: 4
<source text only available at compile time>

something goin' wrong at:
if (typeof this.id == "undefined") {
if (this.metadb) {
541 this.group_key = tf_group_key.EvalWithMetadb(this.metadb);


But after that is seems to run ok.

WSH Panel Mod script discussion/help

Reply #1490
thanx Mod-Ular, it has already be reported to me (same bug), it should be fixed for the next beta

WSH Panel Mod script discussion/help

Reply #1491
WSH Playlist Viewer v2 beta 7 : http://pastebin.com/u/Br3tt

- bug on launch (for who's encountered it) fixed (i hope, tell me about it)
- queue info added for queued tracks + special "Queue content playlist" added to see the queued tracks as a special playlist (check settings menu from the toolbar)

WSH Panel Mod script discussion/help

Reply #1492
Code: [Select]
Error: WSH Panel Mod (WSH Playlist Viewer v2 beta 7 v0.0.7.20120424.2339 by Br3tt aka Falstaff >> [url=http://br3tt.deviantart.com):]http://br3tt.deviantart.com):[/url] Microsoft JScript runtime error:
'list.item[...].id' is null or not an object
File: <main>
Ln: 1814, Col: 3
<source text only available at compile time>

Still getting an error..  .


WSH Panel Mod script discussion/help

Reply #1494
Code: [Select]
Error: WSH Panel Mod (WSH Playlist Viewer v2 beta 7 v0.0.7.20120424.2339 by Br3tt aka Falstaff >> [url=http://br3tt.deviantart.com):]http://br3tt.deviantart.com):[/url] Microsoft JScript runtime error:
'list.item[...].id' is null or not an object
File: <main>
Ln: 1814, Col: 3
<source text only available at compile time>

Still getting an error..  .

yep, but not the same

could you gimme more info on how it happens ? (playlist content (large, small number of items), action you where doing, ... all that could help me because i can't reproduce this bug, thanx)

WSH Panel Mod script discussion/help

Reply #1495
Fallstaff,
In my case the script only fails at fb2k startup. (with a huge Media Library, not tested otherwise)

Medium sized Autoplaylists containing 75-125Gig and 5,000-7500 items.
Everything autosorted by %path_sort%

I see u added queueing functions. Maybe worthwhile to mention the related components i use?
foo_keep_queue: Keep Queue 0.3.5 (by Andreas "Qtax" Zetterlund, Prevents the playback queue from being removed when changing song manually or exiting)
foo_queuecontents: Queue Contents Editor 0.5.1 (by Sami Salonen)

Good luck bug-hunting

WSH Panel Mod script discussion/help

Reply #1496
@Mod-Ular

thanx for the reply, i've tried both (foo_queuecontents and foo_keep_queue) but i can't make it crashes ...

have you installed the last version of WSH panel mod at least? v1.5.3.1 ?

have you try to clear the panel Properties ?

WSH Panel Mod script discussion/help

Reply #1497
Yes, Windows Scripting Host Panel Modded v1.5.3.1 (Build: 19:48:41, Apr 20 2012)

I've reset the properties. (I only adjusted a few settings in the USER-fields.)
But i'm getting the same error at Foobar Startup as mentioned above.

In console i see the script initialising without problems:
WSH Panel Mod (WSH Playlist Viewer v2 beta 7 v0.0.7.20120424.2339 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): initialized in 10 ms

After console shows startup time (everything is loaded), it crashes:
Startup time : 0:37.911965
Error: WSH Panel Mod (WSH Playlist Viewer v2 beta 7 v0.0.7.20120424.2339 by Br3tt aka Falstaff >> http://br3tt.deviantart.com): Microsoft JScript runtime error:
'list.item[...].id' is null or not an object
File: <main> Ln: 1814, Col: 3 <source text only available at compile time>


WSH Panel Mod script discussion/help

Reply #1499
Fallstaff,  I cannot open that zip-archive. Downloaded it 3 times but it seems to be corrupted...