IPB

Welcome Guest ( Log In | Register )

120 Pages V  « < 5 6 7 8 9 > »   
Reply to this topicStart new topic
WSH Panel Mod script discussion/help.
icedtea
post Jan 31 2010, 19:15
Post #151





Group: Members
Posts: 87
Joined: 26-January 10
Member No.: 77538



Tom I am trying to implement your suggestion but image switching isn't working for me
CODE
image_path = fb.FoobarPath + "\\scripts\\images\\";
play_image = gdi.Image(image_path + "play.png");
pause_image = gdi.Image (image_path + "pause.png");
display_image = play_image;

function on_playback_new_track(){
display_image = pause_image;
window.Repaint();
}
function on_playback_pause() {
display_image = play_image;
window.Repaint();
}

function on_playback_starting(){
display_image = pause_image;
window.Repaint();
}

function on_paint(gr) {
gr.DrawImage(display_image, 0, 0, 32, 28, 0, 0, 32, 28, 0, 255);
}


on starting playback I get pause.png OK
on pausing playback I get play.png OK
on resuming playback I get play.png Not OK should be pause.png

What am I doing wrong?

This post has been edited by icedtea: Jan 31 2010, 19:17
Go to the top of the page
+Quote Post
TomBarlow
post Jan 31 2010, 21:06
Post #152





Group: Members
Posts: 585
Joined: 30-July 07
Member No.: 45750



Hi, on_playback_pause() is called when playback is either paused or unpaused, so you need to alternate between the play and pause images there, like this.

CODE
image_path = fb.FoobarPath + "\\scripts\\images\\";
play_image = gdi.Image(image_path + "play.png");
pause_image = gdi.Image (image_path + "pause.png");
display_image = play_image;

function on_playback_stop(){
    display_image = play_image;
    window.Repaint();
}
function on_playback_pause(is_paused) {
    display_image = is_paused?play_image:pause_image;
    window.Repaint();
}

function on_playback_starting(cmd, is_paused){
    display_image = is_paused?play_image:pause_image;
    window.Repaint();
}

function on_paint(gr) {
    gr.DrawImage(display_image, 0, 0, 32, 28, 0, 0, 32, 28, 0, 255);
}
Go to the top of the page
+Quote Post
jmccrohan
post Feb 1 2010, 01:54
Post #153





Group: Members
Posts: 20
Joined: 11-August 07
Member No.: 46121



QUOTE (tedgo @ Jan 27 2010, 22:49) *
Very short code smile.gif
But why do you create a context menu with the default context menu entries only?
You could delete the whole on_mouse_rbtn_up() section.

I uploaded an old version accidentally. blink.gif

The current version refreshes the displayed lyrics.
Go to the top of the page
+Quote Post
icedtea
post Feb 1 2010, 05:41
Post #154





Group: Members
Posts: 87
Joined: 26-January 10
Member No.: 77538



Thanks Tom
I got everything else to work but lost hover somehow in the process. That is the only thing left and I would appreciate the help
CODE
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==

var image_path = fb.FoobarPath + "\\scripts\\images\\";
var play_image = image_path + "play.png";
var pause_image = image_path + "pause.png";
var previous_image = image_path + "previous.png";
var next_image = image_path + "next.png";
var display_image = play_image;
var bw = 32;
var bh = 28;
var window_color = RGB(240,240,240);
var dui = window.InstanceType
var top_margin = 2;
var left_margin = 4;
window.MinWidth = window.MaxWidth = 104;
window.MinHeight = window.MaxHeight = bh + 4;

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

function on_playback_stop(){
display_image = play_image;
window.Repaint();
}
function on_playback_pause(is_paused) {
display_image = is_paused?play_image:pause_image;
window.Repaint();
}

function on_playback_starting(cmd, is_paused){
display_image = is_paused?play_image:pause_image;
window.Repaint();
}

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

function on_paint(gr) {
Buttons = {
but1: new Button(left_margin,top_margin,bw,bh, {normal: previous_image, hover: image_path + "previous_h.png"}, function(){fb.Prev();}, "Previous"),
but2: new Button(bw + left_margin,top_margin,bw,bh, {normal: display_image, hover: image_path + "play_h.png"}, function(){fb.PlayOrPause();}, "Play/Pause"),
but3: new Button((bw*2) + left_margin,top_margin,bw,bh, {normal: next_image, hover: image_path + "next_h.png"}, function(){fb.Next();}, "Next")
}
gr.FillSolidRect(0, 0, ww, wh, window_color);
buttonsDraw(gr);
}


