AHAPXICT, у меня без d делает перенос:
gr.GdiDrawText и gr.DrawString по-разному выводят текст:
а gr.CalcTextWidth правильно считает ширину только для gr.GdiDrawText
поэтому для gr.DrawString я немного увеличил считаемую ширину.
Список разделов › foobar2000 › Секреты foobar2000
Вызов настроек таймера правым кликомВы ее доработали до этого (что значит как )
Доброе!seriousstas, не спится? Доброе утро.
// ==PREPROCESSOR==
// @name "properties"
// @author "kgena_ua"
// ==/PREPROCESSOR==
function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
var g_font = gdi.Font("Areal",12,0);
var g_font2 = gdi.Font("Tahoma",10,0);
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_RIGHT = 0x00000002;
DT_WORD_ELLIPSIS = 0x00040000;
DT_SINGLELINE = 0x00000020;
var ww, wh;
//var color1 = RGB(140,164,179);
var color1 = RGB(140,140,140);
var color2 = RGB(255,255,225);
var color3 = RGB(90,90,90);
var tfarray = [];
var widestring = [];
var g_tooltip = window.CreateTooltip();
var ttText = "";
g_tooltip.SetMaxWidth(300);
window.GetProperty("skip",0);
var name, value, measure, t_height;
var path = "", title;
var g_drag = false;
var g_drag_y = 0;
var s = 0;
var col1 = 10;
var col2 = 115;
var col3;
var metadb;
on_item_focus_change();
function on_paint(gr) {
gr.FillSolidRect (0, 0, ww, wh, RGB(30,30,30));
tfarray = [];
for (j = 0; j < tfname.length; j++) {
group = false;
// if (tfname[j].search('group') >= 0 || tfname[j] == "\r\n" ) group = true;
if (tfname[j].search('group') >= 0 || tfname[j] == "line" ) group = true;
if ((path.substr(0,4) == "http" || path.substr(0,4) == "mms:") && tfname[j] != "%genre%") {
value = fb.TitleFormat("[" + tfname[j] + "]").Eval();
} else {
if (metadb) value = fb.TitleFormat("[" + tfname[j] + "]").EvalWithMetadb(metadb);
}
if ( window.GetProperty("skip") == 1) {
if (value || group) tfarray.push(tfname[j]);
} else {
tfarray.push(tfname[j]);
}
}
t_height = gr.CalcTextHeight("text", g_font) + 2;
widestring = [];
for (i = 0; i < tfarray.length; i++) {
line = false;
group = false;
measure = "";
row = i * t_height + s;
if (tfarray[i].search('line') >= 0) line = true;
if (tfarray[i].search('group') >= 0) group = true;
name = tfarray[i].replace(/[%\$\(\)]|info|meta|group |line|lastfm/g,'').replace(/_/g,' ');
if ((path.substr(0,4) == "http" || path.substr(0,4) == "mms:") && tfarray[i] != "%genre%") {
value = fb.TitleFormat("[" + tfarray[i] + "]").Eval();
} else {
if (metadb) value = fb.TitleFormat("[" + tfarray[i] + "]").EvalWithMetadb(metadb);
}
if (name && value){
if (tfarray[i] == "$info(bitrate)") measure = " kbps";
if (tfarray[i] == "$info(samplerate)") measure = " Hz";
if (tfarray[i] == "$info(bitspersample)") measure = " bps";
if (tfarray[i] == "$info(channels)") measure = " ch";
if (tfarray[i] == "$meta(rating)") measure = " (tag)";
}
line_row = row + t_height / 2;
if (line) gr.DrawLine(col1, line_row, ww - col1, line_row, 1, color3);
gr.GdiDrawText(name, group ? g_font2 : g_font, group ? color3 : color1, col1, row, ww - col1 * 2, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
t_width2 = gr.CalcTextWidth(value, g_font);
col3 = col2 + t_width2;
if (t_width2 > ww - col2 - col1) { widestring.push(row,tfarray[i])};
gr.GdiDrawText(value, g_font, color2, col2, row, ww - col2 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
gr.GdiDrawText(measure, g_font, color1, col3, row, ww - col3 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
}
g_tooltip.Text = ttText;
if (ttText) g_tooltip.Activate();
}
function on_mouse_lbtn_down(x, y) {
g_drag = true;
g_drag_y = (y - s);
}
function on_mouse_lbtn_up(x, y) {
g_drag = false;
}
function on_mouse_move(x, y) {
window.SetCursor(32649);
ttText = "";
for (i = 0; i < widestring.length; i = i + 2) {
if (y > widestring[i] && y < widestring[i] + t_height && x > col2) {
if (path.substr(0,4) == "http" || path.substr(0,4) == "mms:") {
ttText = fb.TitleFormat("[" + widestring[i + 1] + "]").Eval();
} else {
if (metadb) ttText = fb.TitleFormat("[" + widestring[i + 1] + "]").EvalWithMetadb(metadb);
}
if (ttText) return;
}
}
if (g_drag) {
if (s <= 0 && (tfarray.length * t_height) >= wh) {s = y - g_drag_y};
applyDelta();
}
if (s == 0 || s == wh - tfarray.length * t_height) g_drag_y = (y - s);
window.Repaint();
}
function on_mouse_wheel(step) {
if (s <= 0 && tfarray.length * t_height >= wh) {s = s + step * t_height};
applyDelta();
}
function applyDelta() {
s = s > 0 ? 0 : s;
s = s < (wh - tfarray.length * t_height) && s < 0 ? (wh - tfarray.length * t_height) : s;
window.Repaint();
}
function on_mouse_leave() {
window.SetCursor(32512);
g_tooltip.Deactivate();
window.Repaint();
}
function on_metadb_changed() {
path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
// title = fb.Titleformat("%title%").EvalWithMetadb(metadb);
// artist = fb.Titleformat("%artist%").EvalWithMetadb(metadb);
}
function on_item_focus_change() {
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem() ,true;
if (metadb) on_metadb_changed();
window.Repaint();
}
function on_playback_new_track(metadb) {
on_item_focus_change();
}
function on_playback_time(time){
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_stop() {
window.Repaint();
}
var wh_old;
function on_size() {
ww = window.Width;
wh = window.Height;
if (wh != wh_old && s < 0) {
s = wh >= wh_old ? s + 1 : s;
wh_old = wh;
}
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
_menu.AppendMenuItem(MF_ENABLED, 1, "skip if empty");
_menu.CheckMenuItem(1, window.GetProperty("skip"));
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
// if (ShiftDown) {
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, 10, "Reload");
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, 20, "Properties");
_menu.AppendMenuItem(0x00000000, 30, "Configure ...");
// }
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 1:
window.SetProperty("skip", window.GetProperty("skip") == 0 ? 1 : 0);
if (s < 0) s = 0;
break;
case 10:
window.Reload();
break;
case 20:
window.ShowProperties();
break;
case 30:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
var tfname = new Array(
"%artist%",
"%title%",
"%album%",
"%date%",
"%genre%",
"%composer%",
"%performer%",
"%publisher%",
"%album artist%",
"%track number%",
"%totaltracks%",
"%discnumber%",
"%totaldiscs%",
"%comment%",
"%rating%",
"$meta(rating)",
"line",
"group G E N E R A L",
"$info(samplerate)",
"$info(channels)",
"$info(bitspersample)",
"$info(bitrate)",
"%codec%",
"$info(codec_profile)",
"$info(encoding)",
"%length%",
"$info(tool)",
"$info(cue_embedded)",
"line",
"group L O C A T I O N",
"%filename_ext%",
//"%path%",
"$directory_path(%path%)",
"%subsong%",
"%filesize_natural%",
"%last_modified%",
"%folder name%",
"line",
"group P L A Y B A C K S T A T I S T I C S",
"%play_count%",
"%first_played%",
"%last_played%",
"%added%",
"line",
"group L A S T F M",
"%lastfm_bio%",
"%lastfm_similar_artist%",
"%lastfm_artist_playcount%",
"%lastfm_artist_listeners%",
"%lastfm_album_playcount%",
"%lastfm_album_listeners%",
"%lastfm_album_content%"
);
var VK_PGUP = 0x21;
var VK_PGDN = 0x22;
var ttt = 0;
function on_key_down(vkey) {
switch (true) {
case (vkey == VK_PGUP):
ttt = ttt + 1;
break;
case (vkey == VK_PGDN):
ttt = ttt - 1;
break;
}
window.Repaint();
}
// ==PREPROCESSOR==
// @name "change file attributes"
// @author "kgena_ua"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
var color = {
0:RGB(255,255,220),
1:RGB(102,255,102)
};
var file_path, file_name, file_n = [],attributes, verify;;
var txt1, txt2;
var count;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var metadb;
on_item_focus_change();
function on_paint(gr){
gr.FillSolidRect (0, 0, ww, wh, RGB(50,50,50));
gr.GdiDrawText("change file attributes", font, RGB(100,100,100), 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}
function on_item_focus_change() {
txt1 = "";
txt2 = "";
file_n = [];
verify = 0;
metadb = fb.GetSelections().Count > 1 ? fb.GetSelections() : fb.GetFocusItem();
if (metadb) on_metadb_changed();
}
var v;
function on_metadb_changed() {
count = fb.GetSelections().Count;
if (metadb.Count == null){
file_path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
file_name = fb.Titleformat("%filename_ext%").EvalWithMetadb(metadb);
file_n.push(file_name);
try {
file = fso.GetFile(file_path);
attributes = file.Attributes;
verify = attributes;
txt1 = "file is ";
} catch(e) {};
} else {
for (var i = 0; i < count; i++) {
item = fb.GetSelections().Item(i);
file_path = fb.Titleformat("%path%").EvalWithMetadb(item);
file_name = fb.Titleformat("%filename_ext%").EvalWithMetadb(item);
try {
file = fso.GetFile(file_path);
attributes = file.Attributes;
verify = verify + file.Attributes;
file_n.push(file_name);
} catch(e) {};
}
file_n = file_n.join("\r\n");
txt1 = "files are ";
verify = Math.round(verify / count);
}
switch (verify) {
case 32:
txt2 = "READ - WRITE"; break;
case 33:
txt2 = "READ - ONLY"; break;
}
window.Repaint();
}
function change_attributes(k) {
for (var i = 0; i < count; i++) {
item = fb.GetSelections().Item(i);
file_path = fb.Titleformat("%path%").EvalWithMetadb(item);
try {
file = fso.GetFile(file_path);
file.Attributes = k;
} catch(e) {};
}
}
function on_playback_new_track(metadb) {
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_mouse_lbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
RO = verify == 33 ? MF_ENABLED : MF_GRAYED;
RW = verify == 32 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(RO, i++, "read write");
_menu.AppendMenuItem(RW, i++, "read only");
ret = _menu.TrackPopupMenu(x,y);
if (ret == 0) return;
switch (ret) {
case 1:
if (metadb) change_attributes(32);
on_item_focus_change();
break;
case 2:
if (metadb) change_attributes(33);
on_item_focus_change();
break;
}
_menu.Dispose();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
Плавного скрола добится не получается мотает минимум по одной строчке (из-за этого небольшие рывки) и значения ва вообще нужно смотреть Ваш скрипт WSH playlist в скроллинге
Интересно ... речь про тот, что делался под тач , или что-то "с нуля" ?И в планах у меня скрипт "поиск"
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",11,1);
var ww,wh;
DT_LEFT = 0x00000000;
DT_WORD_ELLIPSIS = 0x00040000;
var path;
var dir_name = fb.FoobarPath + "\\Logos\\";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file_name, g_img;
var g_img_default = gdi.Image(dir_name + "no_pic.png");
//var ext = Array ("jpg","jpeg","png","gif","bmp","tiff");
var files = [];
var metadb;
on_item_focus_change();
function on_paint(gr){
g_img = gdi.Image(fb.FoobarPath + "\\Logos\\" + file_name);
if (path.substr(0,4) == "http" || path.substr(0,4) == "mms:") {
if (!g_img) g_img = g_img_default;
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
var scale = Math.min(scale_w, scale_h);
var pos_x = 0;
var pos_y = 0;
if (scale_w < scale_h) pos_y = (wh - g_img.Height * scale) / 2;
else if (scale_w > scale_h) pos_x = (ww - g_img.Width * scale) / 2;
// g_img = g_img.CreateRawBitmap();
// gr.GdiDrawBitmap(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
gr.DrawImage(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
}
// gr.GdiDrawText(files, font, RGB(20,20,20), 10, 10, ww - 20, wh, DT_LEFT | DT_WORD_ELLIPSIS );
// gr.GdiDrawText(path, font, RGB(20,20,20), 10, 20, ww - 20, wh, DT_LEFT | DT_WORD_ELLIPSIS );
// gr.GdiDrawText(" - " + file_name + " - ", font, RGB(20,20,20), 10, 30, ww - 20, wh, DT_LEFT | DT_WORD_ELLIPSIS );
// gr.GdiDrawText(title, font, RGB(20,20,20), 10, 40, ww - 20, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
function on_item_focus_change() {
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (metadb) on_metadb_changed();
}
function on_playback_new_track(metadb) {
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_stop() {
window.Repaint();
}
function on_metadb_changed() {
path = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
title = fb.Titleformat("%title%").EvalWithMetadb(metadb);
file_name = "";
get_files();
for (var i = 0; i < files.length; i++){
var file = files[i].replace(/.jpg|.jpeg|.png|".gif"|.bmp|.tiff/g,'');
// if (path.toLowerCase(path).search(file) > 0) file_name = files[i];
if (title.toLowerCase(title).match(file) != null) file_name = files[i];
}
window.Repaint();
}
function get_files() {
var e = new Enumerator( fso.GetFolder(dir_name).Files );
while( !e.atEnd() ) {
var name = e.item().Name;
name = name.toLowerCase(name);
files.push( name );
e.moveNext();
}
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
Microsoft JScript:
'path' - есть null или не является объектом
File: <main>
Ln: 23, Col: 5
<source text only available at compile time>
"Scripting Engine Initialization Failed ({5103221B-D8DA-4A08-8050-B289628F5E03}, CODE: 0x80020101)kgena_ua:Отображение логотипа станции при проигрывании ИРадио.
MC Web, да, я просто вытащил из ИНета парочку изображений.MC Web:необходимо иметь библиотеку изображений в папке Logos
Да, это наверное сложно, если вообще реально.MC Web:изображение с сайта радиостанции.
В принципе может и реально.kgena_ua:Да, это наверное сложно, если вообще реально.
Респект !!!Скрипт на тестирование.
Вернуться в Секреты foobar2000