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 1375560 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #2150
Wow, thank you man
Now it is exactly what i need.

WSH Panel Mod script discussion/help

Reply #2151
i've updated my sample scripts. this applies to my artreader, cd jewel case and now playing (all variants). until now i've always chosen to prefer embedded art first and fall back on the display preferences if nothing is found. i've never given people the choice before. but i've just been fumbling around in the foobar preferences and see it's now an option which the user can set.

file>preferences>advanced>display>album art

i don't know when that setting was implemented but my scripts now respect the choice made there.

use Update script on the right click menu or the full download is here: https://dl.dropbox.com/u/22801321/samples.zip

files changed:
Code: [Select]
marc2003\common6.js

WSH Panel Mod script discussion/help

Reply #2152
@marc2003

Inspired by something you wrote in another thread I've just begun using your Simple Text Reader, loading title reviews manually scraped from Rovi.
It's indeed a boring pursuit copying and pasting all day long from now and probably until kingdom come, but I've given up the hope that you or romor or someone else will ever write a script performing the task...
Problem is, that in my opinion the text is too small; the normal_font is o.k. in lists and so on, but used in body text on a 1920x1080 monitor it's not an easy reading font size.
It's pure flagellation if I try to make changes in the huge Common6.js – not to mention that it's frequently updated, and it's probably only necessary to have the choice of selecting larger font sizes in text heavy panels such as the Simple Text Reader and e.g. your Last.fm Biography mod script.
I found an old Simple Text Reader and common4.js in my archives and edited the latter to use

Code: [Select]
normal_font = 14

(instead of 12) and

Code: [Select]
row_height = 1.2 * normal_font.Height

(row_height being leading/line spacing), that helped my old eyes a lot.
It would however be much more elegant if you implemented some sort of font (size) handling in the context menus, if it's doable with the WSH Panel mod without to much hassle?
Your collection of scripts is highly valued and appreciated, I use 6-7 of them in my DUI layout!

WSH Panel Mod script discussion/help

Reply #2153
a perfectly reasonable request. i'll probably get that done tonight sometime.

edit: just had a quick bash at it now. click

i just need to test it doesn't break anything else before i put it online.


WSH Panel Mod script discussion/help

Reply #2155
^ok, done. just use Update script from the right click menu.

it will apply to last.fm bio mod, now playing with last.fm bio mod, simple text reader, and simple tag reader.

the scripts in the panels haven't changed - just using the update feature above updates the common file they all share.

WSH Panel Mod script discussion/help

Reply #2156
... the update is exactly what I had in mind. Simple Text Reader and the last.fm bio mod look perfect.
I'll stick to '14' for now and maybe begin using '16' in a couple of years . The leading is fine too. (normally a factor 1.1 to 1.2 is used in type setting.)
marc2003, you earn 5 stars for service and support. And speed!


WSH Panel Mod script discussion/help

Reply #2157
if you need it any of my "list" scripts like last.fm similar artists, charts, musicbrainz, discogs, etc then give me a shout and i can probably work it in.

WSH Panel Mod script discussion/help

Reply #2158
marc2003

your vinyl turntable script has decided to crash unexpectedly.
I started foobar2000 and selected a playlist, then played a track (whose folder contains a "disc.jpg") which has previously worked fine with your script . . . . not this time!

Here is the console output:
Quote
. . .
Opening track for playback: "F:\music\lib\rhythm\curtis mayfield\(1972) superfly\vinyl - buddah records, usa, original pressing\02. pusherman.flac"
Error: WSH Panel Mod ({40845811-E334-4CB0-B4C5-DE5B1B33E36F}): Microsoft JScript runtime error:
'images[...]' is null or not an object
File: <main>
Ln: 94, Col: 3
<source text only available at compile time>
. . .


Here is line 94 (red) in my script:
Quote
function calc() {
    if (!img) return;
    for (i = 0; i < images.length; i++) {
        try { images.Dispose(); } catch(e) {}
    }
    images = [];
    for (i = 0; i < 36; i ++) {
        images = gdi.CreateImage(nw,  nh);
        var temp_gr = images.GetGraphics();
        temp_gr.SetInterpolationMode(6);
        temp_gr.DrawImage(bg, 0, 0, nw, nh, 0, 0, bg.width, bg.height);
        temp_gr.DrawImage(img, disc_x, disc_y, disc_size, disc_size, 0, 0, img.Width, img.Height, i * 10);
        images.ReleaseGraphics(temp_gr);
        temp_gr = null;
    }
}


I right-clicked the crashed panel, went to the "WSH Panel Mod Configuration" window, clicked the "Apply" button . . . . . and the panel started working again!
Can you make sense of the reasons for the crash?


*EDIT*

In the past, I remember having another WSH image viewing panel which decided to crash one day with the "null image" report at the console.

Here is the original lines in that script . . . which would occasionally crash:

        if (Properties.Image.Sort == ImageSort.Shuffle)
            NewItems = NewItems.sort(function(){return (Math.random() > 0.5) ? -1 : 1;});   
        return NewItems;