tooltip_buttons.js is from marc2003's examples
Go to the top of the page
+Quote Post
TomBarlow
post Feb 1 2010, 12:44
Post #155





Group: Members
Posts: 585
Joined: 30-July 07
Member No.: 45750



Have a look under on_paint where the buttons are defined, there is a line starting with "but2: new button..." - there is a bit inside there that looks like this: {normal: display_image, hover: image_path + "play_h.png"}, you need to change that to {normal: display_image, hover: display_image_h} for example and then change display_image_h at the same time you change display_image.
Go to the top of the page
+Quote Post
icedtea
post Feb 1 2010, 13:11
Post #156





Group: Members
Posts: 87
Joined: 26-January 10
Member No.: 77538



QUOTE (TomBarlow @ Feb 1 2010, 12:44) *
Have a look under on_paint where the buttons are defined, there is a line starting with "but2: new button..." - there is a bit inside there that looks like this: {normal: display_image, hover: image_path + "play_h.png"}, you need to change that to {normal: display_image, hover: display_image_h} for example and then change display_image_h at the same time you change display_image.

That is not the problem hover images aren't shown at all even when they are defined and that included the static previous and next buttons. I suspect there is something in tooltip_buttons.js that is causing it but I cannot wrap my head around that script.
Go to the top of the page
+Quote Post
marc2003
post Feb 1 2010, 14:34
Post #157





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



the original tooltip button code is by T.P Wang and tedgo. i don't understand it that well either. tongue.gif

i'll try and work it out from what Tom posted.

in the meantime, i've updated my samples. they've all had their options updated to be accessible from the context menu only. no more script editing should be needed (one exception is setting the image size and margins for buttons).

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

samples include

rating script by NEMO7538
simple seekbar
simple biography
playback buttons
web links (myspace, youtube, lastfm)
3 in 1 artwork panel
-the first is a straight replacement for the default art panel. it always prefers embedded album art if it exists. it then falls back on the usual display options set in the foobar preferences.
-last.fm artist art panel. can download multiple images from last.fm and cycle through them. it must be triggered manually using the context menu
-cycle folder option. can cycle through images in a folder at 5, 10 or 20 second intervals

so no instructions needed really. just extract the scripts folder into your foobar directory. add panels and import the samples you want and right click them to see the various options.

EDIT: in the unlikely event someone downloaded this between 1:35-150pm today, please download it again. i didn't update the zip with my newest files. rolleyes.gif

This post has been edited by marc2003: Feb 1 2010, 15:18
Go to the top of the page
+Quote Post
tedgo
post Feb 1 2010, 15:51
Post #158





Group: Members
Posts: 1089
Joined: 16-April 04
From: Bavaria, Germany
Member No.: 13548



@icedtea
Don't create the buttons in on_paint(), that's all wink.gif

EDIT:
I rewrote your script (should work now)
CODE
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==

var image_path = fb.FoobarPath + "\\scripts\\images\\";
var play_image = {normal: image_path + "play.png", hover: image_path + "play_h.png"};
var pause_image = {normal: image_path + "pause.png", hover: image_path + "play_h.png"};
var previous_image = {normal: image_path + "previous.png", hover: image_path + "previous_h.png"};
var next_image = {normal: image_path + "next.png", hover: image_path + "next_h.png"};
var bw = 32;
var bh = 28;
var window_color = RGB(240,240,240);
var dui = window.InstanceType;
var top_margin = 2;
var left_margin = 4;
window.MinWidth = window.MaxWidth = 104;
window.MinHeight = window.MaxHeight = bh + 4;

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

function on_playback_stop(){
Buttons.but2.alterImage(genPPImageSrc());
Buttons.but2.repaint();
}

function on_playback_pause(state) {
Buttons.but2.alterImage(genPPImageSrc());
Buttons.but2.repaint();
}

function on_playback_starting(){
Buttons.but2.alterImage(genPPImageSrc());
Buttons.but2.repaint();
}

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

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, window_color);
buttonsDraw(gr);
}

