macarych,
Доброго времени суток,makarych!
Ссылка Ваша на буквари по WSH нерабочая.Не сохранились ли у Вас ещё где?
Список разделов › foobar2000 › Секреты foobar2000
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
gr.FillGradRect(0, 0, ww, 14, 90,RGBA(0,0,0,10), RGBA(225,255,155,70));
gr.FillGradRect(0, 0, ww, 14,0,RGBA(0,0,0,50), RGBA(225,255,155,40),.5);
if(fso.FileExists(tmp_b_path + files[selected]) ) {
g_img = gdi.Image(tmp_b_path + files[selected]);
var scale_w = (ww-2) / g_img.Width;
var scale_h = ww / 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 = (ww - g_img.Height * scale) / 2;
else if (scale_w > scale_h) pos_x = (ww - g_img.Width * scale) / 2;
g_img = g_img.CreateRawBitmap();
hs=g_img.Height * scale;
gr.GdiDrawBitmap(g_img, 1+pos_x, 13, g_img.Width * scale, hs, 0, 0, g_img.Width, g_img.Height);
gr.FillGradRect(0, hs+10, ww, 16,90,RGBA(0,0,0,50), RGBA(225,255,155,40));
gr.FillGradRect(0, hs+10, ww, 16,0,RGBA(0,0,0,70), RGBA(225,255,155,40),.5);
//gr.DrawImage(lastfm_img, ww - 48, hs+9, 50, 18, 0, 0, 50, 18);
N_Text=selected + 1 + " (" + files.length + ")"
gr.GdiDrawText(N_Text, a_font, a_color, 4, hs+14, 50, 21, DT_LEFT | DT_WORD_ELLIPSIS );//к-во картинок
gr.GdiDrawText("смена картинок - прокруткой", a_font, 0x44ccee77, 41, hs+14, ww - 15, 21, DT_LEFT | DT_WORD_ELLIPSIS );
} else {
gr.GdiDrawText("[ничего не выбрано]", a_font, 0x44ccee77, 0, 0, ww, ww, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
}
gr.GdiDrawText(artist, a_font, a_color, 5, 0, ww, 21, DT_LEFT | DT_WORD_ELLIPSIS );
/* /// Draw ""TextBio""
for (var i = 0; i < b_text_height; i++) {
gr.GdiDrawText(b_text_array[i + s], b_font, b_color, col, ww+22 + b_text_row_height * i, ww, wh, DT_LEFT );
} */
}
/////////////////////// бегущая строка - сикбар v.10.12.2010 \\\\\\\\\\\
//San_dr http://forum.oszone.net && Zin-Uru http://foobar2000.ru/forum\\
//var font = gdi.Font("Tahoma", 17, 1);
//var font = gdi.Font("AGOpus", 17, 0);
// ==PREPROCESSOR==
// @name "Date Modoki"
// @version "1.0.0"
// @author "tomato111"
// ==/PREPROCESSOR==
//年 %YYYY 4桁
//年 %YY 2桁
//年 %Y 2桁(桁合わせ無し)
//月 %MM
//月 %M (桁合わせ無し)
//月 %ME 英語 フル
//月 %Me 英語 略字
//日 %DD
//日 %D (桁合わせ無し)
//時 %hh
//時 %h(桁合わせ無し)
//分 %mm
//分 %m(桁合わせ無し)
//秒 %ss
//秒 %s(桁合わせ無し)
//曜日 %WJ 日本 フル
//曜日 %Wj 日本 略字
//曜日 %WE 英語 フル
//曜日 %We 英語 略字
//========
// properties
//========
var prop = new function () {
this.Style = {
_format: window.GetProperty('Style._format', '%hh:%mm:%ss (%We) %DD.%MM.%YYYY'),
Color:
{
_0_Default: window.GetProperty('Style.Color._0_Default', 'RGBA(0,0,0,255)'),
_1_Year: window.GetProperty('Style.Color._1_Year', 'RGBA(0,0,0,255)'),
_2_Month: window.GetProperty('Style.Color._2_Month', 'RGBA(0,0,0,255)'),
_3_Day: window.GetProperty('Style.Color._3_Day', 'RGBA(0,0,0,255)'),
_4_Hour: window.GetProperty('Style.Color._4_Hour', 'RGBA(0,0,0,255)'),
_5_Minute: window.GetProperty('Style.Color._5_Minute', 'RGBA(0,0,0,255)'),
_6_Second: window.GetProperty('Style.Color._6_Second', 'RGBA(0,0,0,255)'),
_7_DayOfWeek: window.GetProperty('Style.Color._7_DayOfWeek', 'RGBA(0,0,0,255)'),
_8_DayOfWeek_sat: window.GetProperty('Style.Color._8_DayOfWeek_sat', 'RGBA(0,0,200,255)'),
_9_DayOfWeek_sun: window.GetProperty('Style.Color._9_DayOfWeek_sun', 'RGBA(200,0,0,255)'),
Background: window.GetProperty('Style.Color.Background', 'RGBA(255,255,255,0)')
},
Font_Family: window.GetProperty('Style.Font_Family', 'Arial'),
Font_Size: window.GetProperty('Style.Font_Size', 20),
Font_Bold: window.GetProperty('Style.Font_Bold', false)
};
};
//========
//============================================
//== Prototype ==================================
//============================================
Function.prototype.interval = function (time, callback) {
var __method = this;
var __callback = callback || function () { };
this.$$timerid$$ = window.setInterval(function () {
__method.apply(this, arguments);
__callback.apply(this, arguments);
}, time);
};
Function.prototype.clearInterval = function () {
window.clearInterval(this.$$timerid$$);
};
//============================================
//== function ==================================
//============================================
function RGBA(r, g, b, a) {
var res = 0xff000000 | (r << 16) | (g << 8) | (b);
if (a != undefined) res = (res & 0x00ffffff) | (a << 24);
return res;
}
//============================================
//== DateModoki Object ==========================
//============================================
var DateModoki = new function () {
this.on_paint = function (gr, x, y) {
gr.FillSolidRect(-1, -1, window.Width + 2, window.Height + 2, color['Background']);
for (var i = 0; i < applied_text_arr.length; i++) {
var text = applied_text_arr[i].toString();
if (format.type_arr[i] === '_6_Second') {
switch (format.text_arr[i]) {
case '%ss': text = ('0' + (Number(text) + timer_count)).slice(-2); break;
case '%s': text = (Number(text) + timer_count).toString(); break;
}
}
gr.DrawString(text, font, color[format.type_arr[i]], x, y, window.Width, window.Height, 0x00000000);
x += gr.MeasureString(text.replace(/ /g, ''), font, 0, 0, window.Width, window.Height, 0).Width
+ (text.split(' ').length - 1) * spaceWidth; // MeasureStringメソッドは空白の幅を0と返すので、あらかじめ求めておいたspaceWidthを使って補完する
}
};
this.start = function () {
setFontAndColor();
setDate();
timer.interval(1000);
window.Repaint();
};
var timer = function () {
timer_count++;
if (date_now.getSeconds() + timer_count === 60) {
setDate();
window.Repaint()
}
else
format.isContain_Second && window.Repaint();
};
var setDate = function () {
timer_count = 0;
date_now = new Date();
applied_text_arr = format.applyDate(date_now);
};
var setFontAndColor = function () {
var fontfamily = ['Arial', 'Tahoma', 'Meiryo', 'Segoe UI', 'MS Gothic'];
fontfamily.unshift(prop.Style.Font_Family);
for (i = 0; i < fontfamily.length; i++) {
if (utils.CheckFont(fontfamily[i])) {
window.SetProperty('Style.Font_Family', prop.Style.Font_Family = fontfamily[i]);
break;
}
}
font = gdi.Font(prop.Style.Font_Family, prop.Style.Font_Size, Number(prop.Style.Font_Bold));
color = [];
for (var name in prop.Style.Color) {
color[name] = eval(prop.Style.Color[name]);
}
var temp_bmp = gdi.CreateImage(1, 1);
var temp_gr = temp_bmp.GetGraphics();
spaceWidth = temp_gr.MeasureString(' ,', font, 0, 1, window.Width, window.Height, 0).Width
- temp_gr.MeasureString(',', font, 0, 0, window.Width, window.Height, 0).Width;
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
};
var timer_count, date_now, applied_text_arr = [],
spaceWidth, font, color;
var format = new ParseFormat(prop.Style._format);
// Constructor
function ParseFormat(formatText) {
this.text_arr = [];
this.type_arr = [];
this.isContain_Second = false;
var i = 0;
var type = { YYYY: '_1_Year', YY: '_1_Year', Y: '_1_Year', MM: '_2_Month', ME: '_2_Month', Me: '_2_Month', M: '_2_Month', DD: '_3_Day', D: '_3_Day', hh: '_4_Hour', h: '_4_Hour', mm: '_5_Minute', m: '_5_Minute', ss: '_6_Second', s: '_6_Second', WJ: '_7_DayOfWeek', Wj: '_7_DayOfWeek', WE: '_7_DayOfWeek', We: '_7_DayOfWeek' };
var dateRE = /%(?:YYYY|YY|Y|MM|ME|Me|M|DD|D|hh|h|mm|m|ss|s|WJ|Wj|WE|We)/g;
while (dateRE.exec(formatText) !== null) {
if (i !== RegExp.index) {
this.text_arr.push(formatText.substring(i, RegExp.index).replace(/ /g, ' '));
this.type_arr.push('_0_Default');
}
this.text_arr.push(RegExp.lastMatch);
this.type_arr.push(type[RegExp.lastMatch.slice(1)]);
type[RegExp.lastMatch.slice(1)] === '_6_Second' && (this.isContain_Second = true);
i = RegExp.lastIndex;
}
if (i !== formatText.length) {
this.text_arr.push(formatText.substring(i, formatText.length));
this.type_arr.push('_0_Default');
}
}
ParseFormat.prototype.applyDate = function (dateObj) {
var arr = [], _this = this;
for (var i = 0; i < this.text_arr.length; i++) {
switch (this.text_arr[i]) {
case '%YYYY': arr.push(dateObj.getFullYear()); break;
case '%YY': arr.push(dateObj.getFullYear().toString().slice(2)); break;
case '%Y': arr.push(Number(dateObj.getFullYear().toString().slice(2))); break;
case '%MM': arr.push(('0' + (dateObj.getMonth() + 1)).slice(-2)); break;
case '%ME': arr.push(monthToString(dateObj.getMonth(), false)); break;
case '%Me': arr.push(monthToString(dateObj.getMonth(), true)); break;
case '%M': arr.push(dateObj.getMonth() + 1); break;
case '%DD': arr.push(('0' + dateObj.getDate()).slice(-2)); break;
case '%D': arr.push(dateObj.getDate()); break;
case '%hh': arr.push(('0' + dateObj.getHours()).slice(-2)); break;
case '%h': arr.push(dateObj.getHours()); break;
case '%mm': arr.push(('0' + dateObj.getMinutes()).slice(-2)); break;
case '%m': arr.push(dateObj.getMinutes()); break;
case '%ss': arr.push(('0' + dateObj.getSeconds()).slice(-2)); break;
case '%s': arr.push(dateObj.getSeconds()); break;
case '%WJ': arr.push(dayToString(dateObj.getDay(), false, 'ja')); setDayColor(dateObj.getDay(), i); break;
case '%Wj': arr.push(dayToString(dateObj.getDay(), true, 'ja')); setDayColor(dateObj.getDay(), i); break;
case '%WE': arr.push(dayToString(dateObj.getDay(), false, 'en')); setDayColor(dateObj.getDay(), i); break;
case '%We': arr.push(dayToString(dateObj.getDay(), true, 'en')); setDayColor(dateObj.getDay(), i); break;
default: arr.push(this.text_arr[i]); break;
}
}
function monthToString(num, shorter) {
if (shorter)
return ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'][num];
else
return ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'][num];
}
function dayToString(num, shorter, lang) {
if (shorter)
switch (lang) {
case 'en': return ['Вос', 'Пон', 'Втр', 'Срд', 'Чет', 'Пят', 'Суб'][num];
case 'ja': return ['日', '月', '火', '水', '木', '金', '土'][num];
}
else
switch (lang) {
case 'en': return ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'][num];
case 'ja': return ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'][num];
}
}
function setDayColor(num, i) {
if (num === 0)
_this.type_arr[i] = '_9_DayOfWeek_sun';
else if (num === 6)
_this.type_arr[i] = '_8_DayOfWeek_sat';
}
return arr;
};
// End Constructor
};
DateModoki.start();
//========================================
//== Callback function =========================
//========================================
//EOF
var font = gdi.Font("Arial", 40, 0);
var align = 0x00000003 | 0x00000008, align_scroll = 0x00000009;
var tf_string = ('[%title% —] Art: $if(%artist%,%artist%,•) •%codec%•[%playback_time%]/[%length%]');
var ww, pos_d = 3, q = 0, timer, g_drag = 0;
var start = true, stopped = false;
window.MinHeight = window.MaxHeight = 90;
function RGBA(r, g, b, a) {return ((a << 24) | (r << 16) | (g << 6) | (b));
}
function on_timer(id) {
window.Repaint();
}
function on_playback_new_track(metadb) {
window.Repaint();
}
function on_playback_stop(){
window.Repaint();
}
function on_playback_seek(time){
window.Repaint();
}
function on_playback_time(time){
window.Repaint();
}
function on_playback_pause(state){
window.Repaint();
}
function on_mouse_lbtn_down(x,y){
g_drag = 1;
on_mouse_move(x,y);
}
function on_mouse_lbtn_up(x,y){
if(g_drag){
g_drag = 0;
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ?
g_drag_seek : 1;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
g_drag = 0;
}
}
function on_mouse_move(x,y){
if(g_drag){
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ?
g_drag_seek : 1;
window.Repaint();
}
}
function RGB(r, g, b) { return (0xff000000 | (r << 16) | (g << 8) | (b)); }
function on_paint(gr) {
var text = fb.IsPlaying ? fb.TitleFormat((tf_string)+" • ").Eval() : (stopped ? "STOP" :
"----=== fb2k 4 iCar ===----");// название сборки
var text_width_d = gr.CalcTextWidth(text, font);
ww = window.Width, wh = window.Height, pos = 0, length =
fb.PlaybackLength;
if(!timer) timer = window.SetInterval(on_timer,30);
q = q + 50;
if(length > 0){
if(g_drag){
pos = window.Width * g_drag_seek;
}
else{
pos = window.Width * (fb.PlaybackTime /
[length]);
}
} else if (fb.PlaybackTime) {
}
gr.FillGradRect(0,0,ww,wh,-90,RGB(140,121,92), RGB(25,13,5));
gr.FillGradRect(0,0,pos,wh,-90,RGB(25,13,5),RGB(191,171,118)); //фон прошло
gr.DrawRect(1,0, ww-1, wh-0, 1.0, RGB(205,170,125));
gr.DrawRect(-2,0, pos+1, 90, 3, RGB(25, 20, 20)); //движок-разделитель
gr.DrawRect(1,-1, ww-0, wh-0, 2.0, RGB(20,20,20));
text_width_2 = gr.CalcTextWidth(text, font);
if(text_width_d>ww-15) {
text = text + " • " + text;
text_width_2 = gr.CalcTextWidth(text, font);
if(pos_d <= text_width_d - text_width_2) {
pos_d = 10 - (start ? 0 : 3);
start = false;
} else {
pos_d = pos_d - 1;
}
gr.GdiDrawText(text, font, RGB(180,196,200), pos_d + 10, 38, text_width_2, 80, align_scroll);
DateModoki.on_paint(gr, 20, 6);
} else {
gr.GdiDrawText(text, font, RGB(180,196,200), 0, 20, ww, 90, align_scroll);
}
function on_size() {
if (g_timer) {window.KillTimer(g_timer); g_timer=false;}
}
function on_playback_pause(state) {
window.Repaint();
}
function on_playback_starting(cmd, is_paused) {}
}
// APPLICATION - END
gr.FillGradRect(0,0,ww,wh,-90, RGB(140,121,92), RGB(25,13,5));
gr.FillGradRect(0,0,ww,wh,-90, RGB(25,13,5),RGB(140,121,92));
Согласен , хотя теряется некая объёмность тогда ...Проще заливку фона оставшегося времени звучания поменять.
/////////////////////// бегущая строка - сикбар v.10.12.2010 \\\\\\\\\\\
//San_dr http://forum.oszone.net && Zin-Uru http://foobar2000.ru/forum\\
//var font = gdi.Font("Tahoma", 17, 1);
//var font = gdi.Font("AGOpus", 17, 0);
// ==PREPROCESSOR==
// @name "Date Modoki"
// @version "1.0.0"
// @author "tomato111"
// ==/PREPROCESSOR==
//年 %YYYY 4桁
//年 %YY 2桁
//年 %Y 2桁(桁合わせ無し)
//月 %MM
//月 %M (桁合わせ無し)
//月 %ME 英語 フル
//月 %Me 英語 略字
//日 %DD
//日 %D (桁合わせ無し)
//時 %hh
//時 %h(桁合わせ無し)
//分 %mm
//分 %m(桁合わせ無し)
//秒 %ss
//秒 %s(桁合わせ無し)
//曜日 %WJ 日本 フル
//曜日 %Wj 日本 略字
//曜日 %WE 英語 フル
//曜日 %We 英語 略字
//========
// properties
//========
function RGB(r, g, b) { return (0xff000000 | (r << 24) | (g << 16) | (b)); }
var prop = new function () {
this.Style = {
_format: window.GetProperty('Style._format', '%hh:%mm:%ss • %We• %DD.%MM.%Y'),
Color:
{
_0_Default: window.GetProperty('Style.Color._0_Default', 'RGB(29,21,14)'),
_1_Year: window.GetProperty('Style.Color._1_Year', 'RGB(91,145,143)'),
_2_Month: window.GetProperty('Style.Color._2_Month', 'RGB(35,246,238)'),
_3_Day: window.GetProperty('Style.Color._3_Day', 'RGB(35,246,238)'),
_4_Hour: window.GetProperty('Style.Color._4_Hour', 'RGB(35,246,238)'),
_5_Minute: window.GetProperty('Style.Color._5_Minute', 'RGB(35,246,238)'),
_6_Second: window.GetProperty('Style.Color._6_Second', 'RGB(91,145,143)'),
_7_DayOfWeek: window.GetProperty('Style.Color._7_DayOfWeek', 'RGB(120,255,130)'),
_8_DayOfWeek_sat: window.GetProperty('Style.Color._8_DayOfWeek_sat', 'RGB(0,0,200)'),
_9_DayOfWeek_sun: window.GetProperty('Style.Color._9_DayOfWeek_sun', 'RGB(200,0,0)'),
//Background: window.GetProperty('Style.Color.Background', 'RGBA(255,255,255,0)')
},
Font_Family: window.GetProperty('Style.Font_Family', 'a_LCDNova'),
Font_Size: window.GetProperty('Style.Font_Size', 34),
Font_Bold: window.GetProperty('Style.Font_Bold', true)
};
};
//========
//============================================
//== Prototype ==================================
//============================================
Function.prototype.interval = function (time, callback) {
var __method = this;
var __callback = callback || function () { };
this.$$timerid$$ = window.setInterval(function () {
__method.apply(this, arguments);
__callback.apply(this, arguments);
}, time);
};
Function.prototype.clearInterval = function () {
window.clearInterval(this.$$timerid$$);
};
//============================================
//== function ==================================
//============================================
//============================================
//== DateModoki Object ==========================
//============================================
var DateModoki = new function () {
this.on_paint = function (gr, x, y) {
//gr.FillSolidRect(-1, -1, window.Width + 2, window.Height + 2, color['Background']);
for (var i = 0; i < applied_text_arr.length; i++) {
var text = applied_text_arr[i].toString();
if (format.type_arr[i] === '_6_Second') {
switch (format.text_arr[i]) {
case '%ss': text = ('0' + (Number(text) + timer_count)).slice(-2); break;
case '%s': text = (Number(text) + timer_count).toString(); break;
}
}
gr.GdiDrawText(text, font, color[format.type_arr[i]], x, y, window.Width, window.Height, 0x00000001);
x += gr.MeasureString(text.replace(/ /g,''), font, 0, 0, window.Width, window.Height,10).Width-12
+ (text.split('').length - 1) * spaceWidth; // MeasureString??????????0?????????????????spaceWidth????????
}
};
this.start = function () {
setFontAndColor();
setDate();
timer.interval(1000);
window.Repaint();
};
var timer = function () {
timer_count++;
if (date_now.getSeconds() + timer_count === 60) {
setDate();
window.Repaint()
}
else
format.isContain_Second && window.Repaint();
};
var setDate = function () {
timer_count = 0;
date_now = new Date();
applied_text_arr = format.applyDate(date_now);
};
var setFontAndColor = function () {
var fontfamily = ['prop.Style.Font_Family'];
fontfamily.unshift(prop.Style.Font_Family);
for (i = 0; i < fontfamily.length; i++) {
if (utils.CheckFont("a_LCDNova")) {
window.SetProperty('Style.Font_Family', prop.Style.Font_Family = fontfamily[i]);
break;
}
}
font = gdi.Font(prop.Style.Font_Family, prop.Style.Font_Size, Number(prop.Style.Font_Bold));
color = [];
for (var name in prop.Style.Color) {
color[name] = eval(prop.Style.Color[name]);
}
var temp_bmp = gdi.CreateImage(1, 1);
var temp_gr = temp_bmp.GetGraphics();
spaceWidth = temp_gr.MeasureString(' ,', font, 0, 1, window.Width, window.Height, 0).Width
- temp_gr.MeasureString(',', font, 0, 0, window.Width, window.Height, 0).Width;
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
};
var timer_count, date_now, applied_text_arr = [],
spaceWidth, font, color;
var format = new ParseFormat(prop.Style._format);
// Constructor
function ParseFormat(formatText) {
this.text_arr = [];
this.type_arr = [];
this.isContain_Second = false;
var i = 0;
var type = { YYYY: '_1_Year', YY: '_1_Year', Y: '_1_Year', MM: '_2_Month', ME: '_2_Month', Me: '_2_Month', M: '_2_Month', DD: '_3_Day', D: '_3_Day', hh: '_4_Hour', h: '_4_Hour', mm: '_5_Minute', m: '_5_Minute', ss: '_6_Second', s: '_6_Second', WJ: '_7_DayOfWeek', Wj: '_7_DayOfWeek', WE: '_7_DayOfWeek', We: '_7_DayOfWeek' };
var dateRE = /%(?:YYYY|YY|Y|MM|ME|Me|M|DD|D|hh|h|mm|m|ss|s|WJ|Wj|WE|We)/g;
while (dateRE.exec(formatText) !== null) {
if (i !== RegExp.index) {
this.text_arr.push(formatText.substring(i, RegExp.index).replace(/ /g, ' '));
this.type_arr.push('_0_Default');
}
this.text_arr.push(RegExp.lastMatch);
this.type_arr.push(type[RegExp.lastMatch.slice(1)]);
type[RegExp.lastMatch.slice(1)] === '_6_Second' && (this.isContain_Second = true);
i = RegExp.lastIndex;
}
if (i !== formatText.length) {
this.text_arr.push(formatText.substring(i, formatText.length));
this.type_arr.push('_0_Default');
}
}
ParseFormat.prototype.applyDate = function (dateObj) {
var arr = [], _this = this;
for (var i = 0; i < this.text_arr.length; i++) {
switch (this.text_arr[i]) {
case '%YYYY': arr.push(dateObj.getFullYear()); break;
case '%YY': arr.push(dateObj.getFullYear().toString().slice(2)); break;
case '%Y': arr.push(Number(dateObj.getFullYear().toString().slice(2))); break;
case '%MM': arr.push(('0' + (dateObj.getMonth() + 1)).slice(-2)); break;
case '%ME': arr.push(monthToString(dateObj.getMonth(), false)); break;
case '%Me': arr.push(monthToString(dateObj.getMonth(), true)); break;
case '%M': arr.push(dateObj.getMonth() + 1); break;
case '%DD': arr.push(('0' + dateObj.getDate()).slice(-2)); break;
case '%D': arr.push(dateObj.getDate()); break;
case '%hh': arr.push(('0' + dateObj.getHours()).slice(-2)); break;
case '%h': arr.push(dateObj.getHours()); break;
case '%mm': arr.push(('0' + dateObj.getMinutes()).slice(-2)); break;
case '%m': arr.push(dateObj.getMinutes()); break;
case '%ss': arr.push(('0' + dateObj.getSeconds()).slice(-2)); break;
case '%s': arr.push(dateObj.getSeconds()); break;
case '%WJ': arr.push(dayToString(dateObj.getDay(), false, 'ja')); setDayColor(dateObj.getDay(), i); break;
case '%Wj': arr.push(dayToString(dateObj.getDay(), true, 'ja')); setDayColor(dateObj.getDay(), i); break;
case '%WE': arr.push(dayToString(dateObj.getDay(), false, 'en')); setDayColor(dateObj.getDay(), i); break;
case '%We': arr.push(dayToString(dateObj.getDay(), true, 'en')); setDayColor(dateObj.getDay(), i); break;
default: arr.push(this.text_arr[i]); break;
}
}
function monthToString(num, shorter) {
if (shorter)
return ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'][num];
else
return ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'][num];
}
function dayToString(num, shorter, lang) {
if (shorter)
switch (lang) {
case 'en': return ['Вос', 'Пон', 'Втр', 'Срд', 'Чет', 'Пят', 'Суб'][num];
case 'ja': return ['日', '月', '火', '水', '木', '金', '土'][num];
}
else
switch (lang) {
case 'en': return ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'][num];
case 'ja': return ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'][num];
}
}
function setDayColor(num, i) {
if (num === 0)
_this.type_arr[i] = '_9_DayOfWeek_sun';
else if (num === 6)
_this.type_arr[i] = '_8_DayOfWeek_sat';
}
return arr;
};
// End Constructor
};
DateModoki.start();
//========================================
//== Callback function =========================
//========================================
//EOF
var font = gdi.Font("Arial", 40, 0);
var align = 0x00000003 | 0x00000008, align_scroll = 0x00000009;
var tf_string = ('[%title% —] Art: $if(%artist%,%artist%,•) •%codec%•[%playback_time%]/[%length%]');
var ww, pos_d = 3, q = 0, timer, g_drag = 0;
var start = true, stopped = false;
window.MinHeight = window.MaxHeight = 90;
function on_timer(id) {
window.Repaint();
}
function on_playback_new_track(metadb) {
window.Repaint();
}
function on_playback_stop(){
window.Repaint();
}
function on_playback_seek(time){
window.Repaint();
}
function on_playback_time(time){
window.Repaint();
}
function on_playback_pause(state){
window.Repaint();
}
function on_mouse_lbtn_down(x,y){
g_drag = 1;
on_mouse_move(x,y);
}
function on_mouse_lbtn_up(x,y){
if(g_drag){
g_drag = 0;
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ?
g_drag_seek : 1;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
g_drag = 0;
}
}
function on_mouse_move(x,y){
if(g_drag){
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ?
g_drag_seek : 1;
window.Repaint();
}
}
function RGB(r, g, b) { return (0xff000000 | (r << 16) | (g << 8) | (b)); }
function on_paint(gr) {
var text = fb.IsPlaying ? fb.TitleFormat((tf_string)+" • ").Eval() : (stopped ? "STOP" :
"----=== fb2k 4 iCar ===----");// название сборки
var text_width_d = gr.CalcTextWidth(text, font);
ww = window.Width, wh = window.Height, pos = 0, length =
fb.PlaybackLength;
if(!timer) timer = window.SetInterval(on_timer,18);
q = q + 50;
if(length > 0){
if(g_drag){
pos = window.Width * g_drag_seek;
}
else{
pos = window.Width * (fb.PlaybackTime /
[length]);
}
} else if (fb.PlaybackTime) {
}
gr.FillGradRect(0,0,ww,wh,-90,RGB(140,121,92), RGB(25,13,5));
gr.FillGradRect(0,0,pos,wh,-90,RGB(25,13,5),RGB(191,171,118)); //фон прошло
DateModoki.on_paint(gr, -190, 6);
gr.DrawRect(1,0, ww-1, wh-0, 1.0, RGB(205,170,125));
gr.DrawRect(-2,0, pos+1, 90, 3, RGB(25, 20, 20)); //движок-разделитель
gr.DrawRect(1,-1, ww-0, wh-0, 2.0, RGB(20,20,20));
text_width_2 = gr.CalcTextWidth(text, font);
if(text_width_d>ww-15) {
text = text + " • " + text;
text_width_2 = gr.CalcTextWidth(text, font);
if(pos_d <= text_width_d - text_width_2) {
pos_d = 10 - (start ? 0 : 3);
start = false;
} else {
pos_d = pos_d - 1;
}
gr.GdiDrawText(text, font, RGB(244,231,211), pos_d + 10, 38, text_width_2, 80, align_scroll);
} else {
gr.GdiDrawText(text, font, RGB(244,231,211), 0, 38, ww, 90, align_scroll);
}
function on_size() {
if (g_timer) {window.KillTimer(g_timer); g_timer=false;}
}
function on_playback_pause(state) {
window.Repaint();
}
function on_playback_starting(cmd, is_paused) {}
}
// APPLICATION - END
Добавил два режима selected/automatic. Мне показалось это достаточным (при режиме stop в режиме now playing не очень красивенько - пустые значения в строках). Если этого мало - сделаем как Вы написали.Aum:добавить в менюшку выбор режима
// ==PREPROCESSOR==
// @name "properties & create file"
// @author "kgena_ua"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r, g, b, a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
var font = gdi.Font("Areal",12,0);
var group_font = gdi.Font("Tahoma",9,0);
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_RIGHT = 0x00000002;
DT_WORD_ELLIPSIS = 0x00040000;
DT_SINGLELINE = 0x00000020;
var ww, wh;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
var bgcolor = RGB(20,20,20);
var color1 = RGB(180,180,180);
var color2 = RGB(255,255,200);
var color3 = RGB(100,100,100);
var tooltip = window.CreateTooltip();
tooltip.SetMaxWidth(300);
var tstring = 0;
var delay_flag = false;
var timer;
window.GetProperty("Tooltip", 0);
var selection_mode = window.GetProperty("selection_mode", 0);
var name, value, measure, t_height;
var path = "";
var g_drag = false;
var g_drag_y = 0;
var s = 0;
var col1 = 10;
var col2 = 110;
var col3;
var pos_y, pos_x;
var old_x, old_y;
var wh_old;
var star_size = 12, offset = star_size + 2;
var tfname = new Array(
"$meta(artist)",
"%title%",
"%album%",
"%date%",
"%genre%",
"%composer%",
"%performer%",
"%publisher%",
"$meta(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%",
"$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 tfname_length = tfname.length;
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
show_array(gr);
gr.GdiDrawText("", font, color2, 0, 120, ww, wh, DT_RIGHT | DT_WORD_ELLIPSIS);
}
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 TooltipActivate() {
tstring = Math.floor((pos_y + Math.abs(s)) / t_height);
if (value_width[tstring * 2] > ww - col2 - col1 && pos_x > col2 && window.GetProperty("Tooltip") == 1){
tooltip.Text = value_width[tstring * 2 + 1];
delay();
delay_flag && tooltip.Activate();
} else {
delay_flag = false;
tooltip.Deactivate();
}
}
function delay() {
delay_flag && window.ClearTimeout(timer);
timer = window.SetTimeout(function() {
delay_flag = true;
window.ClearTimeout(timer);
}, 1000);
}
function on_mouse_move(x, y) {
window.SetCursor(32649);
pos_y = y;
pos_x = x;
if (old_y != y || old_x != x){
TooltipActivate();
old_y = y;
old_x = x;
}
if (g_drag) {
if (s <= 0 && (name_array.length * t_height) >= wh) {s = y - g_drag_y};
applyDelta();
}
if (s == 0 || s == wh - name_array.length * t_height) g_drag_y = (y - s);
window.Repaint();
}
function on_mouse_wheel(step) {
if (s <= 0 && name_array.length * t_height >= wh) {s = s + step * t_height};
applyDelta();
}
function applyDelta() {
s = s > 0 ? 0 : s;
s = s < (wh - name_array.length * t_height) && s < 0 ? (wh - name_array.length * t_height) : s;
window.Repaint();
}
function on_mouse_leave() {
window.SetCursor(32512);
window.Repaint();
}
function on_size() {
ww = window.Width;
wh = window.Height;
if (wh != wh_old && s < 0) {
s = wh >= wh_old ? 0 : s;
wh_old = wh;
}
}
var name_array = [];
var value_array = [];
var value_width = [];
var max_width;
function create_array() {
var temp_bmp = gdi.CreateImage(1, 1);
var temp_gr = temp_bmp.GetGraphics();
name_array = [];
value_array = [];
value_width = [];
for (j = 0; j < tfname_length; j++) {
group = false;
LM = false;
if (tfname[j].search('group') >= 0 || tfname[j] == "line" ) group = true;
value = Eval(tfname[j]);
if (value != 0 || group) {
name_array.push(tfname[j]);
value_array.push(value);
value_width.push(temp_gr.CalcTextWidth(value, font),value);
}
}
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
}
function show_array(gr) {
t_height = gr.CalcTextHeight("text", font) + 2;
for (var i = 0; i < name_array.length; i++) {
line = false;
group = false;
measure = "";
if (name_array[i].search('line') >= 0) line = true;
if (name_array[i].search('group') >= 0) group = true;
row = i * t_height + s;
line_row = row + t_height / 2;
line && gr.DrawLine(col1, line_row, ww - col1, line_row, 1, color3);
name = name_array[i].replace(/[%\$\(\)]|info|meta|group |line|lastfm/g,'').replace(/_/g,' ').replace('directory pathpath','directory path');
var rating_name = name_array[i] == "$meta(rating)" ? " (tag)" : "";
gr.GdiDrawText(name + rating_name, group ? group_font : font, group ? color3 : color1, col1, row, ww - col1 * 2, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
if (name_array[i] == "%rating%" || name_array[i] == "$meta(rating)") {
for (var r = 0; r < value_array[i] * offset; r = r + offset) {
draw_star(gr, col2 + star_size / 2 + r, row + t_height / 2, star_size, 1, 0, color2)
}
} else {
value = value_array[i];
gr.GdiDrawText(value, font, color2, col2, row, ww - col2 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
if (name_array[i] == "$info(bitrate)") measure = " kbps";
if (name_array[i] == "$info(samplerate)") measure = " Hz";
if (name_array[i] == "$info(bitspersample)") measure = " bps";
if (name_array[i] == "$info(channels)") measure = " ch";
if (name_array[i] == "%play_count%") measure = " times";
col3 = col2 + gr.CalcTextWidth(value, font);
gr.GdiDrawText(measure, font, color1, col3, row, ww - col3 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
}
}
}
var metadb;
on_item_focus_change();
function on_item_focus_change() {
switch (selection_mode) {
case 0:
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 1:
metadb = fb.GetFocusItem();
break;
}
if (metadb) on_metadb_changed();
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_new_track() {
on_item_focus_change();
}
function on_playback_stop() {
on_item_focus_change();
}
function on_metadb_changed() {
create_array();
window.Repaint();
}
function Eval(field) {
if (metadb) {
path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
return path.indexOf('://') > 0 ? fb.TitleFormat("[" + field + "]").Eval(true) : fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
}
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
_menu.AppendMenuItem(MF_ENABLED, i++, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, i++, "Follow selected track");
_menu.CheckMenuRadioItem(1, i, selection_mode + 1);
_menu.EnableMenuItem(selection_mode + 1, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "Tooltip");
_menu.CheckMenuItem(3, window.GetProperty("Tooltip"));
_menu.AppendMenuItem(MF_ENABLED, i++, "Create txt/xls file");
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
// if (ShiftDown) {
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 10, "Reload");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 20, "Properties");
_menu.AppendMenuItem(MF_ENABLED, 30, "Configure ...");
// }
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 1:
selection_mode = 0;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 2:
selection_mode = 1;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 3:
window.GetProperty("Tooltip") == 0 ? window.SetProperty("Tooltip", 1) : window.SetProperty("Tooltip", 0);
break;
case 4:
menu_create_file(x,y);
break;
case 10:
window.Reload();
break;
case 20:
window.ShowProperties();
break;
case 30:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
///////////////////////////// Create file
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists( fb.ProfilePath + "output")) {fso.CreateFolder( fb.ProfilePath + "output" )};
var output_path = fb.ProfilePath + "\\output\\";
var fields = [];
create_fields_array();
function create_fields_array() {
for (var j = 0; j < tfname.length; j++) {
if (tfname[j].indexOf('line') < 0 && tfname[j].indexOf('group') < 0){
fields.push(tfname[j])};
}
}
var output_fields = [];
var separator = Array(" ; ","\t");
for (var j = 0; j < fields.length; j++) {
window.GetProperty(j + 1,0);
}
window.GetProperty("ext",0);
window.GetProperty("skip",0);
var selected;
var shift = 0;;
function create_output_array() {
output_fields = [];
for (var j = 0; j < fields.length; j++) {
selected = window.GetProperty(j + 1);
if ( selected == 1 ) {output_fields.push(fields[j])};
}
createTextFile();
}
function createTextFile(){
count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
if (count == 0 || output_fields.length ==0) return;
plist_name = plman.GetPlaylistName(plman.ActivePlaylist);
plist_name = plist_name.replace(/[\/\:\*\?\"\<\>\|]/g,'')
if (window.GetProperty("ext") == 0) {
output_file = output_path + "plist " + plist_name + ".txt";
} else {
output_file = output_path + "plist " + plist_name + ".xls";
}
try { file = fso.CreateTextFile( output_file )
} catch(e) {
if (e.number == -2146828218) return; // permission denied
}
if ( window.GetProperty("skip") == 0) {
text = [];
string = "";
for (var j = 0; j < output_fields.length; j++) {
text.push(output_fields[j]);
}
string = text.join(separator[window.GetProperty("ext")]);
file.WriteLine(string);
file.WriteLine("");
}
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
text = [];
string = "";
for (var j = 0; j < output_fields.length; j++) {
value = fb.TitleFormat("[" + output_fields[j] + "]").EvalWithMetadb(item);
var measure = "";
if (value != "" ) {
if (output_fields[j] == "$info(bitrate)") measure = " kbps";
if (output_fields[j] == "$info(samplerate)") measure = " Hz";
if (output_fields[j] == "$info(bitspersample)") measure = " bps";
if (output_fields[j] == "$info(channels)") measure = " ch";
}
if (value != "" || window.GetProperty("skip") == 0) {
text.push(value + measure);
}
string = text.join(separator[window.GetProperty("ext")]);
}
try { file.WriteLine(string)
} catch(e) {
if (e.number == -2146828283) file.WriteLine(":ERROR");
}
}
file.Close();
}
function menu_create_file(x,y){
var _menu = window.CreatePopupMenu();
var i = 1;
count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
MF = count == 0 ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(MF, i++, "create " + (window.GetProperty("ext") == 0 ? "*.txt" : "*.xls") + " file");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var lines = 20;
tl = 0 + shift;
bl = fields.length > lines ? lines + shift : fields.length;
for (var j = tl; j < bl; j++) {
menuItem = fields[j].replace(/[%\$\(\)]|info|meta/g,'').replace(/_/g,' ');
_menu.AppendMenuItem(MF_ENABLED, i++, menuItem);
_menu.CheckMenuItem(i-1, window.GetProperty(i - 2 + shift));
}
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 100, "txt");
_menu.AppendMenuItem(MF_ENABLED, 101, "xls");
_menu.CheckMenuRadioItem(100, 101, 100 + window.GetProperty("ext"));
_menu.EnableMenuItem(100 + window.GetProperty("ext"), 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 110, "skip if empty");
_menu.CheckMenuItem(110, window.GetProperty("skip"));
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 120, "clear all");
if (fields.length > lines) {
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(shift == 0 ? MF_GRAYED : MF_ENABLED, 130, "up");
_menu.AppendMenuItem(shift + lines >= fields.length ? MF_GRAYED : MF_ENABLED, 140, "down");
}
ret = _menu.TrackPopupMenu(x,y);
switch (true) {
case (ret == 1):
create_output_array();
break;
case (ret >= 2 && ret <= fields.length + 1):
selected = window.GetProperty(ret - 1 + shift);
window.SetProperty(ret - 1 + shift, selected == 0 ? 1 : 0);
menu_create_file(x,y);
break;
case (ret == 100):
window.SetProperty("ext", 0);
menu_create_file(x,y);
break;
case (ret == 101):
window.SetProperty("ext", 1);
menu_create_file(x,y);
break;
case (ret == 110):
window.SetProperty("skip", window.GetProperty("skip") == 0 ? 1 : 0);
menu_create_file(x,y);
break;
case (ret == 120):
for (var j = 1; j < fields.length + 1; j++) {
window.SetProperty(j, 0);
}
menu_create_file(x,y);
break;
case (ret == 130):
shift = shift - 1;
menu_create_file(x,y);
break;
case (ret == 140):
shift = shift + 1;
menu_create_file(x,y);
break;
}
_menu.Dispose();
}
///////////////////////////// Draw star
function draw_star(gr, x, y, img_size, fill, line_thickness, color){
var radius = img_size / 2;
var radius_2 = radius / 2.61803;
line_thickness = line_thickness >= radius_2 ? radius_2 : line_thickness;
var delta = line_thickness / 2 * Math.tan(72 / 180 * Math.PI);
var points = [],
x_points_1 = [], y_points_1 = [];
x_points_2 = [], y_points_2 = [];
for (var i = 0; i < 10; i++) {
if (i % 2 == 0) {
x_points_1.push(x + ((radius - delta) * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2)));
y_points_1.push(y + ((radius - delta) * Math.sin(Math.PI * i / 10 * 2 - Math.PI / 2)));
} else {
x_points_2.push(x + ((radius - delta) / 2.61803 * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2)));
y_points_2.push(y + ((radius - delta) / 2.61803 * Math.sin(Math.PI * i / 10 * 2 - Math.PI / 2)));
}
}
for (var i = 0; i < 5; i++) {
points.push(x_points_1[i], y_points_1[i], x_points_2[i], y_points_2[i]);
}
gr.SetSmoothingMode(2);
if(fill > 0) {
gr.FillPolygon(color, 1, points)
}
if(line_thickness > 0) {
gr.DrawPolygon(color, line_thickness, points);
}
}
// ==PREPROCESSOR==
// @name "running string"
// @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;
var color = RGB(255,255,220);
var txt_row = 10;
var s = 10, step, step1 = window.Width, step2 = window.Width;
var text1, text2, t_width, t_width1, t_width2, dir, mode, sw = 1;
var t1 = "", t2 = "", t3 = "", ti = "";
var show1, show2, show3, showi, showr;
String.prototype.repeat = function(n) {
return new Array(n + 1).join(this);
}
var space = "\u0020".repeat(5);
function on_paint(gr) {
gr.FillSolidRect (0, 0, ww, wh, RGB(30,30,30));
run_string(gr);
}
function run_string(gr) {
show1 = window.GetProperty("show1",1);
show2 = window.GetProperty("show2",1);
show3 = window.GetProperty("show3",1);
mode = window.GetProperty("mode",1);
showi = window.GetProperty("showi",1);
if (show1 == 1) {t1 = fb.TitleFormat("$upper([%title%])").Eval();
} else {t1 = "";}
if (show2 == 1) {t2 = fb.TitleFormat("$upper([%artist%])").Eval();
} else {t2 = "";}
if (show3 == 1) {t3 = fb.TitleFormat("$upper([%album%])[ - %date%]").Eval();
} else {t3 = "";}
if (showi == 1) {ti = fb.TitleFormat("[$info(encoding)][ - $info(codec)][ $info(codec_profile)][ - $info(bitrate) kbps][ - $info(samplerate) Hz][ - $info(bitspersample) bps][ - $channels()]$if($stricmp($ext(%filename_ext%),cue), '['cue']',[ - %filesize_natural%])$if($strcmp($info(cue_embedded),yes),' ['embedded cue']',)").Eval();
} else {ti = "";}
text1 = t1 + (show1 > 0 && t2 != "" ? " - " : "") + t2 + ((show1 > 0 || show2 > 0) && t3 != "" ? " - " : "") + t3;
text2 = showi == 1 ? ti : text1;
text1 = showi == 1 && text1 == "" ? text2 : text1;
t_width2 = gr.CalcTextWidth(text2, font);
t_width1 = gr.CalcTextWidth(text1, font);
t_height = gr.CalcTextHeight("000", font)
if (mode == 1) {
step = sw == 1 ? step1 : step2;
t_width = sw == 1 ? t_width1 : t_width2;
if (sw == 1) {step2 = ww};
if (sw == 2) {step1 = ww};
if (t_width < ww - s * 2) {
if (step >= ww) {dir = "left"; step = ww };
if (step + t_width >= ww - s) {dir = "left"};
if (step <= 0 + s) {dir = "right"};
} else {
if (step + t_width <= ww - s) {dir = "right"};
if (step >= 0 + s) {dir = "left"};
}
}
if (mode == 0) { dir = "left";
if (sw == 1) {
if (step1 + t_width1 > ww/2) {step2 = ww};
if (step1 + t_width1 <= 0) {step1 = ww; sw = 2};
} else {
if (step2 + t_width2 > ww/2) {step1 = ww};
if (step2 + t_width2 <= 0) {step2 = ww; sw = 1};
}
}
gr.GdiDrawText( text1, font, color, step1, txt_row, t_width, wh, DT_LEFT);
gr.GdiDrawText( text2, font, color, step2, txt_row, t_width, wh, DT_LEFT);
}
var run_timer;
function on_playback_new_track(info) {
run_timer && window.ClearInterval(run_timer);
run_timer = window.SetInterval(function() {
if (dir == "right") {step1 = step1 + 1};
if (dir == "right") {step2 = step2 + 1};
if (dir == "left") {step1 = step1 - 1};
if (dir == "left") {step2 = step2 - 1};
window.Repaint();
}, 50 );
}
function on_playback_stop() {
window.ClearInterval(run_timer);
window.Repaint();
}
function on_playback_seek(time) {
window.Repaint();
}
function on_playback_time(time){
if(!run_timer) on_playback_new_track();
}
function on_mouse_lbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
_menu.AppendMenuItem(0x00000000, i++, "title");
_menu.CheckMenuItem(i-1, show1);
_menu.AppendMenuItem(0x00000000, i++, "artist");
_menu.CheckMenuItem(i-1, show2);
_menu.AppendMenuItem(0x00000000, i++, "album");
_menu.CheckMenuItem(i-1, show3);
_menu.AppendMenuItem(0x00000000, i++, "info");
_menu.CheckMenuItem(i-1, showi);
_menu.AppendMenuItem(0x00000000, i++, "scrolling mode: " + (mode == 0 ? "L-R" : "L"));
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
window.SetProperty("show1", show1 == 0 ? 1 : 0);
break;
case 2:
window.SetProperty("show2", show2 == 0 ? 1 : 0);
break;
case 3:
window.SetProperty("show3", show3 == 0 ? 1 : 0);
break;
case 4:
window.SetProperty("showi", showi == 0 ? 1 : 0);
break;
case 5:
window.SetProperty("mode", mode == 0 ? 1 : 0);
break;
}
_menu.Dispose();
return true;
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
Отличный вариант - спасибо!seriousstas, по бегущей строке у меня есть такое.
А если по аналогии , как в библиотекеЯ пока не могу определится как сохранять файлы в скрипте с картинками
// ==PREPROCESSOR==
// @name "ALBUM LIBRARY touch mod by Terro"
// @version "2.1"
// @author "Vo Thanh Dat"
// ==/PREPROCESSOR==
// @tooltip "custom-paint"
function RGBA(r, g, b, a) { return (a << 24)|(r << 16)|(g << 8)|(b);}
function RGB(r, g, b) { return 0xff000000|(r << 16)|(g << 8)|(b);}
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
function CustomColor(color){
tempc = color.split("-");
return (0xff000000 | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
}
var lbup =0;
var lbdn = 0;
var y_start = 0;
var y_end = 0;
var y_delta = 0;
var DrawBitmap = true;
var Load_async = true;
var form_text = "",
form_text_b = "",
form_his = [],
form_his_ = [];
var char_index = [];
var font_size = window.GetProperty("Font_size","25");
var g_time = window.setInterval(on_timer,window.GetProperty("TimerInterval",16)/2);
//var g_time = window.SetInterval(on_timer,16);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WshShell = new ActiveXObject("WScript.Shell");
var htmlfile = new ActiveXObject('htmlfile');
var touch_sens = window.GetProperty("Touch_sensitivity",15);
var scroll_step = window.GetProperty("Scroll_Step",1);
var row_count = window.GetProperty("Row",3);
var playlist = window.GetProperty("playlist exclusion","");
var min_song = window.GetProperty("minimum song per group",2);
//================================================================================================= Colors
var select_color = RGBA(29,21,14,0);//window.GetProperty("_COLOR: Select Color","200-200-210"),//RGBA(255,0,0,0);
select_color2 = RGBA(210,210,138,0);//window.GetProperty("_COLOR: Select Color 2","0-128-255"),//RGBA(119,255,233,0);
cover_back_color = RGBA(0,0,0,0);//window.GetProperty("_COLOR: Cover Back Color","0-0-0"),//RGBA(188,255,119,150);
back_shadow_color = RGBA(29,21,14,100);//window.GetProperty("_COLOR: Back Shadow Color","100-100-110"),//RGBA(0,0,0,50);
text_color = window.GetProperty("_COLOR: Text Color","200-200-210"),//RGBA(250,250,250,250);
background_color = window.GetProperty("_COLOR: Background Color","15-15-15"),//RGBA(15,15,15,255);
select_angle = 45;
//select_color = CustomColor(select_color);
//select_color2 = CustomColor(select_color2);
//cover_back_color = CustomColor(cover_back_color);
//back_shadow_color = CustomColor(back_shadow_color);
text_color = CustomColor(text_color);
background_color = CustomColor(background_color);
//=====================================================================================
var cover_path = new RegExp("(artwork)|(cover)|(scan)|(image)");
var cover_img = "*folder*.*-*front*.*-*cover*.*-*.*".split("-");
var g_font = gdi.Font("Segoe UI", 14, 0);
var g_font_m = gdi.Font("Segoe UI", 14, 0);
var g_font_i = gdi.Font("Segoe UI Semibold", 13, 2);
var g_font_c = gdi.Font("Segoe UI Semibold", font_size, 0);//================ font
var g_font_al1 = gdi.Font("Segoe UI Semibold", 14, 0);
var g_font_al2 = gdi.Font("Segoe UI Semibold", 22, 0);
var g_font_al3 = gdi.Font("Segoe UI Semibold", 16, 0);
var g_font_al4 = gdi.Font("Segoe UI Semibold", 14, 0);
var time_f = fb.CreateProfiler("time_f"),
time_s = fb.CreateProfiler("time_s"),
time_r = fb.CreateProfiler("time_r"),
time_h = fb.CreateProfiler(),
time_scroll = fb.CreateProfiler("Time delay paint");
var stub_image,cell_null,cell_null_gr;
var mouse_l_hold_f = false,
on_form = false,
form_text_cusor_hiden = false,
repaint_f1 = false,
repaint_f2 = false,
repaint_f = true,
repaint_a = false,
repaint_main1 = false,
repaint_main2 = false,
repaint_main = true,
hold_shift = false,
mouse_in = false,
main_or_form = false,
hold_scroll = false,
isvisible = false;
var form_text_cusor = 0,
bold_start=0,
bold_end=0,
shift_index = 0,
text_heigh = 0,//================== def 23 search string height
time_reset_loadimg = 30,
postion_load_img = 0.5,
m_m = -1,
max_scroll = window.Width,
max_load_done = 0,
ww = window.Width,wh = window.Height,m_x = 0,m_y = 0,start = 0,end = 0,start_ = 0,time_dl = 0;
var scroll = 0,scroll_ = 0,scroll__ = 0,scroll___ = 0,
scr1 = 0,scroll_v = 0,scroll_a = 0,scr2 = window.Width,
cell = Math.floor((wh - text_heigh - 12)/row_count);
var list = [],list_al = [],list_ar = [],list_ge = [],
list_dr = [],list_img = [];
var ex_al_idx = -1000,
ex_length_idx = [],
ex_length_idx_ = [],
ex_length_idx__ = [],
ex_length_idx___ = [],
playlist_ex = null,
playlist_ex_maxscr = 0,
check_ex_old = -1,
ex_opt = true;
window.DlgCode = 0x0081 ;
function get_cusor_index(x){
var result = form_text.length;
while(char_index[result] > x )
result--;
return (result > 0)?result:0;
}
function refresh_char_index(gr){
char_index = [];
for(var i = 0;i < form_text.length + 1;i++)
char_index[i] = gr.EstimateLineWrap(form_text.substr(0,i),g_font,ww).toArray()[1];
}
//===========================================================================================
function on_mouse_lbtn_up(x,y,mask){
lbup =1;
lbdn = 0;
y_start = y;
hold_scroll = mouse_l_hold_f = false;
scroll = Math.round(scroll / cell / 2) * cell * 2;
}
//=============================================================================================
function on_mouse_lbtn_down(x,y,mask){
lbup =0;
lbdn = 1;
y_start = x;
g_drag = true;
mouse_l_hold_f = on_form = (y < text_heigh);
mouse_l_hold = !mouse_l_hold_f;
/*
if(y < text_heigh){
if(x < ww - text_heigh){
form_text_cusor = get_cusor_index(x);
repaint_f1 = repaint_f2;
form_text_cusor_hiden = true;
time_f.Reset();
}else if(x > ww - text_heigh){
bold_start = bold_end = form_text_cusor = 0;
form_text = "";
time_f.Reset();
}
if(mask == 1.5){
bold_start = (" " + form_text + " ").lastIndexOf(" ",form_text_cusor);
bold_end = (" " + form_text + " ").indexOf(" ",form_text_cusor+1)-1;
}else
bold_start = bold_end = form_text_cusor;
}else if(y > wh - 8){
hold_scroll = true;
scroll = (x * max_scroll / ww) - ww/2;
}else if(ex_opt){
var tmp = check(x,y);
if(tmp > -1 && tmp == ex_al_idx){
for(var i = 0;i < ex_length_idx.length;i++)
ex_length_idx[i] = 0;
ex_al_idx = -1000;
}else if(tmp > -1 ){
var m = 0;
var col_idx = Math.floor(tmp/row_count)
playlist_ex = init_album_playlist(list_dr[tmp],tmp);
ex_al_idx = tmp;
for(var i = 0;i < ex_length_idx.length;i++){
if(i > col_idx) ex_length_idx[i] = 2;
else ex_length_idx[i] = 0;
}
if(col_idx * cell * 2 < scroll )
scroll = col_idx * cell * 2;
else if((col_idx + 3)* cell * 2 > scroll + ww)
scroll += ((col_idx + 3)* cell * 2 - scroll - ww);
scroll = Math.ceil(scroll / cell / 2) * cell * 2;
repaint();
}else if(tmp <= -1.5 && playlist_ex){
var tmp_ = Math.round((-tmp - 1.5)*1000);
for(a in playlist_ex.list)
playlist_ex.list[a].chose = false;
playlist_ex.list[tmp_].chose = true;
repaint();
//fb.trace(tmp_ + " - " + tmp);
}else if(tmp <= -1.1 && playlist_ex){
}else{
for(var i = 0;i < ex_length_idx.length;i++)
ex_length_idx[i] = 0;
ex_al_idx = -1000;
}
}
*/
}
function on_size(){
if (!window.Width || !window.Height) {
return;
};
ww = window.Width;
wh = window.Height;
//if(ww == 0 || wh == 0)
// return;
var scroll_t = Math.floor(scroll/cell/2);
cell = Math.floor((wh - text_heigh - 12)/row_count);
scroll____ = scroll__ = scroll_ = scroll = scroll_t * cell * 2;
max_scroll = scroll_ + ww;
repaint_f1 = repaint_f2;
repaint();
}
function on_char(code){
time333 = (new Date()).getTime();
if(on_form){
time_s.Reset();
form_text_cusor_hiden = true;
selected_cusor = -1;
var coppy = false,paste = false,cut = false;
var input = String.fromCharCode(code);
switch(code){
case 13://ENTER
var pllist = plman.GetPlaylistItems(-1);
for(var i in list_dr)
pllist.AddRange(list_dr[i].pl)
apply_playlist(pllist);
break;
case 25:
form_his.push(form_text);
if(form_his.length > 30) form_his.shift();
if(form_his_.length > 0) form_text = form_his_.pop() + "";
break;
case 26:
form_his_.push(form_text);
if(form_his_.length > 30) form_his.shift();
if(form_his.length > 0) form_text = form_his.pop() + "";
break;
case 1://CTRL + A
bold_start = 0;
bold_end = form_text.length;
break;
case 3: // COPPY
(bold_start != bold_end) && htmlfile.parentWindow.clipboardData.setData('text',form_text.substring(bold_start,bold_end));
break;
case 24://CUT
(bold_start != bold_end) && htmlfile.parentWindow.clipboardData.setData('text',form_text.substring(bold_start,bold_end));
case 8:
save_form_his();
if(bold_start == bold_end){
form_text = form_text.substring(0,form_text_cusor-1) + form_text.substring(form_text_cusor,200);
if(form_text_cusor > 0)
form_text_cusor--;
bold_end = bold_start = form_text_cusor;
}else{
form_text = form_text.substring(0,bold_start) + form_text.substring(bold_end,200);
form_text_cusor = bold_start;
bold_end = bold_start;
}
break;
case 22://CTRL + V//PASTE
input = htmlfile.parentWindow.clipboardData.getData('text');
if(input == null) input = "";
default: //CHAR
save_form_his();
if(char_index[form_text.length] + text_heigh >= ww - 10)
break;
if(bold_start == bold_end){
form_text = form_text.substring(0,form_text_cusor) + input + form_text.substring(form_text_cusor,200);
form_text_cusor += input.length;
bold_end = bold_start = form_text_cusor;
}else{
form_text = form_text.substring(0,bold_start) + input + form_text.substring(bold_end,200);
form_text_cusor = bold_start + input.length;
bold_end = bold_start;
}
break;
}
repaint_f1 = repaint_f2;
}
}
function save_form_his(){
if(time_h.Time < 100)
return;
form_his.push(form_text);
form_his_ = [];
if(form_his.length > 30) form_his.shift();
time_h.Reset();
}
function on_key_down(vkey) {
switch(vkey){
case 0x25:
if(!on_form)return;
if(form_text_cusor > 0){
form_text_cusor--;
}
if(hold_shift){
bold_start = (form_text_cusor < shift_index)?form_text_cusor:shift_index;
bold_end = (form_text_cusor > shift_index)?form_text_cusor:shift_index;
}else
bold_start = bold_end = form_text_cusor;
break;
case 0x27:
if(!on_form)return;
if(form_text_cusor < form_text.length){
form_text_cusor++;
}
if(hold_shift){
bold_start = (form_text_cusor < shift_index)?form_text_cusor:shift_index;
bold_end = (form_text_cusor > shift_index)?form_text_cusor:shift_index;
}else
bold_start = bold_end = form_text_cusor;
break;
case 0x10:
hold_shift = true;
shift_index = form_text_cusor;
break;
case 0x11:
break;
case 13:
break;
case 40:case 38:
break;
}
repaint_f1 = repaint_f2;
form_text_cusor_hiden = true;
}
function on_key_up(vkey){
switch(vkey){
case 0x10:
hold_shift = false;
shift_index = form_text_cusor;
break;
case 0x11:
hold_ctrl = false;
break;
}
}
//=========================================================================================== Touch mod
function on_mouse_move(x,y){
if (lbdn) {
y_end = x;
y_delta = (y_end - y_start);
if (x < ww){
if (y_delta > wh/touch_sens) {
on_mouse_wheel(1);
y_start = y_end;
}
if (y_delta < -wh/touch_sens) {
on_mouse_wheel(-1)
y_start = y_end;
};
}
}
if(m_x == x && m_y == y)
return;
mouse_in = y > text_heigh;
/*
if(y < text_heigh && x < ww - text_heigh)
//window.SetCursor(32513);
//else
window.SetCursor(32512);
if(y < text_heigh && mouse_l_hold_f){
bold_start = form_text_cusor;
bold_end = get_cusor_index(x);
if(bold_start > bold_end){
var tam = bold_start;
bold_start = bold_end;
bold_end = tam;
}
repaint_f1 = repaint_f2;
}
if(m_x > ww-text_heigh && m_y < text_heigh)
repaint_f1 = repaint_f2;
if(hold_scroll){
scroll = (x * max_scroll / ww) - ww/2;
}
*/
m_x = x;m_y = y;
}
function on_mouse_leave(){
hold_scroll = mouse_hold = mouse_in = false;
repaint();
}
//=============================================================== ON PAINT//Search bar
//==========test
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, background_color);
if(ww == 0 || wh == 0)
return;
//if(!repaint_f && !repaint_main)
repaint_f = repaint_main = true;
/* if(repaint_f){
repaint_f = false;
refresh_char_index(gr);
if(bold_start < 0) bold_start = 0;
if(bold_end < 0) bold_end = 0;
if(bold_start > form_text.length) bold_start = form_text.length;
if(bold_end > form_text.length) bold_end = form_text.length;
if(form_text_cusor < 0) form_text_cusor = 0;
if(form_text_cusor > form_text.length) form_text_cusor = form_text.length;
form_text_cusor_x = char_index[form_text_cusor];
gr.DrawLine(0,text_heigh/2,ww,text_heigh/2,text_heigh,0x60000000);
on_form && form_text_cusor_hiden && (bold_start == bold_end) && gr.DrawLine(form_text_cusor_x + text_heigh/10,text_heigh/10,form_text_cusor_x + text_heigh/10,text_heigh*0.9,1,0xffffffff);
bold_end = (bold_end < form_text.length)?bold_end:form_text.length;
(bold_start != bold_end) && gr.DrawLine(char_index[bold_start] + text_heigh/10,text_heigh/2,char_index[bold_end] + text_heigh/10,text_heigh/2,text_heigh-3,0xff0099ff);
gr.GdiDrawText(form_text, g_font, 0xffffffff, text_heigh/10, text_heigh/10, ww, text_heigh, 0);
(form_text == "") && gr.GdiDrawText("Typing Search", g_font_i, 0x55888888, text_heigh/10, text_heigh/10, ww, text_heigh, 0);
gr.DrawLine(ww-text_heigh*0.8,text_heigh*0.8,ww - text_heigh*0.2,text_heigh*0.2,text_heigh/10,(m_x > ww-text_heigh && m_y < text_heigh)?0xf0ffffff:0x60ffffff);
gr.DrawLine(ww-text_heigh*0.8,text_heigh*0.2,ww - text_heigh*0.2,text_heigh*0.8,text_heigh/10,(m_x > ww-text_heigh && m_y < text_heigh)?0xf0ffffff:0x60ffffff);
}*/
if(repaint_main){
//fb.trace("on_paint_main : " + scroll_);
var time_reset = (Math.abs(scroll - scroll_) > cell *0.9);
repaint_main = false;
var hg = Math.floor((wh - text_heigh - 12)/row_count);
var width_ = 0;
var paint_continue = true;
start = Math.max(0,Math.round(scroll_ / hg / 2 - 0.5)) * row_count;
end = Math.min(start + Math.round(ww/ hg / 2 + 1.5)*row_count,list_dr.length);
var sss = (1-Math.pow(0.9,time_dl/10));
for(var i = 0;i < list_dr.length;i++){
if(Math.abs(list_dr[i].i - i )*cell > 1 ){
list_dr[i].i += (i - list_dr[i].i)*sss;
repaint();repaint_f1 = repaint_f2;
if(Math.abs(list_dr[i].i - i ) > 0.5)
time_reset = true;
if(Math.abs(list_dr[i].i - i ) < 3 && list_dr[i].al < 250)
list_dr[i].al = 255*(1 - Math.abs(list_dr[i].i - i)/3)
}
}
for(var i = start;i < end;i++){
if(list_dr[i].al == 0 || Math.abs(list_dr[i].i - i ) > row_count)
continue;
var x_ = Math.round((list_dr[i].i+0.5)/row_count - 0.5)*hg*2 - scroll_;
var y_ = hg * ((list_dr[i].i+0.5)%row_count) + text_heigh + 4 -0.5*hg ;
if(list_dr[i].alpha > 0 && !(list_dr[i].alpha >= 240 && i == check(m_x,m_y))) {
list_dr[i].alpha -= 8*time_dl/16;
repaint();
}
list_dr[i].alpha = Math.min(list_dr[i].alpha,255);//255
(list_dr[i].alpha > 0) && gr.FillGradRect(x_-0.5,y_-3,hg * 2+3,hg+3,select_angle,select_color|(list_dr[i].alpha << 24),select_color2|(list_dr[i].alpha << 24));
if(list_dr[i].imgcell && list_dr[i].imgcell.Width == (cell*2-3)){
gr.GdiAlphaBlend(list_dr[i].imgcell,x_ + 3,y_+1,2 * cell - 3,cell - 3,0,0,cell * 2-3, cell-3,list_dr[i].al);
}else if(paint_continue && list_dr[i].img_){
list_dr[i].imgcell = Draw_cell(list_dr[i].img_,list_dr[i].name + "\r\n(" + list_dr[i].pl.Count + " Tracks)");
gr.GdiAlphaBlend(list_dr[i].imgcell,x_ + 3,y_+1,2 * cell - 3,cell - 3,0,0,cell * 2-3, cell-3,list_dr[i].al);
time_r.Reset();
repaint();
paint_continue = false;
//break;
}else if(paint_continue){
list_dr[i].imgcell = Draw_cell(null,list_dr[i].name + "\r\n(" + list_dr[i].pl.Count + " Tracks)");
gr.GdiAlphaBlend(list_dr[i].imgcell,x_ + 3,y_+1,2 * cell - 3,cell - 3,0,0,cell * 2-3, cell-3,list_dr[i].al);
time_r.Reset();
repaint();
paint_continue = false;
//break;
}
}
time_reset && time_r.Reset();
var lenf_ = cell * 2 * Math.round( list_dr.length / row_count + 0.499) + ww%(cell * 2);
var scr2_ = Math.min(Math.round(ww*ww/lenf_) + 1,ww+20);
if(Math.round(list_dr.length / row_count+0.499) * (cell*2) > ww)
max_scroll = lenf_;
scr1 = scroll_/lenf_ * ww;
scr2 += (scr2_ - scr2)*sss;
if(scr2 < ww){
gr.DrawLine(0,wh-4,ww,wh-4,7,0x60000000);
gr.DrawLine(scr1 ,wh-4,scr1 + scr2,wh-4,5,0xa0ffffff);
((scr2_ - scr2)*sss > 1) && repaint();
}
}
}
//==========end test
function on_timer(timer_id){
if(window.IsVisible && ww * wh > 0){
on_timer_();
}else if(time_scroll.Time > 30 && max_load_done + 2 < list_dr.length){
main_or_form = true;
time_scroll.Reset();
on_timer_();
}
if(!window.IsVisible || ww == 0 || wh == 0)
return;
on_timer_();
}
//====================================================================================== norm timer
function on_timer_(){
//if(!window.IsVisible || ww == 0 || wh == 0)//============= my //
//return; //======== my //
var repaint_1 = false,repaint_2 = false,repaint_3 = false;
main_or_form = !main_or_form;
if(main_or_form){ ///////////////////////////////////////////////////////////
if(repaint_f1 == repaint_f2 ){
repaint_f2 = !repaint_f1;
repaint_1 = true;
}
if(time_f.Time > 500){
time_f.Reset();
repaint_1 = true;
form_text_cusor_hiden = !form_text_cusor_hiden;
}
}else{ ///////////////////////////////////////////////////////////
time_dl = time_scroll.Time;
var delta = (1-Math.pow(0.9,time_dl/12));//9
time_scroll.Reset();
if(form_text_b != form_text && time_s.Time > 150){
time_s.Reset();
repaint_2 = true;
form_text_b = form_text;
time_s.Reset();
search(form_text);
}
var id = check(m_x,m_y);
//if(id > -1 && mouse_in && list_dr[id].alpha < 255){
if(id > -1 && list_dr[id].alpha < 255){ //=============== this on lbdn repaint(stop infinity repaint)
//list_dr[id].alpha += 24*time_dl/16;//16
list_dr[id].alpha += 24*time_dl/16;//16
repaint_2 = true; //true
}
if(scroll < 0)
scroll = 0;
else if(scroll + ww > max_scroll)
scroll = max_scroll - ww;
if(Math.abs(scroll - scroll_) > 0.4){
scroll___ += (scroll - scroll___) * delta;
scroll__ += (scroll___ - scroll__) * delta;
scroll_ += (scroll__ - scroll_) * delta;
repaint_2 = true;//true
}else
scroll___ = scroll__ = scroll_ = scroll;
//ex_length_idx_
var col_idx_s = Math.max( Math.floor(start/row_count) - 3,0),
col_idx_e = Math.min(Math.floor(end/row_count) + 2,ex_length_idx.length);
var al_ex = false;
for(var i = 0;i < ex_length_idx.length;i++){
if(Math.abs(ex_length_idx[i] - ex_length_idx_[i]) > 0.001){
ex_length_idx___[i] += (ex_length_idx[i] - ex_length_idx___[i]) * delta;
ex_length_idx__[i] += (ex_length_idx___[i] - ex_length_idx__[i]) * delta;
ex_length_idx_[i] += (ex_length_idx__[i] - ex_length_idx_[i]) * delta;
al_ex = repaint_2 = true;
}else
ex_length_idx___[i] = ex_length_idx__[i] = ex_length_idx_[i] = ex_length_idx[i];
}
if(playlist_ex && Math.abs(playlist_ex.scroll_ - playlist_ex.scroll) > 0.01){
playlist_ex.scroll___ += (playlist_ex.scroll - playlist_ex.scroll___) * delta;
playlist_ex.scroll__ += (playlist_ex.scroll___ - playlist_ex.scroll__) * delta;
playlist_ex.scroll_ += (playlist_ex.scroll__ - playlist_ex.scroll_) * delta;
al_ex = repaint_2 = true;
} else if(playlist_ex){
playlist_ex.scroll____ = playlist_ex.scroll___ = playlist_ex.scroll__ = playlist_ex.scroll_ = playlist_ex.scroll;
}
if(playlist_ex && check_ex(m_x,m_y) !=check_ex_old){
check_ex_old = check_ex(m_x,m_y);
repaint_2 = true;
}
end = Math.min(end,list_dr.length);
start = Math.max(0,start);
var repaint_temp = repaint_2;
//fb.trace("time_max_img : " + time_max_img)
if(time_r.Time > time_reset_loadimg && Math.abs(scroll - scroll_) < postion_load_img * cell){
var repaint_temp = repaint_2,i = 0;
if(Math.abs(scroll - scroll_) < 1 && !al_ex)
end = list_dr.length;
for(i = start;i < end;i++){
if(time_scroll.Time > 3) break;
else if(list_dr[i].state == 3)
continue;
else if(list_dr[i].state == 0 ){
var tmp_ = load_image(list_dr[i].pl.Item(0),true);
list_dr[i].id = tmp_[0];
list_dr[i].string_cache = tmp_[1];
if(list_dr[i].id % 1 == 0.5){
list_dr[i].img_ = list_img[Math.floor(list_dr[i].id)].img;
list_dr[i].state = 2;
i--;
continue;
}else if(list_dr[i].id == -1){
list_dr[i].Time = fb.CreateProfiler();
list_dr[i].state = -1;
}else if(list_dr[i].id == 0){
list_dr[i].state = 3;
continue;
}else if(list_dr[i].id == -1000){
list_dr[i].img_ = tmp_[2];
list_dr[i].state = 3;
max_load_done = i;
}else{
repaint_2 = true;
time_r.Reset();
list_dr[i].state = 1;
}
break;
}else if(list_dr[i].state == 2 && list_dr[i].img_){
max_load_done = i;
list_dr[i].state = 3;
list_dr[i].imgcell = Draw_cell(list_dr[i].img_,list_dr[i].name + "\r\n(" + list_dr[i].pl.Count + " Tracks)");
repaint_2 = true;
break;
}else if((list_dr[i].state == -1 && list_dr[i].Time.Time > 400 )
||(list_dr[i].state < -1 && list_dr[i].Time.Time > 2000 ) ){//wait to load image from script
var tmp_ = load_image(list_dr[i].pl.Item(0),false);
list_dr[i].id = tmp_[0];
list_dr[i].string_cache = tmp_[1];
if(list_dr[i].id > 0){
repaint_2 = true;
time_r.Reset();
list_dr[i].state = 1;
break;
}else{
list_dr[i].Time.Reset();
list_dr[i].state--;
if(list_dr[i].state < -6)
list_dr[i].state = 3;
}
}
}
}
if(Math.abs(scroll - scroll_) < 1){
repaint_2 = repaint_temp;
}
if(repaint_main1 == repaint_main2){
repaint_main2 = !repaint_main1;
repaint_2 = true;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(repaint_1 && repaint_2){
repaint_f = true;
repaint_main = true;
window.Repaint();
}else if(repaint_1){
repaint_f = true;
window.RepaintRect(0,0,ww,text_heigh);
}else if(repaint_2){
repaint_main = true;
window.RepaintRect(0,text_heigh,ww,wh-text_heigh);
}
}
function repaint(){
repaint_main1 = repaint_main2;
}
function read_list(reload){
list = [];
read_library(reload);
}
function match(input, string){
var temp = "";
input = input.toLowerCase();
string = string.toLowerCase();
while(input !=(temp = input.replace(" "," ")))
input = temp;
while(string !=(temp = string.replace(" "," ")))
string = temp;
var str = string.split(" ");
for(var i in str){
if(str[i] == "" || input !=(temp = input.replace(str[i],"")))
input = temp;
else
return false;
}
return true;
}
function search(string){
list_dr = [];
var back_s = -1.5;
var bbb = Math.ceil(row_count * ww /cell / 2);
for(var i in list){
if(match(list[i].name,string)){
back_s = list_dr.length;
list_dr.push(list[i]);
if(Math.abs(list[i].i - back_s) > row_count * (ww /cell / 2))
list[i].al = 0;
}else{
list[i].i = (back_s - i < row_count)?(back_s + 0.5):i-row_count;
list[i].al = 0;
}
}
scroll___ = scroll__ = scroll_ = scroll = 0;
repaint();
ex_al_idx = -1000;
var max_row_ex = Math.ceil(list_dr.length/row_count) + 1;
for(var i = 0;i < max_row_ex;i++)
ex_length_idx___[i] = ex_length_idx__[i] = ex_length_idx_[i] = ex_length_idx[i] = 0;
}
function check(x,y){
if(!mouse_in || y < text_heigh || y > wh - 7)
return -1;
var row = Math.floor((y - text_heigh - 4)/cell);//ex_al_idx
var col = Math.floor((x + scroll_)/(cell*2));
var row_ex_idx = Math.floor(ex_al_idx/row_count);
if(playlist_ex && (col == row_ex_idx + 1 || col == row_ex_idx + 2)){
//cell * 1.6 + y + 20*i - playlist_ex.scroll_ * 20;
//playlist_ex
var track_idx = Math.floor((y - (1.6*cell + 20))/20 + playlist_ex.scroll_);
if(track_idx > -1 && track_idx < playlist_ex.list.length){
return (-1.500 - track_idx/1000);
}else return -1.1;
}else if( playlist_ex && ex_al_idx > -1 && col > row_ex_idx + 2){
col -= ex_length_idx[col];
}
if(row < 0 || row > row_count-1)
return -1;
var index = row + row_count * col;
if(index < list_dr.length && index >=0){
return Math.floor(index);
}else
return -1;
}
//=========================================================================================== on mouse wheel
function on_mouse_wheel(step){
if(utils.IsKeyPressed(0x11)){
var scroll_t = Math.floor(scroll/cell/2) * row_count;
row_count -= step;
row_count = Math.max(1,row_count);
row_count = Math.min(10,row_count);
window.SetProperty("Row",row_count);
cell = Math.floor((wh - text_heigh - 12)/row_count);
scroll____ = scroll__ = scroll_ = scroll = Math.round(scroll_t/row_count) * cell * 2;
max_scroll = scroll_ + ww;
repaint_f1 = repaint_f2;
repaint();
return;
}else if(check_ex(m_x,m_y) > -2){
scr_tmp = playlist_ex.scroll;
scr_tmp -= step * scroll_step; //2
scr_tmp = Math.min(scr_tmp,playlist_ex.list.length - playlist_ex.max_idx);
scr_tmp = Math.max(0,scr_tmp);
if(scr_tmp != playlist_ex.scroll){
playlist_ex.scroll = scr_tmp;
return;
}else if(playlist_ex.scroll != playlist_ex.scroll_){
return;
}
}
scroll -= step * cell *scroll_step;//2
var al_ex = 0;//.delta
if(playlist_ex && playlist_ex.delta > 0) al_ex = playlist_ex.delta;
//fb.trace(al_ex)
if(scroll < 0 || Math.round(list_dr.length / row_count + 0.499 + al_ex) * (cell*2) < ww)//|| Math.round(list_dr.length / row_count + 0.499) * (cell*2) < ww
scroll = 0;
if(scroll > max_scroll - ww)
scroll = max_scroll - ww;
//time_reset_loadimg = 15;
}
function check_ex(x,y){
var a = check(x,y);
if(a <= -1.5)
return Math.round((-a-1.5)*1000);
else if(a == -1.1)
return - 1;
else
return -2;
}
//================================================================================ On mouse dbclk
function on_mouse_lbtn_dblclk(x,y,mask){
var a = check(x,y);
if(a > -1){
switch(list_dr[a].type){
case "pl":
break;
case "al":
add_playlist(list_dr[a].pl);
//apply_playlist(list_dr[a].pl);
//on_mouse_lbtn_down(x,y,mask);
break;
}
}else if(a <= -1.5){
var idx = Math.round((-a-1.5)*1000);
if(playlist_ex){
apply_playlist(playlist_ex.pl,idx);
}
}else if(y < text_heigh && x < ww - text_heigh){
on_mouse_lbtn_down(x,y,1.5);
}
}
//========================================================================================= Album List
function init_album_playlist(pl,idx){
var text_render = gdi.CreateStyleTextRender();
var ob = new Object();
var TrackTitleFormat = fb.TitleFormat("[%tracknumber%] ^^ $caps(%title%) ^^ $caps(%artist%)");
var pllength = pl.pl.Count;
ob.list = [];
ob.ob = pl;
ob.name = pl.name.split("\r\n")[1];
ob.artist = pl.name.split("\r\n")[0];
ob.idx = idx;
ob.pl = pl.pl;
ob.tr_c = pl.pl.Count;
ob.scroll = 0;ob.scroll_ = 0;ob.scroll__ = 0;ob.scroll___ = 0;
ob.pl.OrderByFormat(fb.TitleFormat("%tracknumber% - %title%"),1);
if(fb.IsPlaying)
ob.nowplaying = ob.pl.Find(fb.GetNowPlaying());
ob.col_idx = Math.floor(idx/row_count);
pl.pl.img_ && (ob.img = pl.pl.img_.Resize(cell * 1.4,cell * 1.4,7).CreateRawBitmap());
ob.x = 0;ob.y = 0;ob.w = 0;ob.h = 0;
for(var i = 0;i < pllength;i++){
var info = TrackTitleFormat.EvalWithMetadb(ob.pl.Item(i)).split(" ^^ ");
ob.list[i] = new Object();
ob.list[i].chose = false;
var imgtemp = gdi.CreateImage(cell * 4, 20);
var gp = imgtemp.GetGraphics();
gp.SetTextRenderingHint(3);
gp.SetSmoothingMode(4);
gp.SetInterpolationMode(7);
text_render.GlowText( 0xffffffff|0x00 , 0xffffffff|0x00, 0);
text_render.RenderStringRect(gp, info[0] , g_font_al1, 08, 0, 20, 20, 0);
text_render.GlowText( 0xffffffff|0x00 , 0x00ffffff|0x00, 0);
text_render.RenderStringRect(gp, info[1] , g_font_al1, 45, 0, cell*2.8, 20, 0);
text_render.GlowText( 0xffffffff|0x00 , 0x00ffffff|0x00, 0);
text_render.RenderStringRect(gp, info[2] , g_font_al1, cell*3.0, 0, cell * 0.9, 20, 1);
imgtemp.ReleaseGraphics(gp);
ob.list[i].tr_render = DrawBitmap ? imgtemp.CreateRawBitmap() : imgtemp.Clone(0,0,imgtemp.Width,imgtemp.Height);
ob.list[i].tr = info[0];ob.list[i].tl = info[1];ob.list[i].ar = info[2];
}
ob.max_idx = Math.floor(cell * (row_count - 1.6)/20);
fb.trace(ob.max_idx);
return ob;
}
//========================================================================Selected Album
function draw_album_playlist(gr,ob,x,y,w,h){
ob.x = x + cell * 1.6;ob.y = y-5;ob.w = w - cell * 1.6;ob.h = h;
var list_lg = ob.list.length;
gr.SetTextRenderingHint(3);
gr.SetSmoothingMode(4);
gr.SetInterpolationMode(7);
var tmp = check_ex(m_x,m_y);
var delta = (w + 3) /2 /cell;
var y_ = cell * (ob.idx%row_count + 0.5) + text_heigh + 4 ;
var thx = x+1,thy = y_,ver = cell * 0.125 * delta;
var point = [x,y + 7,thx,thy-ver + 7,thx - ver,thy + 7,thx,thy + ver + 7,x,y+h + 6,x + w,y + h + 6,x + w,y + 7];
gr.FillPolygon(0x60000000,0,point);//cover_back_color 0x60000000
if(ob.img){
gr.GdiAlphaBlend(ob.img,x+3,y+9,Math.min(cell * 1.4,(w - 10)), cell*1.3,0,0,Math.min(cell * 1.4,(w - 10)),cell * 1.4,255);
ob.ob.img_ && gr.DrawImage(ob.ob.img_,x+3,y+9,Math.min(cell * 1.4,(w - 10)),cell*1.3,0,0,ob.ob.img_.Width * Math.min(1,(w - 10)/cell/1.4),ob.ob.img_.Height,0,255);
}else if(ob.ob.img_){
ob.img = ob.ob.img_.Resize(cell * 1.4,cell * 1.4,7).CreateRawBitmap();
}else if(stub_image){
gr.DrawImage(stub_image,x+5,y+7,Math.min(cell * 1.4,(w - 10)),cell*1.4,0,0,stub_image.Width * Math.min(1,(w - 10)/cell/1.4),stub_image.Height,0,255);
}
gr.GdiDrawText(ob.name,g_font_al2,0xffffff,x + 5 + cell * 1.5,y + 15,w - cell * 1.6,30,0x8000);//0xffffff
gr.GdiDrawText(ob.artist,g_font_al3,0xffffff,x + 5 + cell * 1.5,y + 45,w - cell * 1.6,30,0);
gr.GdiDrawText(ob.tr_c + " Tracks",g_font_al4,0xaaaaaa,x + 5 + cell * 1.5,y + 65,w - cell * 1.6,30,0);//0xaaaaaa
for(var i = 0;i < list_lg;i++){
y_ = cell * 1.6 + y + 20*i - ob.scroll_ * 20;
if(y_ > h) break;
else if(y_ < cell * 1.6 + 10) continue;
var render = ob.list[i].tr_render
var img_w = Math.min(render.Width,w),img_h = render.Height;
var y_1 = Math.max(y_,cell * 1.6 + 10),
y_2 = Math.min(h + 20,y_ + 20),
y_w = y_2 - y_1;
if(ob.list[i].chose){
gr.FillGradRect( x + 3, y_, w - 6, 20, 0, RGBA(255,255,255,40), RGBA(255,255,255,80));//RGBA(255,255,255,40), RGBA(255,255,255,80));
}else if(playlist_ex.nowplaying == i){
gr.FillGradRect( x + 3, y_, w - 6, 20, 0, RGBA(255,255,255,40), RGBA(255,255,255,80));//RGBA(255,255,255,40), RGBA(255,255,255,80));
}
//if()playlist_ex.nowplaying
DrawBitmap && gr.GdiAlphaBlend(ob.list[i].tr_render,x,y_1,img_w, y_w,0,0,img_w,y_w,255);
!DrawBitmap && gr.DrawImage(ob.list[i].tr_render,x,y_1,img_w, y_w,0,0,img_w,y_w,0,255);
}
/*
if(list_lg > ob.max_idx){
var st = y + cell * 1.6 - 5,ed = y + h - 5,
st2 = st + cell * (row_count - 1.6) * ob.scroll_ / list_lg,
ed2 = st + cell * (row_count - 1.6) * (ob.scroll_ + ob.max_idx) / list_lg;
gr.DrawLine(x + w - 5,st,x + w - 5,ed,7,0x30000000);
gr.DrawLine(x + w - 5,st2,x + w - 5,ed2,5,0x50ffffff);
}*/
if((ob.scroll * 20 > 0) && (cell * 1.6 + y + 20 * list_lg - ob.scroll * 20 < h))
ob.scroll--;
}
function read_library(reload){
var Time = fb.CreateProfiler("Time Load library");
var TitleFormat = "[%album artist%]^^[%album%]";
var FoobarTitleFormat = fb.TitleFormat(TitleFormat);
var pl_name = "", pl_idx = -1,list_;
for(var i=0; i < plman.PlaylistCount; i++) {
pl_name = plman.GetPlaylistName(i);
if(pl_name == "Library view") {
pl_idx = i;
break;
}
}
if(pl_idx < 0) {
pl_idx = plman.PlaylistCount;
fb.CreateAutoPlaylist(pl_idx,"WSH Album Filter","ALL",TitleFormat);
list_ = plman.GetPlaylistItems(pl_idx);
}else if(reload){
plman.RemovePlaylist(pl_idx);
fb.CreateAutoPlaylist(pl_idx,"WSH Album Filter","ALL",TitleFormat);
list_ = plman.GetPlaylistItems(pl_idx);
}else
list_ = plman.GetPlaylistItems(pl_idx);
var string_compare = "123456789123456789",string = "",k = 0,i = 0,item,count = 0;
var a = "",b = "",tmp,total = list_.Count;
Time.print();Time.Reset();
while(k < total){
string = FoobarTitleFormat.EvalWithMetadb(list_.Item(k));
tmp = string.split("^^");
a = tmp[0];b = tmp[1];
if(a.length < 3){
k++;
continue;
}
if(string_compare != string){
string_compare = string;
item = new Object();
item.name = a + "\r\n" + b;
item.type = "al";
item.al = 255;
item.i = list.length - 3;
item.i_ = item.i;
item.alpha = 0;
item.state = 0;
item.id = 0;
item.img = null;
item.pl = plman.GetPlaylistItems(-1);
item.pl.Add(list_.Item(k));
count = 1;
(min_song == 1) && list.push(item);
}else{
count++;
item.pl.Add(list_.Item(k));
if(count == min_song)
list.push(item);
}
k++;
}
time_scroll.Reset();
Time.print();
}
//=================================================== add apply to playlist
function apply_playlist(playlist,start){
var pl_idx = check_playlist("Library view");
if(pl_idx == -1){
pl_idx = plman.PlaylistCount;
plman.CreatePlaylist(pl_idx,"Library view");
}else
fb.RunMainMenuCommand("Edit/Clear");
plman.ActivePlaylist = pl_idx;
var playlist_ = playlist.Clone();
//!start && playlist_.OrderByFormat(fb.TitleFormat("$if([%album artist%],%album artist%,zzzz)|$if([%album%],[%date%]%album%,zzzz)|$if(%track number%,%track number%,zzzz)|$sub(5,%rating%)|%title%"),1);
!start && playlist_.OrderByFormat(fb.TitleFormat("%path%"),1);
plman.InsertPlaylistItems(pl_idx,1,playlist_);
plman.ExecutePlaylistDefaultAction(pl_idx,start?start:0);
fb.RunMainMenuCommand("Edit/Remove Duplicates");
}
function add_playlist(playlist){
var pl_idx = check_playlist("Library view");
plman.ActivePlaylist = pl_idx;
playlist.OrderByFormat(fb.TitleFormat("%path%"),1);
//plman.InsertPlaylistItems(fb.ActivePlaylist,plman.PlaylistItemCount(fb.ActivePlaylist),playlist);
plman.InsertPlaylistItems(plman.ActivePlaylist,0,playlist);
plman.ExecutePlaylistDefaultAction(pl_idx,0);
fb.RunMainMenuCommand("Edit/Remove Duplicates");
}
function on_mouse_mbtn_up(x,y,mask){
var a = check(x,y);
if(a > -1){
switch(list_dr[a].type){
case "pl":
break;
case "al":
add_playlist(list_dr[a].pl);
break;
}
}
}
var textrender = gdi.CreateStyleTextRender();
textrender.EnableShadow(true);
//textrender.GlowText( 0xffffffff|0x00 , 0x00ffffff|0x00, 0);
textrender.GlowText( text_color|0x00 , 0x00ffffff|0x00, 0); //======================= Text color
textrender.DiffusedShadow(RGBA(0,0,0,50)|0x0,1,1,1);
//=============================================================Album Art
function Draw_cell(image,string){
if(cell_null?(cell_null.Width != cell * 2-3):true)
install_cell();
var tmp_img = cell_null.Clone(0,0,cell * 2-3, cell-3);
var gp = tmp_img.GetGraphics();
gp.SetTextRenderingHint(3);
gp.SetSmoothingMode(4);
gp.SetInterpolationMode(7);
image && gp.DrawImage(image,3, 2, cell+15, cell-7, 0, 0, image.Width, image.Height, 0,255);
textrender.RenderStringRect(gp, string , g_font_c, cell + 35, 10, cell - 40, cell, 0);
return DrawBitmap ? tmp_img.CreateRawBitmap() : tmp_img;
}
function on_load_image_done(tid,image){
for(var i in list){
if(!list[i].id) continue;
if(list[i].id == tid && list[i].state == 1){
list[i].state = 2;
list[i].img_ = image;
repaint_main1 = repaint_main2;
var img_cache = new Object();
img_cache.img = image;
img_cache.string = list[i].string_cache;
list_img.push(img_cache);
break;
}
}
}
var notifi_nostub_img = false;
function install_cell(){
try{
stub_image = gdi.Image(window.GetProperty("Stub_Image_Path",".\\themes\\album_stub.png"));
}catch(err){
stub_image = null;
}
cell_null = gdi.CreateImage(cell * 2-3, cell-3);
var gp = cell_null.GetGraphics();
gp.SetTextRenderingHint(3);
gp.SetSmoothingMode(4);
gp.SetInterpolationMode(7);
gp.FillGradRect(0,0,cell * 2-3, cell-3,45,cover_back_color,back_shadow_color,1);//0x55000000,0x33000000,1); //================ cover back cover
stub_image && gp.DrawImage(stub_image,1, 1, cell - 5, cell - 5, 0, 0, stub_image.Width ,stub_image.Height, 0,255);
cell_null.ReleaseGraphics(gp);
cell_null_gr = DrawBitmap ? cell_null.CreateRawBitmap() : cell_null;
}
function on_mouse_rbtn_up(x, y){
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var _menu1 = window.CreatePopupMenu();
var Context = fb.CreateContextMenuManager();
var idx;
if(y < text_heigh){
(form_his.length > 0) && _menu.AppendMenuItem(MF_STRING, 1, "Undo ");
(form_his_.length > 0) && _menu.AppendMenuItem(MF_STRING, 2, "Redo ");
(bold_start != bold_end)&& _menu.AppendMenuItem(MF_STRING, 3, "Coppy ");
(bold_start != bold_end)&& _menu.AppendMenuItem(MF_STRING, 4, "Cut ");
(htmlfile.parentWindow.clipboardData.getData('text') != null) && _menu.AppendMenuItem(MF_STRING, 5, "Paste ");
}else{
var check__ = check(x,y);
if(check__ > -1) {
Context.InitContext(list_dr[check__].pl);
Context.BuildMenu(_menu, 100, -1);
on_mouse_move(x,y);
}
}
_menu1.AppendMenuItem(MF_STRING, 8, "Refresh library");
_menu1.AppendMenuItem(MF_STRING, 7, "Show Properties ");
_menu1.AppendMenuItem(MF_STRING, 6, "Show Script");
_menu.AppendMenuSeparator();
_menu1.AppendTo(_menu,MF_STRING, "Preferences");
idx = _menu.TrackPopupMenu(x,y);
switch(idx) {
case 0:break;
case 1:
on_char(26);
break;
case 2:
on_char(25);
break;
case 3:
on_char(3);
break;
case 4:
on_char(24);
break;
case 5:
on_char(22);
break;
case 6:
window.ShowConfigure();
break;
case 7:
window.ShowProperties();
break;
case 8:
read_list(true);
search(form_text);
break;
default:
(idx > 0) && Context.ExecuteByID(idx - 100);
break;
}
Context.Dispose();
_menu.Dispose();
return true;
}
function check_playlist(name){
var pl_name = "", pl_idx = -1;
for(var i=0; i < plman.PlaylistCount; i++) {
pl_name = plman.GetPlaylistName(i);
if(pl_name == name) {
pl_idx = i;
break;
}
}
return pl_idx;
}
function getpath(path){
var img_path = "";
var path_,temp,subFlds,tmp;
for(var iii = 0;iii<2;iii++){
if(tmp = getpath_(iii==0?path:(path + "..\\")))
return tmp;
try{
subFlds = new Enumerator(fso.GetFolder((iii==0?path:(path + "..\\"))).SubFolders);
}catch(err){return null};
for (; !subFlds.atEnd(); subFlds.moveNext()) {
temp = subFlds.item()+"\\";
if(temp.toLowerCase().match(cover_path)){
if(tmp = getpath_(temp))
return tmp;
}
}
}
return null;
}
function getpath_(temp){
var img_path = "",path_;
for(var iii in cover_img){
path_ = utils.Glob(temp + cover_img[iii]).toArray();
for(var j in path_){
if(path_[j].toLowerCase().indexOf(".jpg") > -1 || path_[j].toLowerCase().indexOf(".png") > -1 ||path_[j].toLowerCase().indexOf(".gif") > -1 ){
return path_[j];
}
}
}
return null;
}
function load_imagecache(string){
for(var i = 0;i < list_img.length;i++){
if(list_img[i].string == string)
return i;
}
return -1;
}
function load_image(metadb,first,path_){
if(!path_){
var tran = false;
var path = fb.TitleFormat("$directory_path(%path%)\\").EvalWithMetadb(metadb);
path_ = getpath(path);
if(!path_)
path_ = getpath_(fb.FoobarPath + "cache\\artist_pic\\" + fb.TitleFormat("[%artist%]\\").EvalWithMetadb(metadb));
if(!path_){
return 0;
}
}
var string = processpath(path_),
tmp = load_imagecache(string);
if(tmp > -1){
time_reset_loadimg = 0;
return Array(tmp + 0.5,string);
}else if(fso.FileExists(fb.FoobarPath + "cache\\album\\" + string)){ //Image cache
time_reset_loadimg = 0;
if(Load_async)
return Array(gdi.LoadImageAsync(window.ID,fb.FoobarPath + "cache\\album\\" + string),string);
else {
var img = gdi.Image(fb.FoobarPath + "cache\\album\\" + string);
var img_cache = new Object();
img_cache.img = img;
img_cache.string = string;
list_img.push(img_cache);
return Array(-1000,string,img);
}
}else if(first && fso.FileExists(path_)){ //jscript resize and save image cache
var comm = "wscript //E:jscript \"" + fb.FoobarPath + "cache\\LoadIMG.js\" \""
+ fb.FoobarPath + "\" \""+ path_ + "\" \"" + string + "\" \"" + tran + "\"";
WshShell.Run(comm,false,false);
time_reset_loadimg = 150;
return Array(-1,string);
}
return Array(0,string);
}
function processpath(path){
var str_return = "";
path = path.toLowerCase();
var length = path.length;
for(var i = 0;i < length; i++){
var charcode = path.charCodeAt(i);
if(charcode > 96 && charcode < 123)
str_return += path.charAt(i);
else if(charcode > 47 && charcode < 58)
str_return += path.charAt(i);
else if(charcode == 46)
str_return += path.charAt(i);
}
return str_return;
}
var nowmetadb = null;
function on_playback_new_track(metadb){
nowmetadb = metadb;
if(playlist_ex){
playlist_ex.nowplaying = playlist_ex.pl.Find(metadb);
repaint();
}
}
function on_playback_stop(reason){
nowmetadb = null;
playlist_ex && (playlist_ex.nowplaying = -1);
}
function on_load(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists(fb.FoobarPath + "cache"))
fso.CreateFolder(fb.FoobarPath + "cache");
if(!fso.FolderExists(fb.FoobarPath + "cache\\album"))
fso.CreateFolder(fb.FoobarPath + "cache\\album");
if(!fso.FileExists(fb.FoobarPath + "cache\\LoadIMG.js")){
var data = "var fso = new ActiveXObject(\"Scripting.FileSystemObject\");\r\n"
+ "var Img = new ActiveXObject(\"WIA.ImageFile.1\");\r\n"
+ "var IP = new ActiveXObject(\"WIA.ImageProcess.1\");\r\n"
+ "IP.Filters.Add(IP.FilterInfos(\"Scale\").FilterID);//ID = 1\r\n"
+ "IP.Filters.Add(IP.FilterInfos(\"Crop\").FilterID);//ID = 2\r\n"
+ "IP.Filters.Add(IP.FilterInfos(\"Convert\").FilterID);//ID = 3\r\n"
+ "function resize_image(path,string,tranparent)\r\n"
+ "{\r\n"
+ " var cachesize = 200;\r\n"
+ " var img_w = cachesize,img_h = cachesize,cr_x = 0,cr_y = 0;\r\n"
+ " try{\r\n"
+ " Img.LoadFile(path);\r\n"
+ " }catch(err){\r\n"
+ " return false;\r\n"
+ " }\r\n"
+ " if (Img.Width > Img.Height){\r\n"
+ " img_w *= Img.Width / Img.Height;\r\n"
+ " cr_x = (img_w - img_h)/2;\r\n"
+ " }else { \r\n"
+ " img_h *= Img.Height / Img.Width;\r\n"
+ " cr_y = (img_h - img_w)/2;\r\n"
+ " }\r\n"
+ " IP.Filters(1).Properties(\"MaximumWidth\") = img_w;\r\n"
+ " IP.Filters(1).Properties(\"MaximumHeight\") = img_h;\r\n"
+ " if(tranparent == \"true\"){\r\n"
+ " IP.Filters(3).Properties(\"FormatID\").Value = '{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}';\r\n"
+ " }else{\r\n"
+ " IP.Filters(3).Properties(\"FormatID\").Value = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}';\r\n"
+ " IP.Filters(3).Properties(\"Quality\").Value = 80; \r\n"
+ " }\r\n"
+ " IP.Filters(2).Properties(\"Left\") = cr_x;\r\n"
+ " IP.Filters(2).Properties(\"Top\") = cr_y;\r\n"
+ " IP.Filters(2).Properties(\"Right\") = cr_x;\r\n"
+ " IP.Filters(2).Properties(\"Bottom\") = cr_y;\r\n"
+ " Img = IP.Apply(Img);\r\n"
+ " try{\r\n"
+ " if(fso.FileExists(WScript.arguments(0) + \"cache\\\\album\\\\\" + string))\r\n"
+ " fso.DeleteFile(WScript.arguments(0)+ \"cache\\\\album\\\\\" + string);\r\n"
+ " Img.SaveFile(WScript.arguments(0) + \"cache\\\\album\\\\\" + string);\r\n"
+ " }catch(err){\r\n"
+ " return false;\r\n"
+ " }\r\n"
+ " return true;\r\n"
+ "}\r\n"
+ "resize_image(WScript.arguments(1),WScript.arguments(2),WScript.arguments(3));";
var file = fso.CreateTextFile(fb.FoobarPath + "cache\\LoadIMG.js", true,65001);
file.WriteLine(data);
file.Close();
}
}
on_load();
var t____ = window.SetTimeout(function(){
window.ClearTimeout(t____);
read_list();
search("");
},200);
function on_library_items_added(){
read_list(true);
search(form_text);
}
function on_library_items_removed(){
read_list(true);
search(form_text);
}
seriousstas, этот скрипт никогда процессор и не грузил.seriousstas:с ним загрузка проца - "0"
Отличный скрипт в итоге получился! Просто, легко и красиво. Пора уже репозиторий на каком-нибудь облаке с вашими работами открыть: зашел и все наработки в одном местеkgena_ua:Если этого мало - сделаем как Вы написали.
решил по своему, сумаcшедшая DUI сборка вырисовывается на всех этих скриптах. На днях выложу. Есть проблема -И опять про "склейку" скриптов. Я пока не могу определится как сохранять файлы в скрипте с картинками - через встроенную функцию, или через внешний скрипт. В первом случае есть некоторая задержка (подвисание) .
296 строка: return path.indexOf('://') > 0 ? fb.TitleFormat("[" + field + "]").Eval(true) : fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
заменил просто на
return fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
if (fb.TitleFormat($if($strstr(%_path%,'://'))) {
window.MinHeight=window.MaxHeight=4;
} else {
window.MinHeight=window.MaxHeight=45;
}
var ww = 0, wh = 0;
var g_syscolor = 0;
metadb = fb.GetNowPlaying();////fb.GetFocusItem()
if (metadb) on_metadb_changed();
if(fb.TitleFormat("%path%").EvalWithMetadb(metadb).indexOf("://")!=-1) {
window.MinHeight=window.MaxHeight=3;
} else {
window.MinHeight=window.MaxHeight=60;
}
function get_colors() {
g_syscolor = utils.GetSysColor(15);
}
get_colors();
function on_paint(gr) {
gr.FillSolidRect(0, 0, window.Width, window.Height, g_syscolor);
}
function on_playlist_switch() {
on_metadb_changed();
window.Repaint();
}
function on_playback_new_track() {
on_metadb_changed();
window.Repaint();
}
function on_playback_stop() {
on_metadb_changed();
window.Repaint();
}
function on_colors_changed() {
get_colors();
window.Repaint();
}
function on_mouse_rbtn_up(x, y) {
return true;
}
function on_metadb_changed(metadb) {
if (metadb) on_metadb_changed
}
Вернуться в Секреты foobar2000