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

WSH Panel Mod script discussion/help

Reply #325
hi, maybe i can reach another time some help from you, here.
2 questions:
  • is-it possible to make a knob that will change playback order (and show the appropriate text below the knob), instead of a button? I mean a knob with a defined number of "hard state" (in opposite of smooth drag as volume does - somelike the "source selector" in our old Hi-Fi amplificator for those who remember ) but would react with mouse scroll and/or mouse drag, more than specified lbtn_up/down zone?
    TomBarlow gave me a very good start for a volume knob, but i was curious if i could get same design for playback order, because my volumeknob is feeling a bit alone in my panel
  • then: script/code bug ... and i don't know what could be the cause:
    i've "compiled" (mix from here and there) a rating star panel whith following code:
    Code: [Select]
    // ==PREPROCESSOR==
    // @import "%fb2k_path%docs\Flags.txt"
    // @import "%fb2k_path%docs\Helpers.txt"
    // ==/PREPROCESSOR==

    //===================================== RATING
    var ww = window.Width;
    var wh = window.Height;
    var bg = RGBA(212, 203, 159, 255);
    var g_drag = 0;
    var bool;
    var g_metadb;
    var rating;
    var nrating;
    var lrating;
    var hofset=0;
    var imgw=12;
    var g_tfo = fb.TitleFormat("%rating%");
    var g_font = gdi.Font("wingdings", 12, 0);
    var opt_read = 1

    //=====================================

    function on_paint(gr){
    gr.FillSolidRect( 0, 0, ww, wh, bg);
    gr.SetTextRenderingHint(5);
    if (g_metadb) {

    if (fb.isplaying || fb.ispause) {
    this.RatedStar = RGB(52, 52, 52);
    }else{
    var RatedStar = RGB(190, 186, 129);
    }
    var NotRatedStar = RGB(190, 186, 129);



    for (i = 1; i < 6; i++) {
    color = ( ((i > (g_drag ? lrating : rating)) ? NotRatedStar : RatedStar ) );
        gr.GdiDrawText("", g_font,color,hofset+imgw*(i-1) ,0 ,56 ,26 , 0);
    }
      }
     
      else{}
     
    }
    //=====================================

    function on_mouse_lbtn_up(x,y){

      if(opt_read==1) {
        if (lrating !=rating) {if (g_metadb) {
        bool = g_metadb.UpdateFileInfoSimple("RATING",lrating);
        }}
        else {
          bool = g_metadb.UpdateFileInfoSimple("RATING","");}
      } else {
        if (lrating !=rating) {if (g_metadb) {
        bool = fb.RunContextCommandWithMetadb("Rating/"+((lrating==0) ? "<not set>" : lrating),g_metadb);
        }}
        else {
        bool = fb.RunContextCommandWithMetadb("Rating/<not set>",g_metadb);} 
      }
    }




    //=====================================

    function on_mouse_move(x, y) {
    if (g_metadb) {
    g_drag = 1;
    nrating = Math.ceil((x-hofset)/imgw);
    if (nrating > 5) nrating = 5;
    if (nrating != lrating) {
    lrating = nrating;
    window.Repaint();
    }
    }
    }
    //=====================================

    function on_mouse_leave() {
    on_metadb_changed()
    }
    //=====================================

    function on_item_focus_change() {
    if (g_metadb) {window.UnwatchMetadb();}
    g_metadb = fb.GetFocusItem();
    if (fb.IsPlaying | fb.IsPaused) g_metadb = fb.GetNowPlaying();
    if (g_metadb) {
    on_metadb_changed();
    window.WatchMetadb(g_metadb);
    }

    }
    //=====================================

    function on_metadb_changed() {
    g_drag = 0;
    if (g_metadb) {rating = g_tfo.EvalWithMetadb(g_metadb);}
    if (rating == "?") {rating = 0;}
    lrating = rating;
    window.Repaint();
    }
    //=====================================

    function on_playback_new_track(metadb) {
        on_item_focus_change();
        }
       
    //========================================

    function on_mouse_rbtn_down(x, y) {
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
    }

    //=====================================

    function on_mouse_rbtn_up(x, y) {
       
    var _menu = window.CreatePopupMenu();
       
        if (ShiftDown) {

            _menu.AppendMenuItem(MF_STRING, 1, "Properties");
            _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
            _menu.AppendMenuItem(MF_STRING, 2, "Configure...");
        }
            idx = _menu.TrackPopupMenu(x, y);
        switch (idx) {

        case 1:
            window.ShowProperties();
            break;
        case 2:
            window.ShowConfigure();
            break;
        }

        return true
    }

    //=====================================

    on_item_focus_change();

    //EOF
    everything is ok, i've selected transparent bg, even if, just in case i've declared a bg color that match with the panel below. And rating/unrating works great.
    But when foobar start, all the WSH panel background, and only this one, is black during 2 seconds. Ok, i can live with that (mouhaha), but, my knowledge of JScript goes step by step, and this could help me to understand more things.
    acting normaly:

    strange behaviour during foobar start:
Thx

WSH Panel Mod script discussion/help

Reply #326
coverflow




prerequisite:
  • in foobar2000: Library | Search | %tracknumber% IS 01 | Create Playlist
  • select all tracks in playlist | rightclick | Utilities | Text Tools | Advanced | Track Pattern: "%path%", | Copy
  • open editor (notepad++) | Paste | replace \ by \\ and remove last comma
  • Insert created paths in WSH Panel mod script at line 20 (array) | Apply


Code: [Select]
//coverflow by grimes
//fb2k 1.0+, WSH Panel Mod 1.3.2+ required
//DUI/CUI ready

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

var dui = window.InstanceType;
//var g_font = gdi.Font("Segoe UI", 12, 0);
var g_font = dui === 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
//var color = RGB(200,0,0);
var color = dui === 1 ? window.GetColorDUI(2) : RGB(200, 0, 0);
//var color2 = RGB(0,0,0);
var color2 = dui === 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);

var id = 0;
var zz = 0;
var ww = 0,
    wh = 0;
var patharray = new Array(
//insert paths
);

var g_img;
var g_img2;
var g_img3;
var g_img4;
var g_img5;

function get_image() {
    g_img = utils.GetAlbumArt(patharray[zz], id);
    g_img2 = utils.GetAlbumArt(patharray[zz - 2], id);
    g_img3 = utils.GetAlbumArt(patharray[zz - 1], id);
    g_img4 = utils.GetAlbumArt(patharray[zz + 1], id);
    g_img5 = utils.GetAlbumArt(patharray[zz + 2], id);
}

get_image();

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww * 6, wh, dui === 1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (g_img && g_img2 && g_img3 && g_img4 && g_img5) {
        var scale = 0;
        var y = 0;
        var scale_w = ww / g_img.Width;
        var scale_h = wh / g_img.Height;

        if (scale_w * 2 <= scale_h) {
            scale = scale_w * 2;
            y = (wh - g_img.Height * scale) / 2;
        } else {
            scale = scale_h;
        }
        var scale2 = 0;
        var y2 = 0;
        var scale_w2 = ww / g_img2.Width;
        var scale_h2 = wh / g_img2.Height;

        if (scale_w2 <= scale_h2) {
            scale2 = scale_w2;
            y2 = (wh - g_img2.Height * scale2) / 2;
        } else {
            scale2 = scale_h2;
        }
        var scale3 = 0;
        var y3 = 0;
        var scale_w3 = ww / g_img3.Width;
        var scale_h3 = wh / g_img3.Height;

        if (scale_w3 <= scale_h3) {
            scale3 = scale_w3;
            y3 = (wh - g_img3.Height * scale3) / 2;
        } else {
            scale3 = scale_h3;
        }
        var scale4 = 0;
        var y4 = 0;
        var scale_w4 = ww / g_img4.Width;
        var scale_h4 = wh / g_img4.Height;

        if (scale_w4 <= scale_h4) {
            scale4 = scale_w4;
            y4 = (wh - g_img4.Height * scale4) / 2;
        } else {
            scale4 = scale_h4;
        }
        var scale5 = 0;
        var y5 = 0;
        var scale_w5 = ww / g_img5.Width;
        var scale_h5 = wh / g_img5.Height;

        if (scale_w5 <= scale_h5) {
            scale5 = scale_w5;
            y5 = (wh - g_img5.Height * scale5) / 2;
        } else {
            scale5 = scale_h5;
        }
        gr.DrawImage(g_img, ww * 3 - g_img.Width * scale / 2, y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
        gr.DrawImage(g_img2, 0, y2, g_img2.Width * scale2, g_img2.Height * scale2, 0, 0, g_img2.Width, g_img2.Height);
        gr.DrawImage(g_img3, ww, y3, g_img3.Width * scale3, g_img3.Height * scale3, 0, 0, g_img3.Width, g_img3.Height);
        gr.DrawImage(g_img4, ww * 5 - g_img4.Width * scale4, y4, g_img4.Width * scale4, g_img4.Height * scale4, 0, 0, g_img4.Width, g_img4.Height);
        gr.DrawImage(g_img5, ww * 6 - g_img5.Width * scale5, y5, g_img5.Width * scale5, g_img5.Height * scale5, 0, 0, g_img5.Width, g_img5.Height);
        gr.GdiDrawText(zz + 1, g_font, color, 10, 5, window.Width - 10, window.Height, 0x00000010);
    } else {
        gr.GdiDrawText("error: no stub image path defined", g_font, color2, 10, 5, window.Width - 10, window.Height, 0x00000010);
    }
}

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

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