function genPPImageSrc() {
return (fb.IsPlaying && !fb.IsPaused) ? pause_image : play_image;
}

Buttons = {
but1: new Button(left_margin,top_margin,bw,bh, previous_image, function(){fb.Prev();}, "Previous"),
but2: new Button(bw + left_margin,top_margin,bw,bh, genPPImageSrc(), function(){fb.PlayOrPause();}, "Play/Pause"),
but3: new Button((bw*2) + left_margin,top_margin,bw,bh, next_image, function(){fb.Next();}, "Next")
}


You need this tooltip_buttons.js for this: http://pastebin.de/3644
(has some additional lines to repaint the play/pause button only)

This post has been edited by tedgo: Feb 1 2010, 16:30
Go to the top of the page
+Quote Post
icedtea
post Feb 2 2010, 04:51
Post #159





Group: Members
Posts: 87
Joined: 26-January 10
Member No.: 77538



thanks tego! I will try to understand it if I can
Go to the top of the page
+Quote Post
marc2003
post Feb 2 2010, 06:55
Post #160





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



this post is aimed at people who are happy enough writing their own scripts.

this little snippet allows you to present the user with a text input box, save this text and use it in your scripts.



javascript doesn't have a text input box but vbscript does so i found this code online to do the work. it has to be saved in an external file and we can call it using WshShell.Run.

first of you need my modified version of the script from that link. save this as "input.wsf" in your "scripts" directory...

CODE

<?xml version="1.0" encoding="ISO-8859-1"?>
<job id="IncludeExample">
<script language="VBScript">
<![CDATA[
Function WSHInputBox(Message, Title, Value)
WSHInputBox = InputBox(Message, Title, Value)
End Function
]]>
</script>
<script language="JScript">
<![CDATA[
args = WScript.Arguments;
var WshShell = WScript.CreateObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
try {
ts = fso.OpenTextFile(args(2), 1, false, -1);
s = ts.ReadLine();
ts.close();
} catch(e) {
s = ''
}
var result = WSHInputBox(args(1), args(0), s);
if (result != null) {
try {
ts = fso.OpenTextFile(args(2), 2, true, -1);
ts.WriteLine(result);
ts.close();
} catch(e) {
Wscript.Echo("Error saving data!");
}
}
]]>
</script>
</job>


this is the script to go in your panel. i'm pretty crap at explaining things so i hope the comments make some sort of sense. it's pretty simple really....

CODE
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;

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

function text_input_box(title, message, filename) {
WshShell.Run("\"" + wsf + "\" \"" + title + "\" \"" + message + "\" \"" + filename + "\"", 0, true);
return read(filename);
}

function read(fn) {
try {
var f = fso.OpenTextFile(fn, 1, false, -1);
var s = f.Readline();
f.Close()
return s;
} catch(e) {
return '';
}
}

///////this is the bit you'll want to customise for your own usage//////

var WshShell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wsf = fb.FoobarPath + "scripts\\input.wsf";
//need to be somewhere with "write" access
var settings_path = fb.ProfilePath + "text_input_settings\\";
if(!fso.FolderExists(settings_path)) fso.CreateFolder(settings_path);

//each variable you want to use needs an associated file.
//the input box saves input to this file and then WSH panel mod can read it.
g_text_file = settings_path + "g_text";
//check to see if a value already exists and use it
g_text = read(g_text_file);

//now we a need a function to trigger our input
function on_mouse_lbtn_up(x, y) {
//the text_input box will read the file and present the current value as the default text.
//when you click ok, the external script will then save the result to the text file
//wsh panel mod can then read this updated file and return the new value
//in this simple example, it will just be updating the display using window.Repaint().
g_text = text_input_box("Message Title", "Enter some text:", g_text_file);
window.Repaint();
}

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

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, RGB(255,255,255));
gr.GdiDrawText(g_text, gdi.Font("Segoe UI", 16), RGB(0,0,0), 0, 0, ww, wh, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
}


This post has been edited by marc2003: Feb 2 2010, 07:12
Go to the top of the page
+Quote Post
icedtea
post Feb 2 2010, 09:51
Post #161





Group: Members
Posts: 87
Joined: 26-January 10
Member No.: 77538