I fixed the problem by adding the line in red . . . the panel never crashed again after this edit:

        if (Properties.Image.Sort == ImageSort.Shuffle)
            NewItems = NewItems.sort(function(){return (Math.random() > 0.5) ? -1 : 1;});
        CollectGarbage();   
        return NewItems;

WSH Panel Mod script discussion/help

Reply #2159
not got a clue. if you can make it fail in a way that i can reproduce reliably then it's worth looking at but otherwise....

edit: you can try replacing the for loop with this. it might give me something useful in the console if it happens again..

Code: [Select]
    try {
        for (i = 0; i < 36; i ++) {
            images[i] = gdi.CreateImage(nw,  nh);
            var temp_gr = images[i].GetGraphics();
            temp_gr.SetInterpolationMode(6);
            temp_gr.DrawImage(bg, 0, 0, nw, nh, 0, 0, bg.width, bg.height);
            temp_gr.DrawImage(img, disc_x, disc_y, disc_size, disc_size, 0, 0, img.Width, img.Height, i * 10);
            images[i].ReleaseGraphics(temp_gr);
            temp_gr = null;
        }
    } catch(e) {
        fb.trace("image:" + i);
        fb.trace("nw: " + nw);
        fb.trace("nh: " + nh);
        fb.trace(typeof images[i]);
        fb.trace("width: " + images[i].Width);
        fb.trace("height: " + images[i].Height);
    }


incidentally, this is the bit of code that causes the UI lag on album change. the original script overlaid one image on top of another every 50ms and this caused the silly CPU usage. my idea was to create a slide show but to do that i need to create 36 "flattened" images of these 2 layers first. so i draw the background and then the disc art on top rotated a bit each time. once i've done that, and i have an array of 36 images to loop through, there is no CPU usage at all.

WSH Panel Mod script discussion/help

Reply #2160
If I was to insert CollectGarbage(); inside the function calc() field, can you tell me after which line it would be added, thanks.

*EDIT*

Thanks for your edit

WSH Panel Mod script discussion/help

Reply #2161
it has nothing to do with that at all.

WSH Panel Mod script discussion/help

Reply #2162
Hey guys I am new to writing code in the wsh panel for foobar but am trying to learn, in the meantime I am using eXtremeHunter's code to display a rotating image of a vinyl:

Code: [Select]
// ================================================== //
// @name "Spinning Disc Image Viewer  (Jan 24, 2013)"
// @author "eXtremeHunter"
// ================================================== //
function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}
window.DlgCode = 0x0001; // arrow keys for DUI

var defaultDisc = gdi.Image(fb.FoobarPath + "images\\record2.png");
var margin = window.GetProperty("Margin", 50);
var zoomStep = window.GetProperty("Zoom Step", 30);
var useDiscMask = window.GetProperty("Use Disc Mask", true);

var angle = 0;
var minSize = 20;
var disc = defaultDisc;
var rotationInterval = 50;
var rotationTimer;
var rotationTimerStarted = false;
// ============================== //
function on_paint(gr) {

    gr.FillGradRect(0, 0, ww, wh, 65, RGB(0, 0, 0), RGB(0, 0, 0), 0.5);

    disc && gr.DrawImage(resizedDisc, discX, discY, discW, discH, 0, 0, resizedDisc.Width, resizedDisc.Height, angle);

}
// ============================== //
function on_mouse_wheel(step) {

    if (utils.IsKeyPressed(16)) {

        if (step == -1 && discW <= minSize) return;

        var s = step * zoomStep;
        margin = margin -= s;
        window.SetProperty("Margin", margin);
        on_size();

        window.Repaint();

    }

}
// ============================== //
function on_key_down(vkey) {

    if (vkey == 38) on_mouse_wheel(1) //UP ARROW
    if (vkey == 40) on_mouse_wheel(-1); //DOWN ARROW

}
// ============================== //
function on_size() {

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

    discW = Math.max(minSize, ww - margin);
    discH = Math.max(minSize, wh - margin);

//    if (discH < discW) discW = discH;
  //  else if (discW < discH) discH = discW;

    discX = ww / 2 - discW / 2;
    discY = wh / 2 - discH / 2;

    resizedDisc = disc.resize(discW, discH);

    if (useDiscMask) {

        var discMask = gdi.CreateImage(discW, discH);
        var g = discMask.GetGraphics();
        g.FillSolidRect(0, 0, discW, discH, 0xffffffff);
        g.SetSmoothingMode(2);
        g.FillEllipse(1, 1, discW - 2, discH - 2, 0xff000000);
        discMask.ReleaseGraphics(g);
        resizedDisc.ApplyMask(discMask);
        discMask.Dispose();

    }

}
// ============================== //
(function onRotationTimer() {

    getDiscImage();

    if (!fb.IsPlaying || fb.IsPaused) {
        return;
    }

    if (!rotationTimerStarted) {

        rotationTimer = window.SetInterval(function () {

            if (angle >= 360) angle = 0;
            angle += 10;
            (discW >= ww || discH >= wh) ? window.Repaint() : window.RepaintRect(discX, discY, discW, discH);

        }, rotationInterval);

        rotationTimerStarted = true;
    }

})();
// ============================== //
function stopRotationTimer() {

    window.ClearInterval(rotationTimer);
    rotationTimerStarted = false;

}
// ============================== //
function on_playback_stop(reason) {

    if (reason != 2) {
        stopRotationTimer();
        getDiscImage();
    }
}
// ============================== //
function on_playback_pause(state) {

    state ? stopRotationTimer() : onRotationTimer();

}
// ============================== //
function on_playback_new_track() {

    onRotationTimer();

}
// ============================== //
var tempAlbum;

