IPB

Welcome Guest ( Log In | Register )

126 Pages V  < 1 2 3 4 5 > »   
Reply to this topicStart new topic
WSH Panel Mod script discussion/help.
Yirkha
post Jan 21 2010, 22:15
Post #51





Group: FB2K Moderator
Posts: 2359
Joined: 30-November 07
Member No.: 49158



QUOTE (tedgo @ Jan 21 2010, 22:09) *
Where are the differences?
The difference is in the quantifier, * for 0 or more and + for 1 or more.
But /\[[^\]]*\]/g is best (a literal [, then any number of chars not being a ], then the closing bracket itself).
I don't know if it matters here, but the previous patterns are greedy and would replace for example "foo[123]bar[456]2000" to "foo2000" instead of "foobar2000".


--------------------
Full-quoting makes you scroll past the same junk over and over.
Go to the top of the page
+Quote Post
fbuser
post Jan 21 2010, 22:15
Post #52





Group: Developer
Posts: 682
Joined: 26-September 07
Member No.: 47369



QUOTE (tedgo @ Jan 21 2010, 22:09) *
Thanks smile.gif
I knew it must be something easy...

Seems to work both.
Where are the differences?

replace(/\[.+\]/g,"") matches for example [x] but not [], whereas replace(/\[.*\]/g,"") matches also []. For the expression from marc2003 there has to be at least one character between the brackets.

Edit: Yirkha was faster. If it is supported by JScript /\[.*?\]/g should also work as a non-greedy expression.

This post has been edited by fbuser: Jan 21 2010, 22:29
Go to the top of the page
+Quote Post
tedgo
post Jan 21 2010, 22:25
Post #53





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



Thanks Yirkha smile.gif
(and of course thanks to fbuser and marc2003 too wink.gif)

Now my little lyrics panel will become perfect (in time...)

EDIT:
@fbuser
Your last suggestions works too (tried it with the foo[123]bar[456]2000 sample from Yirkha biggrin.gif)
Its shorter, so i'll use it.
Thanks again.

This post has been edited by tedgo: Jan 21 2010, 22:39
Go to the top of the page
+Quote Post
saivert
post Jan 21 2010, 23:06
Post #54





Group: Members
Posts: 167
Joined: 13-June 06
Member No.: 31801



The last.fm bios panel annoyed me with always starting the text half-way down in the panel so I fixed it.

fixed on_paint function:

CODE
function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
    if(window.InstanceType == 1) gr.DrawRect(0,0, ww, wh, 1.0, RGB(160,160,160));
    if(g_metadb) {
        try {
            if(fso.FileExists(folder + "\\" + filename)) {
                ts = fso.OpenTextFile(folder + "\\" + filename,1);
                g_text = ts.ReadAll();
                ts.close();
                
                if (g_need_calc) {
                    calc();
                } else {
                    //old: gr.GdiDrawText(g_text, g_font, g_textcolor,
                    //          5, g_offset, ww-5, wh - g_offset,  DT_WORDBREAK | DT_NOPREFIX);
                    gr.GdiDrawText(g_text, g_font, g_textcolor,
                          5, g_offset-(wh/2), ww-5, wh*2-g_offset,  DT_WORDBREAK | DT_NOPREFIX);
                }

            }
        } catch(e) {}
    }
}


This post has been edited by saivert: Jan 21 2010, 23:07


--------------------
http://foobar2000.saivert.com - foobar2000 component repository
Go to the top of the page
+Quote Post
marc2003
post Jan 21 2010, 23:12
Post #55





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



oh yuck. you shouldn't be loading the text file in on_paint like that - but it looks like you took the example i posted so that's entirely my fault for posting awful code. trouble is with these forums i can't edit my posts. crying.gif

the opening text file bit should be in on_metadb_changed().

sorry to be a nuisance, but could a moderator delete these posts.

http://www.hydrogenaudio.org/forums/index....st&p=680709
http://www.hydrogenaudio.org/forums/index....st&p=680754
http://www.hydrogenaudio.org/forums/index....st&p=680791

from now i'll post snippets on my own webspace so if i **** them up i can edit them without having to pester you guys. sorry.

This post has been edited by marc2003: Jan 21 2010, 23:16
Go to the top of the page
+Quote Post
TomBarlow
post Jan 21 2010, 23:13
Post #56





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



@tedgo: You might also want to delete the blank lines at the beginning of the text, try this as well:
CODE
replace(/^(\r?\n)+/g,"")