marc2003 is it possible to get a wikipedia image for the links? better yet a template where we can create similar icons.
Thanks
Go to the top of the page
+Quote Post
marc2003
post Feb 2 2010, 09:59
Post #162





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



i just got those images from google image search. try it yourself.... wink.gif (there wasn't a wikipedia icon in the pack that i used)

This post has been edited by marc2003: Feb 2 2010, 09:59
Go to the top of the page
+Quote Post
icedtea
post Feb 4 2010, 13:22
Post #163





Group: Members
Posts: 87
Joined: 26-January 10
Member No.: 77538



marc2003 whenever you get the time please consider making a button to switch playback modes i.e. shuffle, default etc
Thanks
Go to the top of the page
+Quote Post
marc2003
post Feb 4 2010, 13:33
Post #164





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



there's already one in T.P's samples i think.

the samples are on the same download page as the component.

This post has been edited by marc2003: Feb 4 2010, 13:35
Go to the top of the page
+Quote Post
catchyfourwordph...
post Feb 5 2010, 00:50
Post #165





Group: Members
Posts: 6
Joined: 6-September 09
From: Germany
Member No.: 72955



Hello there, fellow alien cats!

I've been experimenting with WSH Panel Mod (DUI) for quite a while now but there's still something I'd like to have in my config but can't manage to script. Well, about that... I should mention that I have nearly no clue of scripting whatsoever. All I did before was copy&paste-ing and changing some numeric values. ^^

So here's what I wanna do: I want a heart-shaped love button like Iíve seen in marc2003ís or carmenmís configs. But it should work without LastFM. I aleady used NEMO7538's rating buttons and created a column named "Loved" that displays a heart when a track has a 5-rating.

But for several reasons I donít wanna handle it this way. One of them is that youíre not able to uncheck a ďlovedĒ song (I could only give it a <5rating). So, Iíd love to see a script that can either

1) create a rating-tag and fills it with the value 5
or
2) create a %loved%-tags (by using customdb i.e.).

Iíd be really really grateful for any helping hand! =)
Go to the top of the page
+Quote Post
garbanzo.bean
post Feb 5 2010, 16:14
Post #166





Group: Members
Posts: 260
Joined: 25-September 08
Member No.: 58627



is it appropriate to make requests here?
i'm no coder, and the scripting for this panel, whatever it is, flies straight over my head.

what i'd like to see is a config that divides its host panel into 9 equal areas - basically a 3x3 grid. each area is filled with a solid colour.
each area is also assigned a number, 1-9, based on the layout of a standard keypad (1 bottom-left and 9 top-right).
clicking on a coloured box sends the box's number to the %mood% tag of the currently playing track.

the whole idea is that the horizontal axis represents tempo, and the vertical axis is mood. mimicking the layout of a keypad would make it work well with global hotkeys.
it would also be easy to implement each track's 'color' into a CUI playlist view, and you could build great autoplaylists based on the values.

i really have no idea how difficult this would be to implement, but if anyone is inclined to put it together, i think people would find it useful!

inspired by:
http://www.crayonroom.com/moody.php

Go to the top of the page
+Quote Post
ojdo
post Feb 5 2010, 16:39
Post #167





Group: Members
Posts: 894
Joined: 18-June 06
From: Germany
Member No.: 31980



QUOTE (garbanzo.bean @ Feb 5 2010, 16:14) *
is it appropriate to make requests here?
i'm no coder, and the scripting for this panel, whatever it is, flies straight over my head.

You are lucky, I just coded such a panel with a 5x5 grid. It is available as a ready theme for DUI in this ZIP file on openaudio.eu (link is at the bottom of the page). It is configured to set the tags %valence% (sad to happy) and %arousal% (calm to active) on a scale from -2 to 2.

I also added tagging scripts for foo_masstag to "move" a track's rating in this grid with 4 keyboard shortcuts (I use the keys W,A,S,D).

This is how a portable installation looks after loading the theme:


This post has been edited by ojdo: Feb 5 2010, 16:48


--------------------
http://freemusi.cc/
Go to the top of the page
+Quote Post
garbanzo.bean
post Feb 5 2010, 17:42
Post #168





Group: Members
Posts: 260
Joined: 25-September 08
Member No.: 58627



ojdo, that is tremendous! it integrates perfectly with my CUI config.
now i just have to build a massive playlist column script to show each track's color biggrin.gif