function on_mouse_lbtn_down(x, y) {
    if (x > ww * 3 && y < wh) {
        if (zz === patharray.length - 1) {
            zz = 0;
        } else if (zz < patharray.length - 1) {
            zz += 100;
        }
        if (zz >= patharray.length - 1) {
            zz = patharray.length - 1;
        }
    }
    if (x < ww * 3 && y < wh) {
        if (zz === 0) {
            zz = patharray.length - 1;
        } else if (zz > 0) {
            zz -= 100;
        }
        if (zz < 0) {
            zz = 0;
        }
    }
    if (g_img) {
        get_image();
    }
    window.Repaint();
}

function on_mouse_move() {
    if (g_img) window.SetCursor(32649);
}

function on_mouse_wheel(delta) {
    for (i = 0; i < delta; i++) {
        zz++;
    }
    for (i = 0; i < -delta; i++) {
        zz--;
    }
    if (zz < 0) {
        zz = patharray.length - 1
    } else if (zz > patharray.length - 1) {
        zz = 0;
    }
    if (g_img) {
        get_image();
    }
    window.Repaint();
}

function on_mouse_rbtn_up(x, y) {
    var MF_SEPARATOR = 0x00000800;
    var MF_STRING = 0x00000000;
    var _menu = window.CreatePopupMenu();
    var idx;
    _menu.AppendMenuItem(MF_STRING, 1, "cover");
    _menu.AppendMenuItem(MF_STRING, 2, "back");
    _menu.AppendMenuItem(MF_STRING, 3, "disc");
    _menu.AppendMenuItem(MF_STRING, 4, "icon");
    _menu.AppendMenuItem(MF_STRING, 5, "artist");
    _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    //_menu.AppendMenuItem(MF_STRING, 5, "Properties");
    _menu.AppendMenuItem(MF_STRING, 6, "Configure...");
    _menu.CheckMenuRadioItem(1, 5, id + 1);
    idx = _menu.TrackPopupMenu(x, y);
    switch (idx) {
    case 1:
        id = 0;
        break;
    case 2:
        id = 1;
        break;
    case 3:
        id = 2;
        break;
    case 4:
        id = 3;
        break;
    case 5:
        id = 4;
        break;
    case 5:
        window.ShowProperties();
        break;
    case 6:
        window.ShowConfigure();
    }

    _menu.Dispose();
    if (g_img) {
        get_image();
    }
    window.Repaint();
    return true;
}

function on_colors_changed() {
    color = dui === 1 ? window.GetColorDUI(2) : RGB(200, 0, 0);
    color2 = dui === 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
    window.Repaint();
}

function on_font_changed() {
    g_font = dui === 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
    window.Repaint();
}


WSH Panel Mod script discussion/help