function getDiscImage() {

    if (!plman.PlaylistItemCount(plman.ActivePlaylist)) return;

    var nowPlayingDisc;

    var metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
   
    if(!metadb) return;

    var currentAlbum = fb.TitleFormat("%album%").EvalWithMetadb(metadb);

    if (currentAlbum == tempAlbum) return;

        nowPlayingDisc = utils.GetAlbumArtV2(metadb, 2);

        nowPlayingDisc ? disc = nowPlayingDisc : disc = defaultDisc;

        tempAlbum = currentAlbum;

    on_size();
    window.Repaint();

}
// ============================== //
function on_selection_changed(metadb) {
    if (!fb.IsPlaying) getDiscImage();
}
// ============================== //
function on_playlist_items_removed() {

    if (!plman.PlaylistItemCount(plman.ActivePlaylist)) disc = defaultDisc;
    on_size();
    window.Repaint();

}

The code works fine except I want to make one small tweak and I am unsure of how to implement it into the code. Essentially I want the image to to be resized AFTER it is rotated. I want the circular vinyl to be resized to an ellipse before every iteration of the rotation so that the vinyl appears as if it was being viewed from the side and above, with its axis of rotation being neither parallel nor perpendicular (as it is displayed currently) to the monitor. I realize it may be difficult to understand what I want and so I can better clarify if needed. Any help will be greatly appreciated.

WSH Panel Mod script discussion/help

Reply #2163
^i have no idea how to implment that.

samples updated. right click>Update script or the full download is here: https://dl.dropbox.com/u/22801321/samples.zip

musicbrainz.
when in links mode, unescape characters before displaying them to make it look nicer.

