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

WSH Panel Mod script discussion/help

Reply #2075
@marc2003
Ah, thanks.

I tried on_metadb_changed and on_playback_edited.
The only thing is that then it will be updated when playcounts or any other info has changed.
But the cover doesn't seems to be recognised as an edit or a metadata change.
Too bad...

And thanks for clarification abour Async and V2
I thought the first may have performance advantages...
So i will stay on V2.

EDIT:
@Falstaff
on_metadb_changed?
I tried already but got no luck...
How did you did it?

And about Async/V2:
I guess its useful for playlists or like marc2003 said if one wants the filepath.
But i think i'll stick on V2 for my cover script

WSH Panel Mod script discussion/help

Reply #2076
"But the cover doesn't seems to be recognised as an edit or a metadata change.
Too bad..."

it does for me, just tested on adding image with Context menu "Tagging" > "Attach pictures" or "Remove pictures"

EDIT: here is the FULL script!

Code: [Select]
// ==PREPROCESSOR==
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

function on_metadb_changed(metadb_or_metadbs, fromhook) {
    fb.trace("metadb_changed!");
};


open console, and check if it logs the trace on actions discribes above

HTH

WSH Panel Mod script discussion/help

Reply #2077
are you sure? does nothing for me....

WSH Panel Mod script discussion/help

Reply #2078
No, it doesn't...
It only gives the message on playback starting or i edit some tags, but not when i edit the attached pictures.
Tried it several times (with fb.trace and fb.ShowPopupmessage, no luck)

WSH Panel Mod script discussion/help

Reply #2079
yep i'm sure, weird you don't have it working .... tested with DUI

WSH Panel Mod script discussion/help

Reply #2080
Nope...
In DUI the same. Tried it still - no luck.

Have you opened console before hit play?
Then you'll see the message comes when opening the first track, not from editing the attached pictures.

EDIT:
The only message that comes to console after attached/removed a picture is:
Reopening played file after update: "C:\Users\Gerhard\Music\Image\Bonus Tracks\001. xxx - xxx.wv"

WSH Panel Mod script discussion/help

Reply #2081
Falstaff

When adding/removing cover art, on_metadb_changed gets called only if playlist is autoplaylist.

WSH Panel Mod script discussion/help

Reply #2082
Oh, yes.
Works with autoplaylists but not with normal ones.
As i said: too bad...

Another strage thing i realized: this fb.trace will be called three times on every start of a new track in my config, although no metadata is changed...
Guess its really time to rewrite my scripts...

EDIT:
Ah, found the bad one: not my scripts at all but Biography view panel!
If i delete it from my config, on_metadb_changed() won't called anymore when playback of a track starts.

WSH Panel Mod script discussion/help

Reply #2083
that's normal. you usually have on_item_focus_change (which in turn calls on_metadb_changed) in these 2 callbacks.

on_playback_stop
on_playback_new_track

it gets called a 3rd time if you have cursor follows playback enabled as well.

depending on what your on_metadb_changed function does, you can have it return if the metadata is the same as before. just store and compare it. i use this for my artist related scripts. if a user is half way down scrolling through a long bit of text, a selection or track change isn't going to reset the position so long as the artist is the same.

WSH Panel Mod script discussion/help

Reply #2084
No, it shouldn't.
It should only "work" when metadata is changed not when focus has changed

And without biograhy view panel this console message does only appear when metadata is changed not when playback starts/stops or focus changes.
So its not my scripts fault (yippieh . No need to rewrite my whole scripts)

EDEIT:
No forget it...
Of course metadata changes when a new track is in focus/playback, but a script that only contains the code snippet posted by falstaff shouldn't give a message to console then.
Because the file and its metadata itself aren't touched by the snippet and as long no other script changes tags or infos this message shouldn't appear.
In other scripts containing on_metadb_changed, on_playback_new_track and on_playback_stop where metadata changes are asked of course this message should appear.
So i was mistakable, sorry

WSH Panel Mod script discussion/help

Reply #2085
we must do things differently then. of course on_metadb_changed only works as a callback when tags change. but as i explained above, i have other events/callbacks trigger it as well.

WSH Panel Mod script discussion/help

