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

WSH Panel Mod script discussion/help

Reply #525
I have got an working code from tedgo and i want to add
Costum Database Rating %RATING_CD%
and if it is possible love and unlove for LastFM
(I use the LastFM script from marc2003)

Could anyone help me please? 

that's my foobar skin Silent Night for fb2k v.1+


Global Button Script.js

Code: [Select]
// Global Button Script
// Code by T.P Wang and tedGo

var ButtonStates = {normal: 0, hover: 1, down: 2, hide: 3};
var Buttons = {};
var g_down = false;

// ----- CREATE BUTTON OBJECT --------------------------------------
var g_tooltip;

function Button(x, y, w, h, img_src, func, tiptext) {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.state = ButtonStates.normal;
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.img = this.img_normal;

this.alterImage = function(img_src) {
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.changeState(this.state);
}

this.traceMouse = function(x, y) {
if (this.state == ButtonStates.hide) return false;

var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);

if (b)
g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
else
this.changeState(ButtonStates.normal);
return b;
}

this.changeState = function(newstate) {
newstate != this.state && window.RepaintRect(this.left, this.top, this.w, this.h);
this.state = newstate;
switch (this.state) {
case ButtonStates.normal:
this.img = this.img_normal;
break;

case ButtonStates.hover:
this.img = this.img_hover;
break;

case ButtonStates.down:
this.img = this.img_down;
break;

default:
this.img = null;
}
}

this.changePos = function(x, y, w, h) {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
}

this.draw = function(gr) {
this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
}

this.repaint = function() {
window.RepaintRect(this.left, this.top, this.w, this.h);
}

this.onClick = function() {
this.func && this.func();
}

this.onMouseIn = function() {
g_tooltip = window.CreateTooltip();
g_tooltip.Text = this.tiptext;
g_tooltip.Activate();
}

this.onMouseOut = function() {
g_tooltip.Deactivate();
g_tooltip.Dispose();
}
}

function buttonsDraw(gr) {
for (var i in Buttons) {
Buttons[i].draw(gr);
}
}

function buttonsTraceMouse(x, y) {
var btn = null;
for (var i in Buttons) {
if (Buttons[i].traceMouse(x, y) && !btn)
btn = Buttons[i];
}
return btn;
}

// ----- MOUSE ACTIONS ---------------------------------------------
var cur_btn = null;
var btn_down;

function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);

if (btn != cur_btn) {
cur_btn && cur_btn.onMouseOut();
btn && btn.onMouseIn();
}

cur_btn = btn;
}

function on_mouse_lbtn_down(x, y) {
g_down = true;
(btn_down = cur_btn) && cur_btn.changeState(ButtonStates.down);
}

function on_mouse_lbtn_up(x, y) {
if (cur_btn) {
cur_btn.changeState(ButtonStates.hover);
btn_down == cur_btn && cur_btn.onClick(x, y);
}

g_down = false;
}

function on_mouse_leave() {
cur_btn && cur_btn.changeState(ButtonStates.normal);
}


Popup-Rating Menu

Code: [Select]

// Popup-Rating Menu
// Code by tedGo

// ==PREPROCESSOR==
// @import "%fb2k_path%Silent Night\scripts\Global Button Script.js"
// ==/PREPROCESSOR==

var ww = 0; wh = 0;

// ----- CREATE BUTTON ---------------------------------------------
var imgPath = fb.FoobarPath + "Silent Night\\images\\";
Buttons.RAT = new Button(0, 0, 39, 20, {normal: imgPath + "Rate.png", hover: imgPath + "Rate1.png"}, getRatingMenu);

// ----- CREATE MENU -----------------------------------------------
function RateMode() {
rm = window.GetProperty("Rating Mode", 0);
if (typeof rm < 0 || rm > 1) rm = 0;
return rm;
}

RateMode();