also added checking for musicbrainz artist id. this is what picard writes to mp3s but i only checked for musicbrainz_artistid previously because that is what foo_musicbrainz writes (and it's the standard for vorbis/apev2). it's not compulsory to tag files with this info because the script will search based on artist name - but it will use the first entry it matches which may be wrong if there is more than artist with the same name.

artreader / cd jewel case
add Google image search to the context menu. having a large panel has made me realise not all my art is up to scratch. i prefer to find stuff manually rather than use programs to do it so i've added this item which opens your browser looking for artist/album. also added Refresh option for cd jewel case. artreader already had it. this just updates the panel if you've edited/replaced the image while a track is playing.

files changed:
Code: [Select]
marc2003\common6.js

WSH Panel Mod script discussion/help

Reply #2164
I am hoping you can help me Marc. I am completely new to foobar2000 and am using a pretty advanced theme not compiled by myself so I am certainly in over my head.

For some reason unbeknown to me the 'last.fm Charts' does not initialise/crashes. It used to work a few days ago but I have no real idea what I have done to change things.
The error from console is as follows:
Code: [Select]
Error: WSH Panel Mod (Last.fm Charts v6.2012-12-05.01 by marc2003): Microsoft JScript runtime error:
Object doesn't support this property or method
File: <main>
Ln: 15, Col: 1
<source text only available at compile time>
I downloaded your newest 'samples' folder linked above and tried replacing the common6 file but it made no difference.
I am not sure if this is even releant but this is the code I get when I select 'configure'.
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common6.js"
// @name "Last.fm Charts"
// @author "marc2003"
// @version "6.2012-12-05.01"
// ==/PREPROCESSOR==

var p = new panel("Last.fm Charts", ["lastfm_charts"]);
var l = new lastfm();
var li = new list(6, 30, p.w - 12, p.h - 30);
var b = new buttons();

b.buttons.but1 = new button(p.w - 56, 8, 50, 18, {normal: "lastfm_red_small.gif"}, function() { p.browser(l.url); }, l.url);

li.lastfm_charts_load();

function on_notify_data(name, data) {
l.notify_data(name, data);
}

function on_size() {
p.size();
b.buttons.but1.x = p.w - 56;
li.w = p.w - 12;
li.h = p.h - 30;
li.size();
}

function on_paint(gr) {
p.draw_background(gr);
p.header(gr, l.username + ": " + li.lastfm_charts_periods_display[li.lastfm_charts_period] + " " + li.lastfm_charts_types[li.lastfm_charts_type] + " charts");
b.draw(gr);
switch(true) {
case l.username.length == 0:
p.centre_text(gr, l.username_error, p.normal_font, p.textcolour, 0, 0, p.w, p.h);
break;
case li.items > 0:
li.draw(gr);
break;
default:
p.centre_text(gr, "[nothing found]", p.normal_font, p.textcolour, 0, 0, p.w, p.h);
break;
}
}

function on_mouse_wheel(step) {
li.wheel(step);
}

function on_mouse_move(x, y) {
p.move(x, y);
if (b.move(x, y)) return;
if (li.move(x, y)) return;
}

function on_mouse_lbtn_up(x, y) {
if (b.lbtn_up(x, y)) return;
if (li.lbtn_up(x, y)) return;
}

function on_mouse_rbtn_up(x, y) {
p.rbtn_up(x, y);
return true;
}
Any guidance would be truly appreciated. Please remember that I have no idea what I am doing. Cheers.

WSH Panel Mod script discussion/help

Reply #2165
just update the charts script in the panel. an updated common6.js broke it back in january. obviously it kept working until now because you didn't update yours.

http://www.hydrogenaudio.org/forums/index....mp;#entry821841

you can always check the latest panel versions here: https://dl.dropbox.com/u/22801321/wsh/versions.txt

i try not to change panel scripts often but sometimes it is unavoidable. most of the constant work/updating goes on in the main common6.js file.

WSH Panel Mod script discussion/help

Reply #2166
i've updated my last.fm bio mod script. it has now been renamed to last.fm & wikipedia biography. i think from the rename alone, you can tell what it does. i've just added a context menu item allowing you to switch between the two.



https://dl.dropbox.com/u/22801321/samples.zip

some other minor changes too.

new / changed files:
Code: [Select]
marc2003\common6.js
samples\last.fm & wikipedia biography.txt
samples\now playing with track list.txt
samples\now playing with last.fm & wikipedia biography.txt
samples\now playing.txt

WSH Panel Mod script discussion/help

Reply #2167
Thanks Marc updating the script fixed it for me. Now that I have the functionality to update the script from within foobar2000 I suspect I will have fairly smooth sailing from here!

WSH Panel Mod script discussion/help

Reply #2168
^just incase it wasn't clear, using Update script can only update the common file and not what is in the panel. there is still potential for problems if i change things in the future but i hope not.  the general rule of thumb is that if you have files from the same zip, you won't go far wrong.


WSH Panel Mod script discussion/help

Reply #2169
i've updated my thumbs script. it now has options to align thumbs along the top and to the right of the panel - in addition to left and bottom that it had previously.

also, you can now turn thumbs off completely which makes my simple image viewer script redundant. support for that has been dropped.



use right click>Update script or the full download is here: https://dl.dropbox.com/u/22801321/samples.zip

files changed:
Code: [Select]
marc2003\common6.js
samples\simple image viewer.txt <<removed

WSH Panel Mod script discussion/help

Reply #2170
I have a problem with this script in my config:
Code: [Select]
// ==PREPROCESSOR==
// @name "DarkOne Display Panel"
// @version "4.0"
// @author "super-gau and tedGo, includes partial codes by fbuser, Br3tt and T.P Wang"
// @import "%fb2k_path%themes\DarkOne_v4.0\Others\WSH Scripts\DO 4.0 Global Script.js"
// ==/PREPROCESSOR==

// ----- VARIABLES -----
var g_timer = v_timer = g_alpha = s_alpha = p_alpha = null;
var g_interval, fileinfo, g_trackinfo;
var v_change = false;

var t_rem = window.GetProperty("Remain Time on", false);

// ----- COLOURS -----
var d_arr = new Array("Default", "Blue", "Green", "Red", "White", "Yellow");
var c_arr = new Array(RGB(191, 228, 255), RGB(128, 192, 255), RGB(0, 255, 0), RGB(255, 0, 0), RGB(255, 255, 255), RGB(255, 255, 0));

function InitColours() {
d_col = window.GetProperty("Display Colour", 0);
g_dcol = d_arr[d_col];
g_acol = c_arr[d_col];
g_fact = g_acol == -65536 ? 0.09 : 0.03;
g_bcol = combColours(ui_backcol, g_acol, g_fact);
}

InitColours();

// ----- CREATE HELPERS -----
String.prototype.repeat = function(n) {
return (new Array(n + 1)).join(this);
}

function pad(x, y, z) {
z || (z = ' ');
return x.length < y ? x + z.repeat(y - x.length) : x;
}

function pad_right(x, y, z) {
z || (z = ' ');
return x.length < y ? z.repeat(y - x.length) + x : x
}

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

return zpad(h) + ":" + zpad(m) + ":" + zpad(s);
}

function drawSquares(gr, squareSize, paddingSize, x, y, w, h) {
var stepSize = squareSize + paddingSize;
var totalsq = Math.ceil(w / stepSize);
var totalrow = Math.ceil(h / stepSize);

for(var j = 0; j < totalrow; j++) {
for(var i = 0; i < totalsq; i++) {
gr.FillSolidRect(i * stepSize + x, j * stepSize + y, squareSize, squareSize, g_bcol);
}
}
}