Reply #2086
See my edit (i'm always too fast in writing my thoughts down and that for easy mistakable  )


WSH Panel Mod script discussion/help

Reply #2088
Not for me...
Only when the playing file reaches one minute and playcount updates on_metadb_changed is called and the message appears.
And i tried several skins (my own, my new design i'm working at, HiFoo, foo_tunes, fooRazor) and blank CUI and DUI with your code snippet.
Still no luck...

WSH Panel Mod script discussion/help

Reply #2089
Hello, everyone! I want to use two colors in one DrawString line, but I can't find the way to do this, can anyone help me?
In other computer language it can be use in "|cffFF0000XXX|r OOO" but I don't know the way in WSH.
PS. I use one line because I want the string align in center.

WSH Panel Mod script discussion/help

Reply #2090
the only way i know of to do that requires that you use 2 lines of DrawString code.

Quote
PS. I use one line because I want the string align in center.


there's no reason why it can't be done with 2 lines. calculate the width of the entire text. subtract that from the overall width of your "text area". divide that by 2. that gives x for the first bit of text. after calculating the width of the first colour text (plus a space), add that on to give the value of x for the second colour.

obviously this method would be useless for text spread over multiple lines but it should work fine for anything on a single line.

WSH Panel Mod script discussion/help

Reply #2091
Maybe someone knows an answer for:
How to draw something like this in wsh panel mod:



But amount of squares depending on the width of a panel.
(the colour depends on ui settings, otherwise i would use png image).

WSH Panel Mod script discussion/help

Reply #2092
Code: [Select]
function on_paint(gr) {

    var w = 20;
    var l = (ww - w) / w;

    for (var i = 0; i < l; i++) {

        for (var j = 0; j < 10; j++) {
            if (i % 2 == 1 && j % 2 == 1) gr.FillSolidRect(w * i, w * j, w, w, 0xff000000);

        }

    }
}

function on_size() {

    ww = window.Width;
    wh = window.Height;

}

WSH Panel Mod script discussion/help

Reply #2093
Wow, this was fast
I'll try it asoon.

WSH Panel Mod script discussion/help

Reply #2094
too slow ... but i give it to you too

Code: [Select]
function on_size() {
    ww = window.Width;
    wh = window.Height;
}

function on_paint(gr) {
    drawSquares(gr, 30, 5, ww, wh);
};

function drawSquares(gr, squareSize, paddingSize, panelW, panelH) {
    // square colour
    var colour = 0xffff0000;
    // step size
    var stepSize = squareSize + paddingSize;
    // # of square in a line
    var totalsq = Math.ceil(panelW / stepSize);
    // # of lines to draw
    var totalrow = Math.ceil(panelH / stepSize);
    
    // let's draw the matrix
    for(var j=0; j < totalrow; j++) {
        for(var i=0; i < totalsq; i++) {
            gr.FillSolidRect(i*stepSize, j*stepSize, squareSize, squareSize, colour);
        }
    }
}

WSH Panel Mod script discussion/help

Reply #2095
edit: ah too slow as well.


WSH Panel Mod script discussion/help

Reply #2097
Wow, thanks Falstaff
This is nearly exactly what i want.
One day if i understand this code i maybe found out how i get the a square at half width at the end

EDIT: Damn i'm that silly.
Understood this code now and its no problem to get what i want 
Many thanks again

WSH Panel Mod script discussion/help

Reply #2098
ok, replace drawSquares function by this one to get the center thing:

Code: [Select]
function drawSquares(gr, squareSize, paddingSize, panelW, panelH) {
    // square colour
    var colour = 0xffff0000;
    // step size
    var stepSize = squareSize + paddingSize;
    // # of square in a line
    var totalsq = Math.ceil(panelW / stepSize);
    // # of lines to draw
    var totalrow = Math.ceil(panelH / stepSize);
    // padding to center
    var hpad = Math.round( ((stepSize * totalsq) - panelW - paddingSize) / 2);
    var vpad = Math.round( ((stepSize * totalrow) - panelH - paddingSize) / 2);
    
    // let's draw the matrix
    for(var j=0; j < totalrow; j++) {
        for(var i=0; i < totalsq; i++) {
            gr.FillSolidRect(i*stepSize - hpad, j*stepSize - vpad, squareSize, squareSize, colour);
        }
    }
}

WSH Panel Mod script discussion/help

Reply #2099
Hi, I would like to modify marc2003's Art Reader script so that when I drag and drop songs from the library to the Art Reader panel, it adds the songs at the end of the active playlist. Is this possible?