I'm not sure it's best to delete everything inside square brackets. You could use multi-line mode and only match square bracketed stuff at the beginning of each line:
CODE
replace(/^\[.*\]/mg,"")
I'm not using laziness because I've found some lyrics that have multiple time stamps at the beginning of some lines.

This post has been edited by TomBarlow: Jan 21 2010, 23:14
Go to the top of the page
+Quote Post
saivert
post Jan 21 2010, 23:24
Post #57





Group: Members
Posts: 167
Joined: 13-June 06
Member No.: 31801



QUOTE (TomBarlow @ Jan 21 2010, 22:10) *
Hi guys, I am currently trying to make some buttons that act more like the main menu...


Try this instead.

CODE
var colour = 0xffff0000;
//var menu_on = false;
var g_t = null;

function menu()
{
var d = new Date();
if (d.getTime()-g_t < 200) return;

var basemenu = window.CreatePopupMenu();
basemenu.AppendMenuItem(0x00000000, 1, "Hi");

//menu_on = true;
ret = basemenu.TrackPopupMenu(20, 60);
d = new Date();
g_t = d.getTime();
//menu_on = false;

if(ret) fb.trace("Hello there");

basemenu.Dispose();
}

function on_paint(gr)
{
gr.FillSolidRect(0,0,window.Width,window.Height,0xffffffff);
gr.FillSolidRect(20,20,40,40,colour);
}

function on_mouse_lbtn_down(x,y)
{
if(x>=20 && x<=60 && y>=20 && y<=60)
colour = 0xff0000ff;

window.Repaint();
}

function on_mouse_move(x, y)
{
if(x>=20 && x<=60 && y>=20 && y<=60)
colour = 0xff00ff00;
else
colour = 0xffff0000;

window.Repaint();
}

function on_mouse_lbtn_up(x, y)
{
if(x>=20 && x<=60 && y>=20 && y<=60)
{
menu();
colour = 0xff00ff00;
}
window.Repaint();
}

function on_mouse_leave()
{
//if(!menu_on)
// colour = 0xffff0000;
//window.Repaint();
//bscly!
}


This should do it I guess. It is indeed a hack since TrackPopupMenu is a blocking function and there is no proper way around that fact.

Notes:

Having a global variable which you set before opening the menu and reset after TrackPopupMenu returns doesn't work. It is of no use in the interim as the script simply doesn't run at that time. As long as the menu is visible (not dismissed) the script is waiting.
Maybe if WSH Panels had a callback function for menus so you call a non-blocking version of TrackPopupMenu and then handle the menu ID clicked in a callback function. This would require WSH Panel to handle the menu in a separate thread, which I'm not sure would work properly.


This post has been edited by saivert: Jan 21 2010, 23:30


--------------------
http://foobar2000.saivert.com - foobar2000 component repository
Go to the top of the page
+Quote Post
saivert
post Jan 21 2010, 23:38
Post #58





Group: Members
Posts: 167
Joined: 13-June 06
Member No.: 31801



QUOTE (marc2003 @ Jan 21 2010, 23:12) *
from now i'll post snippets on my own webspace so if i **** them up i can edit them without having to pester you guys. sorry.



Which is what was proposed earlier by Yirkha. Post scripts on pastebin (or your own webspace) or something instead of using ugly codeboxes on the forum.
Why not using gitshub ?

https://github.com/
lets people contribute on scripts online. versioning etc.


--------------------
http://foobar2000.saivert.com - foobar2000 component repository
Go to the top of the page
+Quote Post
marc2003
post Jan 21 2010, 23:48
Post #59





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



er yes. it was me who started the thread on the advice of Yirkha. the snippets in those posts are all on pastebin. dry.gif

the problem with pastebin is that making changes generates a new url so the links in my posts are still pointing towards the original duff code which i can't delete.
Go to the top of the page
+Quote Post
tedgo
post Jan 21 2010, 23:54
Post #60





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



@TomBarlow
You mean like this?
CODE
lyrics.replace(/\[.*?\]/g,"").replace(/^(\r?\n)+/g,"")

Seems to work...

This post has been edited by tedgo: Jan 21 2010, 23:55
Go to the top of the page
+Quote Post
TomBarlow
post Jan 22 2010, 00:25
Post #61





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



QUOTE (saivert @ Jan 21 2010, 22:24) *
Try this instead.