// ----- CREATE INFO -----
Info.prototype.setColours = function() {
var metadb = fb.GetNowPlaying();

if (metadb) {
fileinfo = metadb.GetFileInfo();
this.Colours[0] = fileinfo.InfoValue(fileinfo.InfoFind("encoding")) == "lossless" ? g_acol : g_bcol;
this.Colours[1] = fileinfo.InfoValue(fileinfo.InfoFind("encoding")) == "lossless" ? g_bcol : g_acol;
this.Colours[2] = fileinfo.InfoValue(fileinfo.InfoFind("md5")) ? g_acol : g_bcol;
this.Colours[3] = fb.TitleFormat("[%replaygain_track_gain%]").Eval() ? g_acol : g_bcol;
this.Colours[4] = fileinfo.MetaValue(fileinfo.MetaFind("tracknumber"), 0) ? ui_btntxtcol : g_bcol;
this.Colours[5] = fileinfo.MetaValue(fileinfo.MetaFind("totaltracks"), 0) ? ui_btntxtcol : g_bcol;
this.Colours[6] = ui_btntxtcol;
} else for (var i = 0; i < this.Colours.length; i++) this.Colours[i] = g_bcol;
}

Info.prototype.setTrackNo = function() {
var metadb = fb.GetNowPlaying();
var a, b;

if (metadb) {
fileinfo = metadb.GetFileInfo();
var c = fileinfo.MetaValue(fileinfo.MetaFind("tracknumber"), 0);
var d = fileinfo.MetaValue(fileinfo.MetaFind("totaltracks"), 0);
var e = c ? pad_right(c, 2, "0") : "  ";
var f = d ? pad_right(d, 2, "0") : "  ";
a = pad(e, 3);
b = pad(f, 3);
this.TrackNo = a;
this.TotalNo = b;
g_trackinfo = fb.PlaybackLength <= 0 ? 2 : metadb.RawPath.indexOf("FOO_LASTFM") == 0 ? 1 : 0;
} else {
this.TrackNo = "";
this.TotalNo = "";
}
}

Info.prototype.setPBTime = function() {
this.Elapse = TimeFmt(fb.PlaybackTime);
this.Remain = fb.PlaybackLength <= 0 ? "" : TimeFmt(fb.PlaybackLength - fb.PlaybackTime);
}

Info.prototype.setBitrate = function() {
this.Bitrate = pad_right(fb.TitleFormat("%bitrate%").Eval(), 4);
}

Info.prototype.setInfo = function() {
this.setColours();
this.setTrackNo();
this.setPBTime();
this.setBitrate();
}

function Info() {
this.Colours = new Array(7);
this.setInfo();
}

info = new Info();

// ----- BASE IMAGE OBJECT -----
function BaseImage() {
this.image = null;
this.curVal  = "";

this.reset = function() {
this.curVal  = "";
}

this.dispose = function() {
this.image && this.image.Dispose();
}

this.isDrawDigit = function(digitValue, index) {
return (this.curVal == null || this.curVal == "" || digitValue != this.curVal.charAt(index));
}
}

// ----- CREATE TRACKNUMBER IMAGE -----
function NumImage() {
this.image = gdi.CreateImage(54, 20);

this.init = function(curNo) {
gr = this.image.GetGraphics();

this.drawDigit(curNo, 0);
this.drawDigit(curNo, 1);
this.drawDigit(curNo, 2);

this.curVal = curNo;

this.image.ReleaseGraphics(gr);
}

this.draw = function(curNo) {
this.init(curNo);
}

this.drawDigit = function(curNo, index) {
var digitValue = curNo.charAt(index);

if (this.isDrawDigit(digitValue, index)) {
var xoffset = index * 18;
gr.FillSolidRect(xoffset, 0, 18, 20, ui_backcol);
drawSquares(gr, 2, 1, xoffset, 0, 18, 20);
g_signs && gr.DrawImage(g_signs, xoffset, 0, 18, 20, digitValue == " " ? 216 : digitValue * 18, d_col * 22, 18, 20);
}
}
}

NumImage.prototype = new BaseImage();
var g_trackNoImage = new NumImage();
var g_totalNoImage = new NumImage();

// ----- CREATE TIME IMAGE -----
function TimeImage() {
this.image = gdi.CreateImage(120, 20);

this.init = function(time) {
gr = this.image.GetGraphics();

this.drawDigit(time, 0, 0);
this.drawDigit(time, 1, 0);

g_signs && gr.DrawImage(g_signs, 36, 0, 6, 20, 234, d_col * 22, 6, 20);

this.drawDigit(time, 3, -12);
this.drawDigit(time, 4, -12);

g_signs && gr.DrawImage(g_signs, 78, 0, 6, 20, 234, d_col * 22, 6, 20);

this.drawDigit(time, 6, -24);
this.drawDigit(time, 7, -24);

this.curVal = time;

this.image.ReleaseGraphics(gr);
}

this.draw = function(time) {
if (this.curVal == "") this.init(time);
else {
gr = this.image.GetGraphics();

this.drawDigit(time, 0, 0);
this.drawDigit(time, 1, 0);

this.drawDigit(time, 3, -12);
this.drawDigit(time, 4, -12);

this.drawDigit(time, 6, -24);
this.drawDigit(time, 7, -24);

this.curVal = time;

this.image.ReleaseGraphics(gr);
}
}

this.drawDigit = function(time, index, offset) {
var digitValue = time.charAt(index);

if (this.isDrawDigit(digitValue, index)) {
var xoffset = index * 18 + offset;
gr.FillSolidRect(xoffset, 0, 18, 20, ui_backcol);
drawSquares(gr, 2, 1, xoffset, 0, 18, 20);
g_signs && gr.DrawImage(g_signs, xoffset, 0, 18, 20, digitValue * 18, d_col * 22, 18, 20);
}
}
}

