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

WSH Panel Mod script discussion/help

Reply #50
Where are the differences?
The difference is in the quantifier, * for 0 or more and + for 1 or more.
But [font= "Courier New"]/\[[^\]]*\]/g[/font] 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.

WSH Panel Mod script discussion/help

Reply #51
Thanks 
I knew it must be something easy...

Seems to work both.
Where are the differences?

replace(/\[.+\]/g,"") matches for example
  • 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.

WSH Panel Mod script discussion/help

Reply #52
Thanks Yirkha
(and of course thanks to fbuser and marc2003 too )

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 )
Its shorter, so i'll use it.
Thanks again.

WSH Panel Mod script discussion/help

Reply #53
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: [Select]
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) {}
    }
}

WSH Panel Mod script discussion/help

Reply #54
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. 

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.

WSH Panel Mod script discussion/help

Reply #55
@tedgo: You might also want to delete the blank lines at the beginning of the text, try this as well:
Code: [Select]
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: [Select]
replace(/^\[.*\]/mg,"")
I'm not using laziness because I've found some lyrics that have multiple time stamps at the beginning of some lines.

WSH Panel Mod script discussion/help

Reply #56
Hi guys, I am currently trying to make some buttons that act more like the main menu...

Try this instead.

Code: [Select]
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.

 

WSH Panel Mod script discussion/help

Reply #57
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.

WSH Panel Mod script discussion/help

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

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.

WSH Panel Mod script discussion/help

Reply #59
@TomBarlow
You mean like this?
Code: [Select]
lyrics.replace(/\[.*?\]/g,"").replace(/^(\r?\n)+/g,"")

Seems to work...

WSH Panel Mod script discussion/help

Reply #60
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: [Select]
.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.

WSH Panel Mod script discussion/help

Reply #61
Yes, it does.
Thanks again

WSH Panel Mod script discussion/help

Reply #62
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!

WSH Panel Mod script discussion/help

Reply #63
That sounds great.  I'm really looking forward to it!

WSH Panel Mod script discussion/help

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

WSH Panel Mod script discussion/help

Reply #65
@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.

WSH Panel Mod script discussion/help

Reply #66
@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!

WSH Panel Mod script discussion/help

Reply #67
wow carmenm, can't wait to try it out!

WSH Panel Mod script discussion/help

Reply #68
(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?

WSH Panel Mod script discussion/help

Reply #69
Code: [Select]
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);
}

WSH Panel Mod script discussion/help

Reply #70
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

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...

WSH Panel Mod script discussion/help

Reply #71
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.


Code: [Select]
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);
}


WSH Panel Mod script discussion/help

Reply #72
the script would error if the image wasn't found. not sure what's going on there.

WSH Panel Mod script discussion/help

Reply #73
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!

WSH Panel Mod script discussion/help

Reply #74
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: [Select]
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.