Thanks very much, it works well. Unfortunately I do need something under on_mouse_leave as it is called when the menu is opened, and I want my buttons to be in the 'down' state.

Tedgo, I think this should work?
CODE
.replace(/^(\[.*?\])+/mg,"").replace(/^(\r?\n)+/g,"")


It should turn this:

[1234][2345]tra la la [huh] la la

into this:

tra la la [huh] la la

As well as getting rid of empty lines at the start.
Go to the top of the page
+Quote Post
tedgo
post Jan 22 2010, 00:28
Post #62





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



Yes, it does.
Thanks again smile.gif
Go to the top of the page
+Quote Post
carmenm
post Jan 22 2010, 09:39
Post #63





Group: Members
Posts: 720
Joined: 24-November 05
From: Grenoble
Member No.: 25981



Hi everyone,

I wanted to show you guys what i am working on. SO here is a screenshot.

THere is an lot of features behind that config like:

- automatic download and caching of artists bio, big, similar artists small arts. And all that is done in the background.
- All other panels are informed when a new info related to them is available so that they update themselves
- the 2 art panels you see are actually the same config. Huge amount of options like my new fillImage algorithm that you can see in use in the artist panel. You can also add button, choose the position. The art panel allows you to use an external program(aad here) to change the current image. And the panel will automatically update itself afterwards.
- THe similar panels has a lot of options like a custom right click menu for each artists with multiple search engines and opening the artist radio with lastfm_radio!
- the biography panel doesnt have so much options yet
- All those back features are controled by one background config that does the works and can inform you of any errors.
- All those panels config are saved and loaded from ini in a smart way. Change a common option from the back wsh and all other panels will update themselves.

I would love to release it today but there are still things i want to change. Like more options for buttons and everything. And i also use the hours i spend using it to correct all the possible bugs(like with artists names). Yet i couldnt resist showing you what i have so far.
Hope you like it.

And i couldnt have done any of this without TPWang and marc2003 so thanks a lot to both of you!
Go to the top of the page
+Quote Post
Hitchhiker427
post Jan 22 2010, 09:50
Post #64





Group: Members
Posts: 232
Joined: 11-December 09
Member No.: 75848



That sounds great. I'm really looking forward to it!
Go to the top of the page
+Quote Post
allerlei
post Jan 22 2010, 10:51
Post #65





Group: Members
Posts: 38
Joined: 12-August 09
From: Nuremberg, Germa
Member No.: 72241



@carmenm: Absolutely great, that's what I'm looking for... so where you're going to release it?


--------------------
Stefan
http://allerlei.tk/
Go to the top of the page
+Quote Post
carmenm
post Jan 22 2010, 11:01
Post #66





Group: Members
Posts: 720
Joined: 24-November 05
From: Grenoble
Member No.: 25981



QUOTE (allerlei @ Jan 22 2010, 10:51) *
@carmenm: Absolutely great, that's what I'm looking for... so where you're going to release it?

To be true i could just release it now. It works great and is already very configurable. but I dont want to release it too fast and then have to make updates that will break your configs. So i just need a little time to make it more configurable.
In fact what i want is for you never to have to modify anything in the code itself.
I dont have so much time here at work.
Will do as much as i can tomorrow.
I hope to release it this we then.
Go to the top of the page
+Quote Post
allerlei
post Jan 22 2010, 11:59
Post #67





Group: Members
Posts: 38
Joined: 12-August 09
From: Nuremberg, Germa
Member No.: 72241



@carmenm: Good luck! I'm really looking forward to try your work. Especially the upper half of your design fits totally my expectations on a design I always tried to build on my own, but I hadn't this success (maybe based on a lack of time) you have - chapeau!


--------------------
Stefan
http://allerlei.tk/
Go to the top of the page
+Quote Post
nifferl7
post Jan 23 2010, 09:50
Post #68





Group: Members
Posts: 16
Joined: 2-October 09
From: Cincinnati
Member No.: 73665



wow carmenm, can't wait to try it out!
Go to the top of the page
+Quote Post
Shaun1
post Jan 23 2010, 10:48
Post #69





Group: Members
Posts: 27
Joined: 20-January 10
Member No.: 77319