function getRatingMenu(x, y) {
x = Buttons.RAT.left;
y = Buttons.RAT.top;

var a = window.CreatePopupMenu();
var g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
var isRating = fb.TitleFormat("$if2(%rating%,0)").EvalWithMetadb(g_metadb);
var delRating = isRating > 0 ? 0 : 1;
var idx;


a.CheckMenuRadioItem(101, 102, rm + 101);

a.AppendMenuItem(0, 101, "Database Rating");
a.AppendMenuItem(0, 102, "Tag Rating");
a.CheckMenuRadioItem(101, 102, rm + 101);
a.AppendMenuItem(2048, 0, 0);
a.AppendMenuItem(0, 1, "Rating 1 - ★");
a.AppendMenuItem(0, 2, "Rating 2 - ★★");
a.AppendMenuItem(0, 3, "Rating 3 - ★★★");
a.AppendMenuItem(0, 4, "Rating 4 - ★★★★");
a.AppendMenuItem(0, 5, "Rating 5 - ★★★★★");
a.CheckMenuRadioItem(1, 5, isRating);
a.AppendMenuItem(delRating, 6, "Remove Rating");

idx = a.TrackPopupMenu(x, y);

switch (true) {
case (idx >= 101 && idx <= 102):
window.SetProperty("Rating Mode", idx - 101);
RateMode();
break;

case (idx >= 1 && idx <= 5):
rm == 0 ? fb.RunContextCommandWithMetadb("Rating/" + idx, g_metadb) : g_metadb.UpdateFileInfoSimple("Rating", idx);
break;

case (idx == 6):
fb.IsMetadbInMediaLibrary(g_metadb) ? fb.RunContextCommandWithMetadb("Rating/<not set>", g_metadb) : g_metadb.UpdateFileInfoSimple("Rating", "");
break;
}

a.Dispose();
}


//Fixed coords for menu
function on_mouse_rbtn_down(x, y) {

}function on_mouse_rbtn_down(x, y, vkey){
rbtnDown = vkey==6 ? true : false;
}

function on_mouse_rbtn_up(x, y, vkey){
if (rbtnDown) {
rbtnDown=false;
return vkey==4 ? false : true;
} else
return true;
}

// ----- DRAW ------------------------------------------------------
function on_paint(gr) {
buttonsDraw(gr);
}

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

Buttons.RAT.changePos(0, 0, 39, 20);   
}


WSH Panel Mod script discussion/help

Reply #526
Allways thanks to grimes and marc2003
Well,how to display console on the WSH-MOD?
Please help me,foo_cosole is only system color

WSH Panel Mod script discussion/help

Reply #527
little update for my lastfm script


WSH Panel Mod script discussion/help

Reply #528
Vertical scrollbar

After some (laborious) studies, I have finally written a script that you may find useful.  It's a file to import in your script to easily define a viewport in the WSH window, with a vertical scrollbar that the user can use to scroll the content of a bitmap vertically.  Keyboard and mouse scrolling are also supported (but are optional).

The scrollbar is configurable.  For example, it can be automatically hid when the mouse leave the WSH window or when it is useless, it can be placed on the left side of the viewport, you can change the colors (including the alpha channel), etc....

Download: main site (no wait) or alternate download link (4shared)

The archive contains scrollbar.js.  It's the main script, to import in your application.  It is fully documented.

There are also two demo scripts:

scrollbar_demo.js is a totally useless and stupid demo, with many comments.

info_text_viewer.js is a somewhat more useful script, that displays the content of the "info.txt" file in the folder containing the currently playing or focussed audio file, or, if that file doesn't exist, the first .txt file it finds in the folder.  (See image below.)

You will probably have to change the @import directive in the demo files, as my scripts are in "%fb2k_profile_path%\wsh_scripts\".

Feel free to report bugs or post suggestions in this thread.

info_text_viewer.js:


WSH Panel Mod script discussion/help

Reply #529
I am having trouble reversing the fading of the button states. Currently it's fading in when mouseover and simply dissappearing when mouseout. I want it the other way round. Like fade-in on_mouseover and disappearing when mouseout.

Image fade buttons