TimeImage.prototype = new BaseImage();
var g_timeImage = new TimeImage();

// ----- CREATE BITRATE IMAGE -----
function BitrateImage() {
this.image = gdi.CreateImage(72, 20);

this.init = function(bitrate) {
gr = this.image.GetGraphics();

this.drawDigit(bitrate, 0);
this.drawDigit(bitrate, 1);
this.drawDigit(bitrate, 2);
this.drawDigit(bitrate, 3);

this.curVal = bitrate;

this.image.ReleaseGraphics(gr);
}

this.draw = function(bitrate) {
this.init(bitrate);
}

this.drawDigit = function(bitrate, index) {
var digitValue = bitrate.charAt(index);

if (this.isDrawDigit(digitValue, index)) {
var xoffset = index * 18;
gr.FillSolidRect(xoffset, 0, 18, 20, ui_backcol);
drawSquares(gr, 2, 1, xoffset, 0, 18, 20);
g_signs && gr.DrawImage(g_signs, xoffset, 0, 18, 20, digitValue == " " ? 216 : digitValue * 18, d_col * 22, 18, 20);
}
}
}

BitrateImage.prototype = new BaseImage();
var g_bitrateImage = new BitrateImage();

// ----- CREATE VOLUME IMAGE -----
function VolumeImage() {
this.image = gdi.CreateImage(168, 20);

this.init = function(volume) {
gr = this.image.GetGraphics();

this.drawDigit(volume, 0, 0);
this.drawDigit(volume, 1, 0);
this.drawDigit(volume, 2, 0);
this.drawDigit(volume, 3, 0);

g_signs && gr.DrawImage(g_signs, 72, 0, 6, 20, 240, d_col * 22, 6, 20);

this.drawDigit(volume, 5, -12);
this.drawDigit(volume, 6, -12);

g_signs && gr.DrawImage(g_signs, 114, 0, 18, 20, 216, d_col * 22, 18, 20);
g_signs && gr.DrawImage(g_signs, 132, 0, 36, 20, 264, d_col * 22, 36, 20);

this.curVal = volume;

this.image.ReleaseGraphics(gr);
}

this.draw = function(volume) {
if (this.curVal == "") this.init(volume);
else {
gr = this.image.GetGraphics();

this.drawDigit(volume, 0, 0);
this.drawDigit(volume, 1, 0);
this.drawDigit(volume, 2, 0);
this.drawDigit(volume, 3, 0);

this.drawDigit(volume, 5, -12);
this.drawDigit(volume, 6, -12);

this.curVal = volume;

this.image.ReleaseGraphics(gr);
}
}

this.drawDigit = function(volume, index, offset) {
var digitValue = volume.charAt(index);

if (this.isDrawDigit(digitValue, index)) {
var xoffset = index * 18 + offset;
gr.FillSolidRect(xoffset, 0, 18, 20, ui_backcol);
drawSquares(gr, 2, 1, xoffset, 0, 18, 20);
g_signs && gr.DrawImage(g_signs, xoffset, 0, 18, 20, digitValue == " " ? 216 : digitValue == "-" ? 246 : digitValue * 18, d_col * 22, 18, 20);
}
}
}

VolumeImage.prototype = new BaseImage();
var g_volumeImage = new VolumeImage();

// ----- CREATE MENU -----
function CustomMenu(x, y) {
var a = window.CreatePopupMenu();
var idx;

for (var i = 0; i < d_arr.length; i++) {
a.AppendMenuItem(0, 1 + i, d_arr[i]);
}
a.CheckMenuRadioItem(1, 6, d_col + 1);

a.AppendMenuSeparator();
a.AppendMenuItem(0, 7, "Properties");
a.AppendMenuItem(0, 8, "Configure...");

idx = a.TrackPopupMenu(x, y);

switch (true) {
case (idx >= 1 && idx <= 6):
window.SetProperty("Display Colour", idx - 1);
InitColours();
info.setColours();
g_trackNoImage.reset();
g_totalNoImage.reset();
g_timeImage.reset();
g_bitrateImage.reset();
g_volumeImage.reset();
window.Repaint();
break;

case (idx == 7):
window.ShowProperties();
break;

case (idx == 8):
window.ShowConfigure();
break;
}

a.Dispose();
}

// ----- DRAW -----
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, ui_backcol);
drawSquares(gr, 2, 1, 0, 30, ww - 26, 20);