thanks for sharing. i am very lucky indeed!
Go to the top of the page
+Quote Post
marc2003
post Feb 5 2010, 18:04
Post #169





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



@catchyfourwordphrase, i've made you a script. it's totally separate from the rating script so just use that as usual.

you'll need the latest version of my samples zip.

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

it contains updates since my last post (plus i've fixed the ratings panel to let you customise the background colour)

now you'll need to configure customdb. on the "fields" page, create a new field called "LOVE". set the "name" and "display" as this. for the "key", you should select "custom" and add

%artist%,%title%

now restart foobar. now go to the "actions" page and add these 2 actions

CODE
Display: Love
Field: LOVE
Update: ContextMenu
Set Value: 1


CODE
Display: Unlove
Field: LOVE
Update: ContextMenu->Erase


now add a panel and download this code

http://pastebin.com/f7baf0174

use a tag named %love% in your playlist to display a heart if it equals 1.



This post has been edited by marc2003: Feb 5 2010, 18:27
Go to the top of the page
+Quote Post
cartman(2vd)
post Feb 5 2010, 19:36
Post #170





Group: Members
Posts: 240
Joined: 10-August 06
Member No.: 33888



QUOTE (marc2003 @ Feb 1 2010, 14:34) *


In single every sctipt of yours i got error
"Cant create object" in common.js on line 237

CODE
var WshShell = new ActiveXObject("WScript.Shell");


did i missed somthing so much mandatary that it wasnt even in readme? biggrin.gif
Go to the top of the page
+Quote Post
marc2003
post Feb 5 2010, 19:38
Post #171





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



file>preferences>tools>wsh panel mod>uncheck "safe mode". restart foobar.

i keep meaning to make some proper documentation but i never quite get around to it.
Go to the top of the page
+Quote Post
cartman(2vd)
post Feb 5 2010, 19:51
Post #172





Group: Members
Posts: 240
Joined: 10-August 06
Member No.: 33888



QUOTE (marc2003 @ Feb 5 2010, 19:38) *
file>preferences>tools>wsh panel mod>uncheck "safe mode". restart foobar.

i keep meaning to make some proper documentation but i never quite get around to it.


solved. thx for swift response.
Go to the top of the page
+Quote Post
catchyfourwordph...
post Feb 5 2010, 20:38
Post #173





Group: Members
Posts: 6
Joined: 6-September 09
From: Germany
Member No.: 72955



Thanks a ton, marc2003!! smile.gif
Worked like a charm...at least until foobar decided to crash several times because of customdb. It's kind of weird - I've been running fb2k with four dockable panels (one of them is a chronflow panel in nearly fullscreen) and haven't experienced any crashes at all but as soon as I want to add a tiny little heart to my screen, foobar goes bananas biggrin.gif
But nevertheless, thanks again for helping me out. Members like you are one of the reasons why I love foobar and its community so much.

Well, is there any work around to get along with foo_customdb's buggyness? If not, I'd be totally happy with a heart button which generates a 5 in the %rating%-tag and can also erase it. Right now, I'm trying to change your script to do so but the only result was the lovely "ping" sound of a script error wink.gif
So, sorry to bother you again, but could you please help me again with this?
Go to the top of the page
+Quote Post
marc2003
post Feb 5 2010, 20:56
Post #174





Group: Members
Posts: 4326
Joined: 27-January 05
From: England
Member No.: 19379



i experienced a few crashes with foo_customdb during my very first hour of use. and i think it's related to the default fields/actions being triggered during playback. because as soon as i removed them all and just used my own settings, i've not had a single problem. i've been using it for pushing on 2 months now with my last.fm script and it's behaved perfectly.

so try removing all the defaults and leave just your own settings - make sure you restart foobar when done.

This post has been edited by marc2003: Feb 5 2010, 20:57
Go to the top of the page
+Quote Post
catchyfourwordph...
post Feb 6 2010, 00:26
Post #175





Group: Members
Posts: 6
Joined: 6-September 09
From: Germany
Member No.: 72955



For me it seems like this actually did the trick, no crash so far. emot-toot.gif
So, thanks again!
Go to the top of the page
+Quote Post

120 Pages V  « < 5 6 7 8 9 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th April 2014 - 08:02