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 1409643 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod script discussion/help

Reply #226
Does anyone know how to get the text width using GdiDrawText() in pixels for a given font and font size?

WSH Panel Mod script discussion/help

Reply #227
Can anyone help me change applyDelta() in Scroll with GdiDrawText.txt to implement a "floor" so that when offset = 0 you can't drag the text down as there is no text on top. Every method I try ends up cutting some text from the bottom

WSH Panel Mod script discussion/help

Reply #228
Scratch my last question, I chose to work around that.  New question:  Is there a way to specify where the popup menu appears?  Using the command provided in the samples, it always appears wherever the mouse cursor is.  However, I'm making a "toolbar-like" panel, and it would look a lot better if the popups appeared directly under the command, rather than where the cursor is.  Thanks.

WSH Panel Mod script discussion/help

Reply #229
i'm guessing you have this in your menu?

Code: [Select]
idx = _menu.TrackPopupMenu(x, y);


simply replace x and y with the x co-ordinate and height of your object that is being clicked.

@icedtea, this is the formula i use to work out the height of my text. it's not perfect but it's close enough.

Code: [Select]
String.prototype.count=function(s1) { 
    return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
}
textheight = arr[3] - arr[1] + wh  + (g_text.count("\n") * 3);
offset = 0;


WSH Panel Mod script discussion/help

Reply #231
Some minor changes (quick and dirty )  i've made at marc2003s "now playing"-script

for multple artists i use
Code: [Select]
    folder = data_folder + fb.TitleFormat("$crc32($meta(artist,0))").EvalWithMetadb(g_metadb);
    var jpg = utils.Glob(folder + "\\*.jpg").toArray();
    var png = utils.Glob(folder + "\\*.png").toArray();
    var gif = utils.Glob(folder + "\\*.gif").toArray();
    
    var folder1= data_folder + fb.TitleFormat("$crc32($meta(artist,1))").EvalWithMetadb(g_metadb);
    var folder2= data_folder + fb.TitleFormat("$crc32($meta(artist,2))").EvalWithMetadb(g_metadb);  
    var artist1 = utils.Glob(folder1 + "\\*.jpg").toArray();
    var artist2 = utils.Glob(folder2 + "\\*.jpg").toArray();

    arr = jpg.concat(png, gif, artist1, artist2);


and in the scale-function to show the upper part of an portrait picture in an landscape panel
Code: [Select]
function scale(gr, img, pos_x, pos_y, width, height, mth) {
    var s = mth == "max" ? Math.max(width / img.width, height / img.height) : Math.min(width / img.width, height / img.height);
    var nw = img.width * s;
    var nh = img.height * s;
    pos_x += ((width - nw) / 2);
    pos_y += ((mth == "max") && (img.width < img.height)) ? 0 : ((height - nh) / 2);
    // pos_y += ((height - nh) / 2);
    gr.DrawImage(img, pos_x, pos_y, nw, nh, 0, 0, img.width, img.height);
}


it could surely done better, but maybe it's useful for some. I haven't found a good multi-language & multi-artist solution for the bio-panel.

greetz dalover

WSH Panel Mod script discussion/help

Reply #232
you can change the language for the biography panel (line 25)