Reply #327
  • in foobar2000: Library | Search | %tracknumber% IS 01 | Create Playlist
  • select all tracks in playlist | rightclick | Utilities | Text Tools | Advanced | Track Pattern: "%path%", | Copy
  • open editor (notepad++) | Paste | replace \ by \\ and remove last comma
  • Insert created paths in WSH Panel mod script at line 20 (array) | Apply


Looks good. Are you planning to improve the script further
so that user don't have to go through the steps described above?

WSH Panel Mod script discussion/help

Reply #328
At this point this is only a testversion. The steps are only necessary after adding new albums to media library.
These new albums are simply missing in coverflow.
Maybe new albums could be added to the array by playing a track of the new album, but i don't plan to add this feature.
I would like to add something like reflection or 3d effect, but i don't know the graphic abilities of WSH panel mod, especially IGdiGraphics interface.
Maybe someone could give more information, what is possible?

WSH Panel Mod script discussion/help

Reply #329
samples updated: http://cid-649d3bfeaf541fbb.skydrive.live....ide/samples.zip

2 minor changes
"artwork 3 in 1" now fills the panel instead of leaving gaps when the image doesn't fit. aspect is still maintained so edges will be clipped if necessary.
"simple biography" panel now stops scrolling at the right place.

i've also re-jigged lots of background stuff that you won't notice. hopefully i didn't break anything in the process.

WSH Panel Mod script discussion/help

Reply #330
I would like to add something like reflection or 3d effect, but i don't know the graphic abilities of WSH panel mod, especially IGdiGraphics interface.
Maybe someone could give more information, what is possible?


for this, you should look at ojdo's HTPC panels thread in the uploads section. his script has reflections in.

WSH Panel Mod script discussion/help

Reply #331
I've got a request for a script that can do the following:

1. show tags directly from last.fm (like the biography panel)
2. write them to a tag with a button click
3. filters for tags you want to exclude/include (like in the last.fm plus plugin for picardtagger).

Would this be possible, and would anyone like to create a script like this if it is?

WSH Panel Mod script discussion/help

Reply #332
I've got a request for a script that can do the following:

1. show tags directly from last.fm (like the biography panel)
2. write them to a tag with a button click
3. filters for tags you want to exclude/include (like in the last.fm plus plugin for picardtagger).

Would this be possible, and would anyone like to create a script like this if it is?


its possible
even without scripting experience you can do this yourself.
all you have to do is edit the scripts that are floating around here.
just take the lastfm script from marc2003 and change it so that it gets the tags from the last fm api.
filtering is the easiest part where you just add a new column with [%lastmf_tags%] for example

WSH Panel Mod script discussion/help

Reply #333
samples updated with glass playback buttons.

http://cid-649d3bfeaf541fbb.skydrive.live....ide/samples.zip

this has additonal requirements compared to the other scripts:

1) requires columns UI and a specially modified version of WSH panel mod -
http://sites.google.com/site/jk7800/foobar...?attredirects=0
2) the panel must be placed at the bottom of a vertical splitter with both the status bar and status pane turned off

and it looks like this....

When I try and use any of your samples I get a script error, the only one that works is aero seekbar. I am trying to get the glass buttons and I have the modded version of wsh panel you linked too.

WSH Panel Mod script discussion/help

Reply #334
did you follow the instructions regarding extracting the zip into your foobar folder and turning off safe mode in the WSH panel mod preferences?

WSH Panel Mod script discussion/help

Reply #335
got it working, I forgot to put the scripts folder in the install dir, but I do have one issue, the playback icons for me look much blurrier than in the screenshot. here is a screen:
http://img245.imageshack.us/img245/3935/22007058.png

WSH Panel Mod script discussion/help

Reply #336
that looks fine to me??

but in my screen shot i'm not using standard windows aero. i'm using a theme called win7blend found on devinatart.

WSH Panel Mod script discussion/help

Reply #337
They get sharper if I change the code where it says 160 / 2 to 160 / 200 (which moves them all to the left side) basically anywhere but the middle they look much shaprer, as soon as I put them back in the middle they are quite noticeably blurry for me though.

WSH Panel Mod script discussion/help

Reply #338
Y'll should use integer values as coordinates! Just use Math.round()
The images look blurry because they are being rendered at non-integer values i.e. 12.5 pixels.
<insert signature here>