If you need the images for testing simply put any image into either the defined folder or change img_path and var sprite to your likeness.

Hope someone can figure this out.

WSH Panel Mod script discussion/help

Reply #530
No one who could help me ? Either simplify this script or fix the fading ? If so maybe someone can tell me how to adress the output of a timer to use it as input of a function which changes the alpha

WSH Panel Mod script discussion/help

Reply #531
It's really strange that foobar has so many troubles with providing lyrics (to me at least)
Only valid component seems to be made years ago by author - ssenna, with elements still in alpha stage and accessible by Columns UI users only. OTOH other users have choice of primitive text display element for displaying general tags and maybe lyrics if they contain novel

However I made simple CGI VBS for biography view some time ago http://www.hydrogenaudio.org/forums/index....st&p=717583, based on foo_lyricsdb interaction, kindly provided and maintained by dug, and it's working great but biography view can have only one instance with contents, so it's pretty useless generally. I also tried to access Winamp's lyricsplugin.com but they made some ajax trick not beatable by VBS scripting (unless you evoke IE panel)

So to cut this crap, is there ready-made WSH panel that can display provided text as lyrics. I found some posts with dead links so can't say
Not that it would be elegant foobar solution, but perhaps better then all those crash-ware available

WSH Panel Mod script discussion/help

Reply #532
afaik no. But i've planned to code a such panel (WSH panel Mod) all i need is free time now, the community will informed when it will be done ... or maybe some will code one before me

WSH Panel Mod script discussion/help

Reply #533
Thanks for confirmation... looking forward to your solution

WSH Panel Mod script discussion/help

Reply #534
@romor: try this: http://matthijsb.deviantart.com/art/nfoo-V...r-1-1-170638369
it searches the directory of the music you're playing for .nfo, .txt & .log files and displays them in a wsh panel.
you could change the code a bit so it reads the lyrics tag for example, or let it search a txt file for the lyrics you need.

WSH Panel Mod script discussion/help

Reply #535
I made a track display panel that shows lyrics, it doesn't do synced lyrics though. It would be possible to make it do that, but since I don't have synced lyrics I can't be bothered. If anyone wants to modify it so it does, feel free.

You'll need something like lyricsgrabber2 to get the lyrics.

I can't remember if I posted this already, oh well.

Download: http://www.hydrogenaudio.org/forums/index....showtopic=83696


 

WSH Panel Mod script discussion/help

Reply #537
@marc2003

Hi,
just a quick question:
My "now playing" panel doesn't downloads artist pictures automatically even if it's ticked in the right click menu. 
I always have to download them manually choosing "download artist art from lastfm".

Newest WSH_Panel, Samples, Columns_Ui and Foobar.

Since I have no Idea why it would be nice if you could help me out.




WSH Panel Mod script discussion/help

Reply #538
Thanks for confirmation... looking forward to your solution


Hello,

Ok, so here is my lyrics script for WSH panel Mod  ... it maybe needs some code optimization but it works fine apparently

get it here : http://pastebin.com/NHSLyrHu

Lyriks 1.0 (build 20101012.0815) - a WSH lyrics module by Br3tt
- This WSH script get lyrics from TAG first then from local file in foobar2000\lyrics\
then it displays them (scrolling)
- It handles TXT and LRC format (sync handled), but not the LRC Enhanced format
(it translates eLRC to a normal LRC text)
- Comments, Blank lines, Info lines are ignored.
- Manual Scrolling possible with the mousewheel (double click on the panel to re-center on the active line)
- Requirements :
  1) foobar2000
  2) WSH Panel Mod component
  3) this script in a WSH panel
  4) Optional: a lyrics grabber (i.e: Lyric Show Panel by hidding the panel, foo_lyricsDB, ...)
- Some settings are available by using the panel Properties (right click on WSH panel -> Properties)


Please, gimme feedback

WSH Panel Mod script discussion/help

Reply #539
Marc, how tough would it be to implement a cycle mode for Thumbs 2?


not that tough. laziness is a factor though.