Code: [Select]
lastfm("&lang=XX&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});


Quote
lang (Optional) : The language to return the biography in, expressed as an ISO 639 alpha-2 code.



WSH Panel Mod script discussion/help

Reply #233
you can change the language for the biography panel (line 25)

Code: [Select]
lastfm("&lang=XX&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});


Quote
lang (Optional) : The language to return the biography in, expressed as an ISO 639 alpha-2 code.



i know - that's my solution with a language variable
Code: [Select]
function get_bio_lang() {
    switch(biolang) {
        case 1:
            lastfm("&lang=de&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});
            break;
        case 2:
            lastfm("&lang=jp&&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});
            break;
         case 0:
        default:
            lastfm("&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});
    }  
}


it's a non automatic solution. i change the biolang-var in the update part

WSH Panel Mod script discussion/help

Reply #234
@icedtea, this is the formula i use to work out the height of my text. it's not perfect but it's close enough.

Code: [Select]
String.prototype.count=function(s1) { 
    return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
}
textheight = arr[3] - arr[1] + wh  + (g_text.count("\n") * 3);
offset = 0;

marc2003 what are you using for applyDelta?

I am using this from Hitchhiker427 but the panel's text gets frozen occasionally i.e. does not drag
Code: [Select]
function applyDelta(delta) {
var temp = offset + delta;
if (offset > 0 || (offset == 0 && delta > 0) || textheight < wh) {
offset = 0;
} else if (offset > -delta) {
offset = 0;
window.Repaint();
} else if (offset > -textheight + wh) {
offset = temp;
window.Repaint();
} else if (delta > 0) {
offset = temp;
window.Repaint();
}
}

WSH Panel Mod script discussion/help

Reply #235
i haven't bothered with drag support - it uses the mouse wheel only. i'm using the font height as a measurement unit so the text always lines up at the top of the panel.

Code: [Select]
function on_mouse_wheel(delta) {
    step = g_font.height * 5;
    offset += (delta * step);
    if(offset > 0 || textheight < wh) {
        offset = 0;
    } else {
        temp = -textheight + wh;
        if(offset < temp) offset = Math.round(temp / step) * step;
    }
    window.Repaint();
}

WSH Panel Mod script discussion/help

Reply #236
marc2003 another thing I needed your help with
I am using your bio panel with some modifications. I was trying to switch between artist summary and details using
Code: [Select]
    if (idx == 1) {
        cont = 'summary';
        artist='';
        on_metadb_changed();
        }
    if (idx == 2) {
        cont = 'content';
        artist='';
        on_metadb_changed();
        }

and passing cont to the metadb function. This works ok but where I am failing is getting the selection to stick between sessions using window.SetProperty(); and then using window.GetProperty() to set MF_CHECKED/MF_UNCHECKED for the option.

Thanks

WSH Panel Mod script discussion/help

Reply #237
@icedtea,

You mentioned that you were using a script from me for scrolling.  Is that the same bio script I sent you a while ago?  If so, I've fixed a number of bugs (some to do with scrolling) and added a few features.  I haven't noticed any scrolling issues in my latest version.  Do you want me to send you what I have?  Maybe you can dissect it and figure out a solution to the problem.

WSH Panel Mod script discussion/help

Reply #238
@icedtea,

You mentioned that you were using a script from me for scrolling.  Is that the same bio script I sent you a while ago?  If so, I've fixed a number of bugs (some to do with scrolling) and added a few features.  I haven't noticed any scrolling issues in my latest version.  Do you want me to send you what I have?  Maybe you can dissect it and figure out a solution to the problem.

I would really appreciate that.
Thanks

WSH Panel Mod script discussion/help

Reply #239
marc2003 please ignore the previous message I made it work by using
Code: [Select]
bio_text = xmlDoc.getElementsByTagName(window.GetProperty("mode") ? "summary" : "content")[0].childNodes[0].nodeValue;
...
_menu.AppendMenuItem(window.GetProperty("mode") ? MF_CHECKED : MF_UNCHECKED, 1, "Summary");
_menu.AppendMenuItem(window.GetProperty("mode") ? MF_UNCHECKED : MF_CHECKED, 2, "Details");
...
if (idx == 1) {
 window.SetProperty("mode", 1);
 artist = '';
 need_calc = true;
 on_metadb_changed();
}
if (idx == 2) {
 window.SetProperty("mode", 0);
 artist = '';
 need_calc = true;
 on_metadb_changed();
}

Just wanted to check if there is a more optimum way
Thanks

WSH Panel Mod script discussion/help

Reply #240
@marc2003

I'm trying to change the fonts and background from your excellent biography panel

this is what i have so far

Code: [Select]
function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
    if(username.length == 0 || api_key.length != 32) {
        gr.GdiDrawText("Last.fm username and/or API KEY is not set.", g_font, g_textcolor, 0, 0, ww, wh,DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
    } else if(g_metadb) {
        gr.GdiDrawText(g_text, g_font, g_textcolor, 6, offset + 65, ww-16, wh-offset,DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
        gr.FillSolidRect(0, 0, ww, 56, g_backcolor);
        gr.GdiDrawText(artist, gdi.Font("Calibri", 26, 1), g_textcolor_hl, 6, 5, ww-77, 32,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
        gr.GdiDrawText(addCommas(listeners) + " listeners,  " + addCommas(userplaycount) + " plays in your library.", gdi.Font("Calibri", 22, 0), g_textcolor_hl, 6, 33, ww-16, 28,DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
        gr.DrawImage(lfm_img, ww-60, 8, 50, 18, 0, 0, 50, 18);
        gr.DrawLine(5, 35, ww-10, 35, 1, g_textcolor_hl);
    } else {
        gr.GdiDrawText("[no selection]", g_font, g_textcolor, 0, 0, ww, wh,DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
    }
}


now i want to change the background color to black, all fonts to some kind of light grey and the size of the biography text font to let's say 18 or 20.
Help would be much appreciated.

WSH Panel Mod script discussion/help

Reply #241
just put these 4 variables anywhere in the script (not inside any function).

Code: [Select]
g_backcolor = RGB(0,0,0);
g_textcolor = RGB(180,180,180);
g_textcolor_hl = RGB(200,200,200);
g_font = gdi.Font("Segoe UI", 20, 0);


obviously you can play around with the colours yourself.

WSH Panel Mod script discussion/help

Reply #242
thank you.
Works perfectly!

WSH Panel Mod script discussion/help

Reply #243
just one thing - the panel will change colour if you change the text/background colours in the DUI/CUI settings. you'll have to reload the script to get your colours back. shouldn't be much of an issue but i thought i'd mention it.

EDIT: i suppose you could move those variables inside on_paint right at the start. then you won't have any problems. i should have just said this in the first place.

WSH Panel Mod script discussion/help

Reply #244
Thx 

only one more question:

where are those icons for youtube, myspace, lastfm from?
It would be great if it were a button set because I need a google, wikipedia, discogs and a
rate your music button which fit your buttons and to combine them to a nice web toolbar
in my foobar htpc mod.

If you made them yourself then I have to say good work! if not please tell me where
you downloaded them...

edit: nevermind...found them on top of this page 

WSH Panel Mod script discussion/help

Reply #245
Hi everybody. As I'm totally new at scripting I have a simple question - where and what should I add/change to the seekbar script to get "Stopped" displayed in the middle of the seekbar when no song is playing? Currently of course it is not displaying anything 

I compiled this code from different sources out here. 

Code: [Select]
function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

text_colour = RGB(50,50,50);
background_colour = RGB(240,240,240);

/*you can set 2 colours here for a gradient effect on the seekbar. this sample replicates the aero blue found in windows 7.
if you want a solid colour, set

bar_colour_2 = "none";

(then only bar_colour_1 will be used)*/

bar_colour_1 = RGB(240,240,240);
bar_colour_2 = RGB(190,190,190);

/////////////////////////end user settings//////////////////////////////////////////////////////////////////////////////////////////////////////

var g_font = gdi.Font("Segoe UI", 12, 1);
var g_drag = 0;
var g_drag_seek = 0;
var g_timer, txt;

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

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, background_colour);
if(fb.IsPlaying) {
if(fb.PlaybackLength > 0) {
if(g_drag){
t = fb.PlaybackLength * g_drag_seek;
h = Math.floor(t/3600)
m = Math.floor((t-=h*3600)/60);
s = Math.floor(t-=m*60);
pos = ww * g_drag_seek;
txt = (h > 0 ? h + ":" + (m <10 ? "0" + m : m) : m) + ":" + (s < 10 ? "0" + s : s) + " / " + length;
} else {
pos = ww * (fb.PlaybackTime / fb.PlaybackLength);
txt = fb.IsPaused ? "Paused" : fb.titleformat("Playing | %codec% | %bitrate% kbps | %samplerate% Hz | $caps(%channels%) | %playback_time%").Eval() + " / " + length;
}
if(bar_colour_2 == "none") {
gr.FillSolidRect(0, 0, pos, wh, bar_colour_1);
} else {
gr.FillGradRect(0, 0, pos, wh, 90, bar_colour_1,bar_colour_2);
}
} else if(fb.PlaybackTime > 0.1) {
txt = fb.IsPaused ? "Paused" : fb.titleformat("Playing | %codec% | %bitrate% kbps | %samplerate% Hz | $caps(%channels%) | %playback_time%").Eval() + " / LIVE";
}

        gr.SetTextRenderingHint(5);
gr.DrawString(txt, g_font, text_colour, 0, 0, ww, wh,0x11005000);
}

if(window.InstanceType == 1) gr.DrawRect(0,0, ww, wh, 1.0, RGB(137,140,149));
}

function on_mouse_lbtn_down(x,y){
if(fb.IsPlaying && fb.PlaybackLength > 0) g_drag = 1;
}

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

function on_mouse_mbtn_down(x,y){
    if(fb.IsPlaying && fb.PlaybackTime > 0) fb.RunMainMenuCommand("View/Columns playlist/Activate now playing");
}

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

function on_playback_new_track() {
length = fb.TitleFormat("%length%").Eval();
g_timer = window.CreateTimerInterval(100);
}

function on_playback_stop() {
if(g_timer) window.KillTimer(g_timer);
    window.Repaint();
    CollectGarbage();
    }

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

function on_timer(id){
window.Repaint();
}

function on_mouse_wheel(delta) {
fb.PlaybackTime = fb.PlaybackTime + 5*delta;
}

if(fb.isplaying) on_playback_new_track();

WSH Panel Mod script discussion/help

Reply #246
replace your on_paint function with this...

Code: [Select]
function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, background_colour);
    if(fb.IsPlaying) {
        if(fb.PlaybackLength > 0) {
            if(g_drag){
                t = fb.PlaybackLength * g_drag_seek;
                h = Math.floor(t/3600)
                m = Math.floor((t-=h*3600)/60);
                s = Math.floor(t-=m*60);
                pos = ww * g_drag_seek;
                txt = (h > 0 ? h + ":" + (m <10 ? "0" + m : m) : m) + ":" + (s < 10 ? "0" + s : s) + " / " + length;
            } else {
                pos = ww * (fb.PlaybackTime / fb.PlaybackLength);
                txt = fb.IsPaused ? "Paused" : fb.titleformat("Playing | %codec% | %bitrate% kbps | %samplerate% Hz | $caps(%channels%) | %playback_time%").Eval() + " / " + length;
            }
            if(bar_colour_2 == "none") {
                gr.FillSolidRect(0, 0, pos, wh, bar_colour_1);
            } else {
                gr.FillGradRect(0, 0, pos, wh, 90, bar_colour_1,bar_colour_2);
            }
        } else if(fb.PlaybackTime > 0.1) {
                txt = fb.IsPaused ? "Paused" : fb.titleformat("Playing | %codec% | %bitrate% kbps | %samplerate% Hz | $caps(%channels%) | %playback_time%").Eval() + " / LIVE";
        }
    } else {
        txt = "Stopped";
    }   
    gr.SetTextRenderingHint(5);
    gr.DrawString(txt, g_font, text_colour, 0, 0, ww, wh,0x11005000);
}

WSH Panel Mod script discussion/help

Reply #247
thank you very much Marc! I was adding the same "else" code, but my mistake was that i was adding it at the very end of on_paint(gr) function 

a real noob

WSH Panel Mod script discussion/help

Reply #248
Hi,

I'm trying to get an action when I roll over an image.
Can someone show some basic stuff on this?

Cheers
<3 f00

WSH Panel Mod script discussion/help

Reply #249
Hey guys, I'm thinking of writing a script to grab stuff from allmusic.com (biography, work info, etc...)
Since I've never written any VBScript or JScript, did anyone write a sample or script that I could be useful?
For example how to load an html page, parse, etc...

Thanks in advance!