WSH Panel Mod script discussion/help

Reply #339
thanks for the tip. but i still can't tell the difference. .

for anybody using this script change line 22:

Code: [Select]
pos = Math.round((ww-160) / 2);


i've updated the hosted file as well.

WSH Panel Mod script discussion/help

Reply #340
Thanks guys! worked great. they look perfectly sharp now.

WSH Panel Mod script discussion/help

Reply #341
did you follow the instructions regarding extracting the zip into your foobar folder and turning off safe mode in the WSH panel mod preferences?


your "rating" work in "other WSH samples (new)" have a sad problem.

when i click on the star ,nothing happens, it can't rate the song, another word , your work can only show the rating , it can't rate the rating.

WSH Panel Mod script discussion/help

Reply #342
i'm thinking perhaps my issue with not be able to see so clearly is that i have a crappy old CRT monitor....

anyway, samples updated with a proper readme detailing what each script does and all relevant instructions.

http://cid-649d3bfeaf541fbb.skydrive.live....ide/samples.zip

WSH Panel Mod script discussion/help

Reply #343
Pardon my ignorance but I couldn't find a way to align text drawn with the new IStyleTextRender. How do I do it?
<insert signature here>

WSH Panel Mod script discussion/help

Reply #344
In MainMenuManager All-In-One.txt can someone please show my how I can append the preferences entry?

WSH Panel Mod script discussion/help

Reply #345
add these 2 lines just before "ret = 0".

Code: [Select]
basemenu.AppendMenuItem(MF_SEPARATOR, 0, 0);
basemenu.AppendMenuItem(MF_STRING,2000,"Preferences");


then add this as the first item in the switch statement just below.

Code: [Select]
case(ret == 2000):
    fb.ShowPreferences();
    break;

WSH Panel Mod script discussion/help

Reply #346
thanks marc2003 can you please give me the code for adding a rating submenu as well contextman.Init("Rating") doesn't seem to do the trick for me.

WSH Panel Mod script discussion/help

Reply #347
I need help with this code:

Code: [Select]
function createPattern(w,h){
    var bg = gdi.CreateImage(w,h);
    var mask = gdi.CreateImage(w,h);
    var g = mask.GetGraphics();
    g.FillSolidRect(0,0,w,h,0xff000000);
    for (i = 0; i < Math.round(h/2); i++){
        g.FillSolidRect(0,i*2+1,w,1,0xffffffff);
    }
    mask.ReleaseGraphics(g);
    g = bg.GetGraphics();
    g.FillSolidRect(0,0,w,h,0xffffffff);
    bg.ReleaseGraphics(g);
    bg.ApplyMask(mask);
    return bg;
}

This thing creates a pattern I use to paint a volume bar, my panel calls this in the on_size callback. Everything works when I press the OK button. My problem appears to be on foobar2000 startup. The console throws this: Microsoft JScript runtime error: 'null' is null or not an object Ln: 23, Col: 5 which is the line: var g = mask.GetGraphics();

Does anyone see anything stupid there?
<insert signature here>

WSH Panel Mod script discussion/help

Reply #348
New version of cover browser (formerly coverflow)



Updated instructions for filling array and arrayupdate (prerequisite):
  • in foobar2000: Library | Search | %tracknumber% IS 01 | Create Playlist
  • Select all tracks of generated playlist | rightclick | Utilities | Text Tools | Advanced | Track Pattern: "%path%", | Copy
  • open an Editor (z.B. Notepad++) | Paste | Replace \ by \\ and remove last comma
  • Repeat step2 with Track Pattern: "%album%", and remove last comma
  • Insert in line 45 and 49 of WSH Panel mod script | Apply


http://pastebin.de/5265

updates and information: http://foobar-users.de/index.php?topic=200...g16441#msg16441

WSH Panel Mod script discussion/help

Reply #349
thanks marc2003 can you please give me the code for adding a rating submenu as well contextman.Init("Rating") doesn't seem to do the trick for me.


Marc I could not find a way to get the rating menu from the context menu so instead I created a custom menu and used fb.RunContextCommandWithMetadb. Is there a way to just populate using the context playback statistics rating menu?