gr.DrawRect(1, 0, ww * 17 / 70, 10, 1, info.Colours[0]);
gr.DrawRect(ww * 71 / 280, 0, ww * 17 / 70, 10, 1, info.Colours[1]);
gr.DrawRect(ww * 141 / 280, 0, ww * 17 / 70, 10, 1, info.Colours[2]);
gr.DrawRect(ww * 211 / 280, 0, ww * 17 / 70, 10, 1, info.Colours[3]);

gr.GdiDrawText("LOSSLESS", btn_font, info.Colours[0], ww / 8 - 33, 0, 70, 10, 37);
gr.GdiDrawText("LOSSY", btn_font, info.Colours[1], ww / 8 * 3 - 34, 0, 70, 10, 37);
gr.GdiDrawText("AUDIO MD5", btn_font, info.Colours[2], ww / 8 * 5 - 34, 0, 70, 10, 37);
gr.GdiDrawText("REPLAYGAIN", btn_font, info.Colours[3], ww - ww / 8 - 33, 0, 70, 10, 37);

gr.GdiDrawText("TRACK", btn_font, info.Colours[4], 0, 18, 27, 10, 37);
gr.GdiDrawText("TOTAL", btn_font, info.Colours[5], 60, 18, 27, 10, 37);
gr.GdiDrawText("ELAPSED", btn_font, v_change || t_rem ? g_bcol : info.Colours[6], ww / 2 - 38, 18, 35, 10, 38);
gr.GdiDrawText("TIME", btn_font, v_change ? g_bcol : info.Colours[6], ww / 2 + 5, 18, 20, 10, 38);
gr.GdiDrawText("REMAINING", btn_font, v_change || !t_rem ? g_bcol : info.Colours[6], ww / 2 + 33, 18, 46, 10, 38);
gr.GdiDrawText("VOLUME", btn_font, v_change ? ui_btntxtcol : g_bcol, ww - 88, 18, 34, 10, 37);
gr.GdiDrawText("KBPS", btn_font, v_change ? g_bcol : info.Colours[6], ww - 46, 18, 20, 10, 37);

if (fb.IsPlaying) {
if (g_trackinfo == 0) {
g_trackNoImage.draw(info.TrackNo);
gr.DrawImage(g_trackNoImage.image, 0, 30, 54, 20, 0, 0, 54, 20);

g_totalNoImage.draw(info.TotalNo);
gr.DrawImage(g_totalNoImage.image, 60, 30, 54, 20, 0, 0, 54, 20);
} else {
var noTrack = g_trackinfo == 1 ? 534 : 420;
g_signs && gr.DrawImage(g_signs, 0, 30, 114, 20, noTrack, d_col * 22, 114, 20);
}

g_signs && gr.DrawImage(g_signs, ww / 2 - 63, 30, 18, 20, fb.IsPaused ? 197 : 179, d_col * 22, 18, 20);
}

if (v_change) {
var vol = fb.Volume.toFixed(2) + " db";
g_volumeImage.draw(pad_right(vol, 10));
gr.DrawImage(g_volumeImage.image, ww - 191, 30, 165, 20, 0, 0, 165, 20);
} else {
if (fb.IsPlaying) {
var t_play = t_rem && fb.PlaybackLength <= 0 ? false : true;
var t_fmt = t_rem ? info.Remain : info.Elapse;
t_play && g_timeImage.draw(t_fmt);
t_play && gr.DrawImage(g_timeImage.image, ww / 2 - 38, 30, 120, 20, 0, 0, 120, 20);
!t_play && g_signs && gr.DrawImage(g_signs, ww / 2 - 38, 30, 120, 20, 300, d_col * 22, 120, 20);

g_bitrateImage.draw(info.Bitrate);
gr.DrawImage(g_bitrateImage.image, ww - 94, 30, 69, 20, 0, 0, 69, 20);
}
}

g_alpha = g_fact == 0.09 ? 20 : 7;
s_alpha = fb.StopAfterCurrent ? 255 : g_alpha;
g_signs && gr.DrawImage(g_signs, ww - 18, 21, 18, 12, 648, d_col * 22, 18, 12, 0, s_alpha);

p_alpha = fb.IsPlaying ? 255 : g_alpha;
g_signs && gr.DrawImage(g_signs, ww - 18, 38, 18, 12, 668 + fb.PlaybackOrder * 20, d_col * 22, 18, 12, 0, p_alpha);

!window.IsTransparent && gr.FillGradRect(0, -25, ww, 75, 90, RGBA(63, 100, 127, 128), 0);
}

// ----- MOUSE ACTIONS -----
function on_mouse_rbtn_up(x, y) {
CustomMenu(x, y);
return true;
}

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

function on_volume_change(val) {
if (v_timer) {
window.ClearTimeout(v_timer);
v_timer = null;
}

v_timer = window.SetTimeout(
function () {
window.RepaintRect(ww / 2 - 38, 18, ww - (ww / 2 - 12), 32);
window.ClearTimeout(v_timer);
v_timer = null;
v_change = false;
}, 3000);

v_change = true;
window.RepaintRect(ww / 2 - 38, 18, ww - (ww / 2 - 12), 32);
}