(sorry, I originally posted this in the WSH Panel Mod thread without seeing this script discussion one and can't delete my post there)

I installed this plugin and used the MainMenuManager All-In-One sample so I can access the entire foobar menu just by clicking the panel. My question is, how do I make the wsh panel look better by making it display text "Menu" or an icon button?
Go to the top of the page
+Quote Post
marc2003
post Jan 23 2010, 12:19
Post #70





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



CODE
g_img = gdi.Image(fb.FoobarPath + "path\\to\\image.png");

function on_paint(gr) {
   gr.DrawImage(g_img, 0, 0, g_img.Width, g_img.Height, 0, 0, g_img.Width, g_img.Height);
}
Go to the top of the page
+Quote Post
Falstaff
post Jan 23 2010, 19:29
Post #71





Group: Members
Posts: 2800
Joined: 12-November 06
Member No.: 37463



QUOTE (T.P Wang @ Jan 20 2010, 08:28) *
This is a simple demo that using GdiDrawText() with scroll (mouse):

EDIT: Improved
EDIT2: Improved again, now both mouse whell and mouse drag work.

http://pastebin.ca/1758754


it doesn't work here on WSH Pnale Mod 1.3.0 beta 4 + foobar 1.0

[b]WSH Panel Mod (GUID: DD259EC0-0DA3-4856-BFD4-B8402D106108): initliased in 0.0000006 s
Error: WSH Panel Mod (GUID: DD259EC0-0DA3-4856-BFD4-B8402D106108): Erreur d'exécution Microsoft JScript:
Cet objet ne gère pas cette propriété ou cette méthode
Ln: 70, Col: 1
<no source text available>


forgot, it's ok with v1.3.0 final...

This post has been edited by Falstaff: Jan 23 2010, 19:32


--------------------
http://br3tt.online.fr/
Go to the top of the page
+Quote Post
Shaun1
post Jan 24 2010, 02:13
Post #72





Group: Members
Posts: 27
Joined: 20-January 10
Member No.: 77319



Thanks marc2003! I pasted it into the window and I changed "path\\to\\image.png" to "images\\image.jpg" to point it to my foobar\images directory. But it still just shows a blank window. Sorry, I have very little knowledge about this stuff.


QUOTE (marc2003 @ Jan 23 2010, 03:19) *
CODE
g_img = gdi.Image(fb.FoobarPath + "path\\to\\image.png");

function on_paint(gr) {
   gr.DrawImage(g_img, 0, 0, g_img.Width, g_img.Height, 0, 0, g_img.Width, g_img.Height);
}

Go to the top of the page
+Quote Post
marc2003
post Jan 24 2010, 02:44
Post #73





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



the script would error if the image wasn't found. not sure what's going on there.
Go to the top of the page
+Quote Post
Shaun1
post Jan 24 2010, 05:44
Post #74





Group: Members
Posts: 27
Joined: 20-January 10
Member No.: 77319



QUOTE (marc2003 @ Jan 23 2010, 17:44) *
the script would error if the image wasn't found. not sure what's going on there.


Doh, made a little typo when putting it in. Now works perfectly, thanks again marc!
Go to the top of the page
+Quote Post
saivert
post Jan 24 2010, 18:25
Post #75





Group: Members
Posts: 167
Joined: 13-June 06
Member No.: 31801



Updates the Bios panel:

http://gist.github.com/285324


Changes:
- Doesn't open text file in on_paint anymore
- Prints "#EOF" in red at end of text to avoid confusion as to where the text actually ends.

Plans:
- Proper scrollbar (coding a scrollbar from scratch should be feasible, but such a waste).
- Autoscrolling (need to use timer)

Actually adding real scrollbar to the panel window and then having some events in the js code for handling scrollbar messages would be better.
Might take a look at the WSH Panels Mod source and see what I can do.

I imagine something like:

CODE
var SCROLLBAR_NONE = 0;
var SCROLLBAR_VERTICAL = 1;
var SCROLLBAR_HORIZONTAL = 2;
// to get both use OR
window.enableScrollbar(SCROLLBAR_VERTICAL);
window.setScrollbarExtent(SCROLLBAR_VERTICAL, 100);
function on_scrollbar_message(which, pos) {

}

// etc...


I actually don't like that other separate Bios component. It is buggy and slow. Coding my own with WSH Panels Mod is much better.

This post has been edited by saivert: Jan 24 2010, 18:39


--------------------
http://foobar2000.saivert.com - foobar2000 component repository
Go to the top of the page
+Quote Post

126 Pages V  < 1 2 3 4 5 > » 
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: 24th September 2014 - 01:48