The title of this topic is "WSH Panel Mod script discussion/help"
So, maybe this is the best place to ask...
[!--sizeo:4--][span style=\"font-size:14pt;line-height:100%\"][!--/sizeo--]First question:[/size]
I tried to make my own script based on few other codes I found, my script shows the metadata of currently playing song, the metadata successfully appeared but why did the ampersand sign (&) in song title changed into underline when I already specify DT_NOPREFIX = 0x00000800; ?? Even DT_END_ELLIPSIS = 0x00008000; is not functioning??
This is how it appeared:

The title for the song is "Mosh & Dive" but it appeared "Mosh _Dive".
This is as seen on Wikipedia, the title (second song) contained an ampersand:

This is the metadata opened via "Properties" in foobar2000

This is my code:
// Use with GdiDrawText()
// {{
var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_END_ELLIPSIS = 0x00008000;
// }}
var albumartist = title = album = trackartist = year = genre = bitrate = samplerate = codec = tracknumber = metadata = "";
function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
var textFont = gdi.Font("Yu Gothic", 12, 1);
var textFont2 = gdi.Font("Arial", 14, 1);
var textColour = RGB(255, 0, 128);
var textColour2 = RGB(100, 0, 100);
function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, RGB(0, 0, 0));
var info = trackartist + "\n" + title + "\n" + album + "\n" + albumartist + "\n" + year + "\n" + genre + "\n" + bitrate + "\n" + samplerate + "\n" + codec + "\n" + tracknumber;
var whatelse = metadata;
gr.GdiDrawText(info, textFont, textColour, 10, 20, ww - 20, wh - 10);
gr.GdiDrawText(whatelse, textFont2, textColour2, 5, 1, ww - 20, wh - 10);
}
function update() {
if (fb.IsPlaying) {
metadata = fb.TitleFormat("Now playing '('English Metadata')'").Eval(true);
trackartist = fb.TitleFormat("Artist Name $if(%artist%,%artist%,Unknown)").Eval(true);
title = fb.TitleFormat("Track Title $if(%album%,$iflonger(%album%,40,$left(%album%,21) ...,%album%),Unknown)").Eval(true);
album = fb.TitleFormat("Album Title $if(%album%,$iflonger(%album%,40,$left(%album%,21) ...,%album%),Unknown)").Eval(true);
albumartist = fb.TitleFormat("Album Artist $if(%album artist%,%album artist%,$if(%artist%,%artist%,Unknown))").Eval(true);
year = fb.TitleFormat("Release Year $if(%date%,$year(%date%),Unknown)").Eval(true);
genre = fb.TitleFormat("Genre $if(%genre%,%genre%,Unknown)").Eval(true);
bitrate = fb.TitleFormat("Bitrate %bitrate%' kbps'").Eval(true);
samplerate = fb.TitleFormat("Sample Rate %samplerate% Hz").Eval(true);
codec = fb.TitleFormat("Codec %codec% ['('%codec_profile%')']").Eval(true);
tracknumber = fb.TitleFormat("Track $if(%tracknumber%,%tracknumber%,00) of $if(%totaltracks%,%totaltracks%,Unknown) $if(%discnumber%,'(' Disc %discnumber% $if(%totaldiscs%, of %totaldiscs%,)')',)").Eval(true);
} else {
bitrate = genre = album = title = year = trackartist = samplerate = codec = tracknumber = "";
metadata = fb.TitleFormat("Now playing '('English Metadata')'").Eval(true);
albumartist = fb.TitleFormat("No song is playing right now!").Eval(true);
}
window.Repaint();
}
if (fb.IsPlaying) {
update();
}
function on_size() {
ww = window.Width;
wh = window.Height;
}
function on_playback_new_track() {
update();
}
function on_playback_stop(reason) {
if (reason != 2) {
update();
}
}
function on_playback_dynamic_info() {
update();
}
function on_playback_dynamic_info_track() {
update();
}
Since DT_END_ELLIPSIS = 0x00008000; is not functioning, I had to use
$if(%album%,$iflonger(%album%,40,$left(%album%,21) ...,%album%),Unknown)
because I have few songs which contained in a long name single-album.
The single-album name is written in Japanese and it is 76 characters long, there's English Wikipedia article for it: Suzukake no Ki no Michi de "Kimi no Hohoemi o Yume ni Miru" to Itte Shimattara Bokutachi no Kankei wa Dō Kawatte Shimau no ka, Bokunari ni Nannichi ka Kangaeta Ue de no Yaya Kihazukashii Ketsuron no Yō na Mono.
If there's something I missed inside the code, please inform me.
[!--sizeo:4--][span style=\"font-size:14pt;line-height:100%\"][!--/sizeo--]Second question[/size]
I want to create another script that only displays properties of selected/highligted song(s) from playlist. Can anyone tell me what code I suppose to use?
For example, if I select only one then it will display properties for that song, but if I selected multiple then it will display all properties for those selected??
The things I want to display in the combined properties are:
Items selected (Number of items selected)
Artist (List of artists of items selected, separated by comma)
Track (List of tracks of items selected, separated by comma)
Album (List of albums of items selected, separated by comma)
Duration (Total duration of items selected)
Sample rate (List of sample rate of items selected, separated by comma)
Channels (Actually all my songs are stereo, but it's nice to see it displayed)
Bitrate (Display the range, lowest - highest)
Codec (Example: MP3 - CBR, MP3 - VBR, FLAC)
Encoding (Example: lossy, lossless)
Note: I don't want to combine the first script (that display metadata for currently playing song) and the script that I want to make in second question (that display metadata for selected/highlighted song).
I'll follow this topic, thank you very much!