function on_playback_order_changed(new_order) {
window.RepaintRect(ww - 18, 38, 18, 12);
}

function on_playback_time(time) {
info.setPBTime();
window.RepaintRect(ww / 2 - 38, 30, 120, 20);
}

function on_playback_dynamic_info() {
info.setBitrate()
window.RepaintRect(ww - 94, 30, 69, 20);
}

function on_playback_edited() {
info.setInfo();
window.Repaint();
}

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

function on_playback_pause(state) {
window.RepaintRect(ww / 2 - 62, 30, 18, 20);
}

function on_playback_stop(reason) {
if (fileinfo) fileinfo.Dispose();

if (reason != 2) {
info.setInfo();
fb.RunMainMenuCommand("ELPlaylist/Redraw");
}

window.Repaint();
}

function on_playlist_stop_after_current_changed(state) {
window.RepaintRect(ww - 18, 21, 18, 12);
}

function on_notify_data(name, info) {
if (name == "remTime") {
window.SetProperty("Remain Time on", info == true ? true : false);
t_rem = window.GetProperty("Remain Time on");
window.RepaintRect(ww / 2 - 38, 18, 120, 38);
}
}

function on_script_unload() {
g_trackNoImage && g_trackNoImage.dispose();
g_totalNoImage && g_totalNoImage.dispose();
g_timeImage && g_timeImage.dispose();
g_bitrateImage && g_bitrateImage.dispose();
g_volumeImage && g_volumeImage.dispose();
g_signs && g_signs.Dispose();
}
The global script that is loaded looks like this:
Code: [Select]
// DarkOne v4.0 Global Script
// Code by tedGo, using partial code by eXtremeHunter1972

var configPath = fb.FoobarPath + "themes\\DarkOne_v4.0\\";
var imgPath = configPath + "Images\\";
var g_signs = gdi.Image(imgPath + "Signs.png");

var btn_font = gdi.Font("Arial Black", 7, 0);
var ui_type = window.InstanceType;
var ww = 0; wh = 0;

// ----- CREATE RGB(A) -----
function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}

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

// ----- CREATE CUSTOM COLOURS -----
function CustomColour(colour){
tempc = colour.split("-");
return ((tempc[3] << 24) | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
}

function setAlpha(color, a) {
return ((color & 0x00ffffff) | (a << 24));
}

function toRGB(d){
var d, r, g, b;
d = d - 0xff000000; r = d >> 16; g = d >> 8 & 0xFF; b = d & 0xFF;
return [r,g,b];
}

function combColours(c1, c2, f){
var c1, c2;
c1 = toRGB(c1); c2 = toRGB(c2);

var r, g, b;
r = Math.round(c1[0] + f * (c2[0] - c1[0])); g = Math.round(c1[1] + f * (c2[1] - c1[1])); b = Math.round(c1[2] + f * (c2[2] - c1[2]));
return (0xff000000 | (r << 16) | (g << 8) | (b));
}

// ----- GET UI COLOURS -----
function get_colors() {
ui_backcol = ui_type == 0 ? window.GetColorCUI(3) : window.GetColorDUI(1);
ui_textcol = ui_type == 0 ? window.GetColorCUI(0) : window.GetColorDUI(0);
ui_btntxtcol = ui_type == 0 ? window.GetColorCUI(2) : window.GetColorDUI(0);
}

get_colors();

function on_colors_changed() {
get_colors();
window.Repaint();
}
Some users of my config have random crashes of the panel - but with FLAC files only! - with this error message:
Code: [Select]
Error: WSH Panel Mod (DarkOne Display Panel v4.0 by super-gau and tedGo, includes partial codes by fbuser, Br3tt and T.P Wang): Microsoft JScript runtime error:
Overflow
File: <main>
Ln: 176, Col: 4
<source text only available at compile time>
And i don't know why...

The line that causes the crash is:
g_signs && gr.DrawImage(g_signs, xoffset, 0, 18, 20, digitValue == " " ? 216 : digitValue * 18, d_col * 22, 18, 20);
(All variables are defined before)
Could anybody take a look at and point me to the right direction?

If someone wants to try the script, this is the Signs.png file: http://www.abload.de/image.php?img=signs1gujt.png

WSH Panel Mod script discussion/help

Reply #2171
As I said on deviantArt: The problem occurs when a track number contains a period (i.e. "21.").

WSH Panel Mod script discussion/help

Reply #2172
Yes, and not only on flac files (was an accident that it only happens with flac files until now).
I now know whats the reason - i haven't respected that users may tag tracknumber with letters/signs besides numbers.

WSH Panel Mod script discussion/help

Reply #2173
I have a workaround that should work (will update the download, too):
Go to the Script and change line 93 from:
var c = fileinfo.MetaValue(fileinfo.MetaFind("tracknumber"), 0);
to:
var c = fb.TitleFormat("$if2($num(%tracknumber%,0),)").Eval();

Then it should work without crashes

WSH Panel Mod script discussion/help

Reply #2174
Confirmed. Fix works.