My "now playing" panel doesn't downloads artist pictures automatically even if it's ticked in the right click menu. 
I always have to download them manually choosing "download artist art from lastfm".


my mistake. i've uploaded a fixed version or you can just change this on line 54...

Code: [Select]
if(arr.length == 0 && window.GetProperty("auto") == 1001) {


to this

Code: [Select]
if(arr.length == 0 && window.GetProperty("auto")) {






WSH Panel Mod script discussion/help

Reply #542
I thought I'd asked this before, but I can't seem to find the question or answer anymore.
Anyway, is there a tutorial where I can learn the basics of what is needed to fully understand the structure of the code that is used in the WSH Panel Mod.
I'm able to alter the code (is it Jscript or Javascript?) here and there from existing scripts, but to start one from scratch is something different.

cheers r3v0
<3 f00

WSH Panel Mod script discussion/help

Reply #543
@marc2003

For some reason I´m having troubles with thumbs & thumbs2. I´m getting 0xc0000135 error from art.exe when trying to download the images.
If I set the custom folder mode say with "*.jpg" it always displays "no image". I´m using the latest version. Thanks in advanced.

WSH Panel Mod script discussion/help

Reply #544
^i think that error is because art.exe requires the net framework 2.0 installed.

as for custom folder mode simply put the path to a folder. you don't specify wildcards for filenames - it automatically reads all jpg files.

WSH Panel Mod script discussion/help

Reply #545
Falstaff - Just tried out your lyrics viewer script, and it works really well.  I like it better than all the other lyrics display options.  One request visually I would like is the option to use the default panel color.  I tried to switch "plain color background" toggle to True in the properties, and I got a script error.  I also tried to change the color values in the script itself and noticed you used RGBA instead of RGB so we can't edit that to match the rest of the panels.

Thanks for the script!  Works great with synced and unsynced embedded lyrics!  I don't have non-embedded lyrics so I can't attest to that performance.

WSH Panel Mod script discussion/help

Reply #546
Yep that was the reason. Got the config part as well.
Thanks marc2003, they are working nice

WSH Panel Mod script discussion/help

Reply #547
Falstaff - Just tried out your lyrics viewer script, and it works really well.  I like it better than all the other lyrics display options.  One request visually I would like is the option to use the default panel color.  I tried to switch "plain color background" toggle to True in the properties, and I got a script error.  I also tried to change the color values in the script itself and noticed you used RGBA instead of RGB so we can't edit that to match the rest of the panels.

Thanks for the script!  Works great with synced and unsynced embedded lyrics!  I don't have non-embedded lyrics so I can't attest to that performance.


thanx for your feedback, i'll fix what you point to me with default background colour asap.

PS1: fix the script error by replacing line 168 : "g_bgcolour" by "g_plainbg_colour" ... my bad
PS2: RGBA() is like RGB() with just an alpha composant for adjusting tranparency ! just set the 4th value to 255 to obtain the same result of RGB()

WSH Panel Mod script discussion/help

Reply #548
WOW Falstaff, this is excellent script! Thanks for making it man



- It would be nice "DEFAULT_OFFSET" to be synced with "LINE_HEIGHT"
- Some lyrics with timestamps aren't recognized. I couldn't find why
- Some time ago I made VBS that fetches lyrics automatically from dug's database: http://www.hydrogenaudio.org/forums/index....st&p=717583 Can you merge it somehow in your script if it is possible, as I don't understand JS?

WSH Panel Mod script discussion/help

Reply #549
WOW Falstaff, this is excellent script! Thanks for making it man



- It would be nice "DEFAULT_OFFSET" to be synced with "LINE_HEIGHT"
- Some lyrics with timestamps aren't recognized. I couldn't find why
- Some time ago I made VBS that fetches lyrics automatically from dug's database: http://www.hydrogenaudio.org/forums/index....st&p=717583 Can you merge it somehow in your script if it is possible, as I don't understand JS?

can you give me this skin you make? it is very beautiful. please^^