Список разделов › foobar2000 › Секреты foobar2000
Aliado_71, за размер отвечает переменная star_size (star_size = window.GetProperty(" star: size", 20); ). Сделать значение зависимым от чего-то можно, только от "чего". Если при разворачивании плеера во весь экран изменяется и размер панели, где находится скрипт, то можно привязаться к высоте панели.....Aliado_71:как сделать что бы звездочки масштабировались если разворачивать плеер во весь экран
// ==PREPROCESSOR==
// @name "Rating & File attributes"
// @author "kgena_ua"
// @version "16032017"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
// foo_playcount.dll required
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)); }
function getRed(color) {return ((color >> 16) & 0xff);}
function getGreen(color) {return ((color >> 8) & 0xff);}
function getBlue(color) {return (color & 0xff);}
function RGBA_color(c) {
return RGBA(getRed(c), getGreen(c), getBlue(c), b_hover_alpha);
}
var font_name = window.GetProperty(" font name", "Arial");
var font_size = window.GetProperty(" font size", 10);
var font_style = window.GetProperty(" font style", 0);
var font;
get_font();
function get_font(){
font = gdi.Font(font_name, font_size, font_style);
}
var ww, wh;
var fso = new ActiveXObject("Scripting.FileSystemObject");
DT_LEFT = 0x00000000;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
ColorTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
}
ColorTypeDUI = {
text: 0,
background: 1,
highlight: 2,
selection: 3
}
function get_color(){
if (window.InstanceType == 0){
bgcolor = window.GetColorCUI(ColorTypeCUI.background);
color1 = window.GetColorCUI(ColorTypeCUI.text);
color2 = window.GetColorCUI(ColorTypeCUI.selection_text);
color_error = RGB(255,100,0);
} else if (window.InstanceType == 1) {
bgcolor = window.GetColorDUI(ColorTypeDUI.background);
color1 = window.GetColorDUI(ColorTypeDUI.text);
color2 = window.GetColorDUI(ColorTypeDUI.highlight);
color_error = RGB(255,100,0);
}
window.Repaint();
}
get_color();
function on_colors_changed(){
get_color();
}
String.prototype.repeat = function(n) {
return new Array(n + 1).join(this);
}
window.SetProperty(" - user", "");
if (window.GetProperty(" - user") != "" ) window.SetProperty(" - user", "");
window.SetProperty("-".repeat(50), "");
if (window.GetProperty("-".repeat(50)) != "" ) window.SetProperty("-".repeat(50), "");
var rating = 0, TAGrating, DBrating, nrating = 0;
var rating_mode = window.GetProperty("rating_mode", 0);
var rating_5 = window.GetProperty("set rating 5", false);
var x_text = window.GetProperty(" text: x", 0);
var y_text = window.GetProperty(" text: y", "");
var text = window.GetProperty(" text", true);
var x_star = window.GetProperty(" star: x", 20);
var y_star = window.GetProperty(" star: y", 20);
var star_size = window.GetProperty(" star: size", 20);
var offset = star_size + 3;
var shadow = window.GetProperty(" shadow", true);
var fade_effect = window.GetProperty("fade effect", true);
var no_rating_transparent = window.GetProperty(" no rating image transparent (0-255)", 120);
var file, file_path = "", file_ext = "";
var file_attributes, readwrite;
var read_only = false, cue_file = false, stream = false;
var g_drag = false;
var on_mouse = false;
var tooltip = window.CreateTooltip();
var tooltip_stale = false;
TTDT_AUTOMATIC = 0;
tooltip.SetDelayTime(TTDT_AUTOMATIC, 100);
function tooltip_check_stale(){
if (tooltip_stale = true){
tooltip.Deactivate();
tooltip_stale = false;window.Repaint();
}
}
var t_type;
var metadb;
var count;
on_item_focus_change();
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
r_color = readwrite ? fb.IsPlaying ? color2 : color1 : color_error;
for (var i = 0; i < 5; i++) {
x_s = x_star + star_size * 0.5 + (i * offset);
y_s = y_star;
star(gr, x_s, y_s, star_size, true, 0, color1, false, bgcolor, no_rating_transparent);
star(gr, x_s, y_s, star_size, true, 0, r_color, shadow, bgcolor, star_alpha[i]);
}
text_height = gr.CalcTextHeight("text", font);
y_t = y_text ? y_text : y_star - text_height * 0.5;
text && gr.DrawString( rating_mode == 0 ? "db" : "tag" , font, RGBA_color(color1), x_text, y_t, ww, wh);
//gr.GdiDrawText( star_alpha, font, RGB(255,255,200), 20, 40, ww, wh );
}
function getNRating(posx) {
nrating = Math.ceil(( posx - x_star ) / offset );
if (nrating > 5) nrating = 5;
if (nrating < 0) nrating = 0;
if (nrating != 0) nrating = rating_5 ? 5 : nrating;
}
function getRating(){
if ( count > 1 ) {
TAGrating = 0;
DBrating = 0;
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
DBrating += parseInt(fb.TitleFormat("$if2(%rating%,0)").EvalWithMetadb(item));
TAGrating += parseInt(fb.TitleFormat("$if2($meta(rating),0)").EvalWithMetadb(item));
}
rating = rating_mode == 0 ? DBrating : TAGrating;
rating = rating / count;
} else {
DBrating = fb.TitleFormat("$if2(%rating%,0)").EvalWithMetadb(metadb);
TAGrating = fb.TitleFormat("$if2($meta(rating),0)").EvalWithMetadb(metadb);
rating = rating_mode == 0 ? DBrating : TAGrating;
}
}
function setRating(){
if ((nrating != rating) && metadb) {
if (rating_mode == 0) {
if ( count > 1 ) {
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
fb.RunContextCommandWithMetadb("Playback Statistics/Rating/" + (nrating == 0 ? "<not set>" : nrating), item);
}
} else{
fb.RunContextCommandWithMetadb("Playback Statistics/Rating/" + (nrating == 0 ? "<not set>" : nrating), metadb);
}
rating = nrating;
} else {
if ( count > 1 ) {
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
if (readwrite) {item.UpdateFileInfoSimple("Rating", nrating == 0 ? "" : nrating);
rating = nrating
}
}
} else{
if (readwrite) {metadb.UpdateFileInfoSimple("Rating", nrating == 0 ? "" : nrating);
rating = nrating
}
}
}
}
g_drag = false;
if (rating_mode == 1) {
tooltip.Activate();
tooltip_stale = true;
tooltip.GetDelayTime(TTDT_AUTOMATIC);
}
}
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_selection_changed(metadb) {
on_item_focus_change();
}
function on_item_focus_change() {
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (metadb) on_metadb_changed();
}
function on_metadb_changed() {
count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
if (metadb) {
rating_mode = window.GetProperty("rating_mode") == 0 ? 0 : 1;
getRating();
check_star_state();
get_attributes();
}
window.Repaint();
}
function on_mouse_lbtn_up(x,y){
setRating();
}
function on_mouse_mbtn_dblclk(){
nrating = 0;
setRating();
}
function on_mouse_lbtn_down(x,y) {
tooltip_check_stale();
g_drag = true;
getNRating(x);
window.Repaint();
}
function on_mouse_move(x, y) {
on_mouse = true;
window.SetCursor(32649);
if (g_drag){
getNRating(x);
}
button_change_state();
check_star_state();
window.Repaint();
}
function on_mouse_leave() {
tooltip_check_stale();
on_mouse = false;
button_leave_change_state();
window.SetCursor(32512);
window.Repaint();
}
function on_mouse_wheel(delta) {
tooltip && tooltip.Deactivate();
if (delta > 0) {rating_mode = 0};
if (delta < 0) {rating_mode = 1};
window.SetProperty("rating_mode", rating_mode);
on_item_focus_change();
window.Repaint();
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
_menu.AppendMenuItem(MF_ENABLED, 1, "Store Ratings in the database");
_menu.AppendMenuItem(MF_ENABLED, 2, "Store Ratings in the file tags");
_menu.CheckMenuRadioItem(1, 2, rating_mode + 1);
_menu.EnableMenuItem(rating_mode + 1, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 3, "Set Rating 5");
_menu.CheckMenuItem(3, rating_5);
var txt = "";
switch (file_attributes) {
case 32:
txt = "to read - only";
break;
case 33:
txt = "to read - write";
break;
}
MF_STRING = txt ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Change file attributes " + txt);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 5, "Fade effect");
_menu.CheckMenuItem(5, fade_effect);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 20, "Properties");
_menu.AppendMenuItem(MF_ENABLED, 30, "Configure...");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
case 2:
rating_mode = ret - 1;
window.SetProperty("rating_mode", rating_mode);
on_item_focus_change();
break;
case 3:
window.SetProperty("set rating 5", !rating_5);
rating_5 = window.GetProperty("set rating 5");
break;
case 4:
switch (file_attributes) {
case 32:
if (metadb) change_file_attributes(33); //read only
on_item_focus_change();
break;
case 33:
if (metadb) change_file_attributes(32); //read write
on_item_focus_change();
break;
}
break;
case 5:
window.SetProperty("fade effect", !fade_effect);
fade_effect = window.GetProperty("fade effect");
break;
case 20:
window.ShowProperties();
break;
case 30:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
function get_attributes() {
file_attributes = 0;
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
item_path = fb.Titleformat("%path%").EvalWithMetadb(item);
try {
file = fso.GetFile(item_path);
file_attributes += parseInt(file.Attributes);
} catch(e) {};
}
file_attributes = Math.round(file_attributes / count);
t_type = track_type(metadb.RawPath);
read_only = file_attributes == 33 ? true : false;
cue_file = t_type == "cue" ? true : false;
stream = t_type == "stream" ? true : false;
tooltip.Text = cue_file ? " cue file " : read_only ? " file" + (count > 1 ? "s are " : " is ") + "read only " : stream ? " stream " : "";
if ((cue_file || read_only || stream) && rating_mode == 1 ) {
readwrite = false;
} else {
readwrite = true;
}
}
function change_file_attributes(k) {
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
item_path = fb.Titleformat("%path%").EvalWithMetadb(item);
try {
file = fso.GetFile(item_path);
file.Attributes = k;
} catch(e) {};
}
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
function star(gr, x, y, img_size, fill, line_thickness, color, sh, sh_color, alpha){
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 = [];
var sh_points = [];
for (var i = 0; i < 10; i++) {
if (i % 2 == 0) {
x_points_1.push((radius - delta) * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2));
y_points_1.push((radius - delta) * Math.sin(Math.PI * i / 10 * 2 - Math.PI / 2));
} else {
x_points_2.push((radius - delta) / 2.61803 * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2));
y_points_2.push((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] + radius, y_points_1[i] + radius, x_points_2[i] + radius, y_points_2[i] + radius);
}
for (var i = 0; i < 5; i++) {
sh_points.push(x_points_1[i] + radius + 1, y_points_1[i] + radius + 1, x_points_2[i] + radius + 1, y_points_2[i] + radius + 1);
}
var img = gdi.CreateImage(img_size, img_size);
var temp_gr = img.GetGraphics();
temp_gr.SetSmoothingMode(2);
if (line_thickness > 0) {
sh && temp_gr.DrawPolygon(sh_color, line_thickness, sh_points);
temp_gr.DrawPolygon(color, line_thickness, points);
}
if (fill) {
sh && temp_gr.FillPolygon(sh_color, 1, sh_points);
temp_gr.FillPolygon(color, 1, points)
}
gr.DrawImage(img, x - radius, y - radius, img_size, img_size, 0, 0, img_size, img_size, 0, alpha);
img.ReleaseGraphics(temp_gr);
img.Dispose();
temp_gr = null;
img = null;
}
function track_type(p) {
var type;
if (p.indexOf("file") >= 0 && p.indexOf("cue") >= 0){
type = "cue";
} else if (p.indexOf("file") >= 0){
type = "file";
} else if (p.indexOf("cdda") >= 0){
type = "cdda";
} else if (p.indexOf('://') >= 0 || p.indexOf('www') >= 0 || p.indexOf("youtube") >= 0 || p.indexOf("video") >= 0 || p.indexOf("vimeo") >= 0){
type = "stream";
} else {
type = "";
}
return type;
}
var b_hover_state, b_hover_alpha = 0;
var star_state = [];
var star_alpha = [];
check_star_state();
var b_timer_started = false;
function check_star_state() {
star_state = [];
for (var i = 0; i < 5; i++) {
r = g_drag ? nrating : rating;
if (i < r) {star_state[i] = 1} else (star_state[i] = 0);
}
if (!b_timer_started) button_alpha_timer();
}
function button_change_state() {
if (!b_timer_started) button_alpha_timer();
b_hover_state = 1;
}
function button_leave_change_state() {
if (b_hover_state != 0) {
b_hover_state = 0;
}
}
function button_alpha_timer() {
b_timer_started = true;
b_timer = window.SetInterval(function() {
switch (b_hover_state) {
case 0:
b_hover_alpha = fade_effect ? Math.max(0, b_hover_alpha -= 10) : 0;
break;
case 1:
b_hover_alpha = fade_effect ? Math.min(255, b_hover_alpha += 51) : 255;
break;
}
for (var i = 0; i < 5; i++) {
if (!star_alpha[i]) star_alpha[i] = 0;
switch (star_state[i]) {
case 0:
star_alpha[i] = fade_effect ? Math.max(0, star_alpha[i] -= 15) : 0;
break;
case 1:
star_alpha[i] = fade_effect ? Math.min(255, star_alpha[i] += 51) : 255;
break;
}
}
window.Repaint();
if (!on_mouse){
var tmp_off = [];
var tmp_on = [];
for(var i = 0; i < star_alpha.length; i++) {
if (star_state[i] != 1) tmp_off.push(star_alpha[i]);
if (star_state[i] == 1) tmp_on.push(star_alpha[i]);
}
if (b_hover_alpha <= 0
&& Math.max.apply(null, tmp_off) <= 0
&& (Math.min.apply(null, tmp_on) >= 255 && tmp_on.length > 0)){
b_timer_started = false;
window.ClearInterval(b_timer);
}
}
}, 30);
}
kgena_ua, Делаю скрин который будет разворачиватся на весь экран, все рисую на $div, $muldiv, получается панелька js растягивается и звездочки сдвигаются. В общем выставил нужный размер звезд и аккуратно обрезал панельку по звездам пиксель в пиксель, теперь сдвиг есть, но не критично.kgena_ua:Если при разворачивании плеера во весь экран изменяется и размер панели, где находится скрипт, то можно привязаться к высоте панели.....
... и не появится.San_dr:а вот картинка .\radio Logos\radio_stub.png не появляется
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
y_s = wh / 2;
r_color = readwrite ? fb.IsPlaying ? color2 : color1 : color_error;
for (var i = 0; i < 5; i++) {
x_s = x_star + star_size * 0.5 + (i * offset);
star(gr, x_s, y_s, star_size, true, 0, color1, false, bgcolor, no_rating_transparent);
star(gr, x_s, y_s, star_size, true, 0, r_color, shadow, bgcolor, star_alpha[i]);
}
text_height = gr.CalcTextHeight("text", font);
y_t = y_text ? y_text : y_s - text_height * 0.5;
text && gr.DrawString( rating_mode == 0 ? "db" : "tag" , font, RGBA_color(color1), x_text, y_t, ww, wh);
}
// ==PREPROCESSOR==
// @name "Properties & properties file"
// @author "kgena_ua"
// @version "22032017"
// @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)); }
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
var ww, wh;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
String.prototype.repeat = function(n) {
return new Array(n + 1).join(this);
}
window.SetProperty(" - user", "");
if (window.GetProperty(" - user") != "" ) window.SetProperty(" - user", "");
window.SetProperty("-".repeat(50), "");
if (window.GetProperty("-".repeat(50)) != "" ) window.SetProperty("-".repeat(50), "");
var font_name_item = window.GetProperty(" font name: item", "Arial");
var font_name_group = window.GetProperty(" font name: group", "Arial");
var font_size_item = window.GetProperty(" font size: item", 12);
var font_size_group = window.GetProperty(" font size: group", 11);
var font_style_item = window.GetProperty(" font style: item", 0);
var font_style_group = window.GetProperty(" font style: group", 0);
var font_item, font_group;
get_font();
function get_font(){
font_item = gdi.Font(font_name_item, font_size_item, font_style_item);
font_group = gdi.Font(font_name_group, font_size_group, font_style_group);
}
ColorTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
};
ColorTypeDUI = {
text: 0,
background: 1,
highlight: 2,
selection: 3
};
function get_color(){
if (window.InstanceType == 0){
bgcolor = window.GetColorCUI(ColorTypeCUI.background);
color_item_name = window.GetColorCUI(ColorTypeCUI.text);
color_item_value = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);
color_group_text = window.GetColorCUI(ColorTypeCUI.inactive_selection_background);
} else if (window.InstanceType == 1) {
bgcolor = window.GetColorDUI(ColorTypeDUI.background);
color_item_name = window.GetColorDUI(ColorTypeDUI.text);
color_item_value = window.GetColorDUI(ColorTypeDUI.highlight);
color_group_text = window.GetColorDUI(ColorTypeDUI.selection);
}
window.Repaint();
}
get_color();
function on_colors_changed(){
get_color();
}
var custom_colors = window.GetProperty(" colors: custom", false);
var c_bgcolor = customColor(window.GetProperty(" color: background", "0-0-0"));
var c_color_item_name = customColor(window.GetProperty(" color: item name", "180-180-180"));
var c_color_item_value = customColor(window.GetProperty(" color: item value", "255-255-220"));
var c_color_group_text = customColor(window.GetProperty(" color: group text", "100-100-100"));
bgcolor = custom_colors ? c_bgcolor : bgcolor;
color_item_name = custom_colors ? c_color_item_name : color_item_name;
color_item_value = custom_colors ? c_color_item_value : color_item_value;
color_group_text = custom_colors ? c_color_group_text : color_group_text;
function customColor(colour){
tempc = colour.split("-");
return (0xff000000 | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
}
var tooltip = window.CreateTooltip();
tooltip.SetMaxWidth(300);
var tstring = 0;
var delay_flag = false;
var timer;
window.GetProperty("tooltip", false);
var selection_mode = window.GetProperty("selection_mode", 0);
var item_name_array = [];
var item_value_array = [];
var value_width = [];
var name, value;
var g_drag = false;
var g_drag_y = 0;
var s = 0;
var t_h;
var t_x1 = window.GetProperty(" text: x", 10);
var t_x2;
var t_x3;
var vertical_item_padding = window.GetProperty(" vertical item padding", 2);
var pos_y, pos_x;
var old_x, old_y;
var wh_old;
var group_text = window.GetProperty("group text", false);
var tfname = [
"$meta(artist)",
"%title%",
"%album%",
"%date%",
"%genre%",
"%composer%",
"%performer%",
"%publisher%",
"$meta(album artist)",
"%track number%",
"%totaltracks%",
"%discnumber%",
"%totaldiscs%",
"%comment%",
"%discid%",
"%rating%",
"$meta(rating)",
"%label%",
"%subtitle%",
"group general",
"$info(samplerate)",
"$info(channels)",
"$info(bitspersample)",
"$info(bitrate)",
"%codec%",
"$info(codec_profile)",
"$info(encoding)",
"%length%",
"$info(tool)",
"$info(cue_embedded)",
"group location",
"%filename_ext%",
"$directory_path(%path%)",
"%subsong%",
"%filesize_natural%",
"%last_modified%",
"%folder name%",
"group playback statistics",
"%play_count%",
"%first_played%",
"%last_played%",
"%added%",
"group last.FM",
"%lastfm_bio%",
"%lastfm_similar_artist%",
"%lastfm_artist_playcount%",
"%lastfm_artist_listeners%",
"%lastfm_album_playcount%",
"%lastfm_album_listeners%",
"%lastfm_album_content%"
];
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
draw_array(gr);
gr.GdiDrawText( "", font_item, color_item_value, 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(x,y) {
tstring = Math.floor((pos_y + Math.abs(s)) / t_h);
if (value_width[tstring * 2] > ww - t_x2 - t_x1 && x > t_x2 && window.GetProperty("tooltip")){
tooltip.Text = value_width[tstring * 2 + 1];
delay();
delay_flag && tooltip.Activate();
tooltip.TrackActivate = true;
tooltip.TrackPosition(x + 15, y - 10);
} 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(x,y);
old_y = y;
old_x = x;
}
if (g_drag) {
if (s <= 0 && (item_name_array.length * t_h) >= wh) {s = y - g_drag_y};
applyDelta();
}
if (s == 0 || s == wh - item_name_array.length * t_h) g_drag_y = (y - s);
}
function on_mouse_wheel(step) {
if (s <= 0 && item_name_array.length * t_h >= wh) {s = s + step * t_h};
applyDelta();
}
function applyDelta() {
s = s > 0 ? 0 : s;
s = s < (wh - item_name_array.length * t_h) && s < 0 ? (wh - item_name_array.length * t_h) : s;
window.Repaint();
}
function on_mouse_leave() {
tooltip.TrackActivate = false;
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;
}
}
function clear_name(n) {
// return n.replace(/.*\(|lastfm_/g,"").replace(/[^a-z\s\(_]/g,"").replace(/[\(\_]/g," ");
return n.replace(/.*\(|lastfm_|[^a-z\s\_]/g,"").replace(/_/g," ")
}
var measure = {
'bitrate' : " kbps",
'samplerate' : " Hz",
'bitspersample' : " bps",
'channels' : " ch",
'playcount' : " times"
}
function create_array() {
var temp_bmp = gdi.CreateImage(1, 1);
var temp_gr = temp_bmp.GetGraphics();
item_name_array = [];
item_value_array = [];
value_width = [];
t_x2 = 0;
for (j = 0; j < tfname.length; j++) {
group = tfname[j].search('group') >= 0 ? true : false;
value = Eval(tfname[j]);
if (value != 0 || group) {
item_name_array.push(tfname[j]);
item_value_array.push(value);
value_width.push(temp_gr.CalcTextWidth(value, font_item),value);
}
if (!group){
tmp_t_x2 = temp_gr.CalcTextWidth(clear_name(tfname[j]), font_item);
t_x2 = tmp_t_x2 > t_x2 ? tmp_t_x2 : t_x2;
}
}
t_x2 = t_x2 + t_x1 + 10;
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
}
function draw_array(gr) {
t_h = gr.CalcTextHeight("Text", font_item) + window.GetProperty(" vertical item padding");
star_size = t_h - 5;
offset = star_size + 2;
for (var i = 0; i < item_name_array.length; i++) {
group = item_name_array[i].search('group') >= 0 ? true : false;
font = group ? font_group : font_item;
color = group ? color_group_text : color_item_name;
t_y = i * t_h + s;
l_y = t_y + t_h / 2;
if (!group){
name = clear_name(item_name_array[i]);
} else {
name = group_text ? item_name_array[i].replace(/group\s/g,"").replace(/(?=.)/g," ").replace(/^\s/g,"") : "";
}
rating_text = item_name_array[i] == "$meta(rating)" ? " (tag)" : "";
gr.GdiDrawText(name + rating_text, font, color, t_x1, t_y, ww - t_x1 * 2, t_h, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
t_w = group_text ? gr.CalcTextWidth(name, font) + 5 : 0;
group && gr.DrawLine(t_x1 + t_w, l_y, ww - t_x1, l_y, 1, color);
if (item_name_array[i] == "%rating%" || item_name_array[i] == "$meta(rating)") {
for (var r = 0; r < item_value_array[i] * offset; r = r + offset) {
draw_star(gr, t_x2 + star_size / 2 + r, t_y + t_h / 2, star_size, true, 0, color_item_value, false, bgcolor, 255);
}
} else {
value = item_value_array[i];
gr.GdiDrawText( value, font_item, color_item_value, t_x2, t_y, ww - t_x2 - t_x1, t_h, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS | DT_NOPREFIX);
t_x3 = t_x2 + gr.CalcTextWidth(value, font_item);
tmp = clear_name(item_name_array[i]).replace(/\s/g,"");
gr.GdiDrawText( measure[tmp], font_item, color_group_text, t_x3, t_y, ww - t_x3 - t_x1, t_h, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
}
}
}
var metadb;
on_item_focus_change();
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_new_track() {
on_item_focus_change();
}
function on_playback_dynamic_info_track() {
on_item_focus_change();
}
function on_playback_stop() {
on_item_focus_change();
}
function on_selection_changed(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_metadb_changed() {
create_array();
window.Repaint();
}
function Eval(field) {
if (metadb) {
type = metadb.RawPath;
if (type.indexOf("file") > 0){
return fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
} else{
if (selection_mode == 0){
if (field == "$meta(artist)" || field == "%title%"){
return fb.TitleFormat("[" + field + "]").Eval(true);
}
if (field == "%genre%"){
return fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
}
}
return fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
}
}
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
_menu.AppendMenuItem(MF_ENABLED, 1, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, 2, "Follow selected track");
_menu.CheckMenuRadioItem(1, 2, selection_mode + 1);
_menu.EnableMenuItem(selection_mode + 1, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 3, "Group text");
_menu.CheckMenuItem(3, group_text);
_menu.AppendMenuItem(MF_ENABLED, 4, "Tooltip");
_menu.CheckMenuItem(4, window.GetProperty("Tooltip"));
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 5, "Create txt/xls file");
_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.SetProperty("group text", !group_text);
group_text = window.GetProperty("group text");
break;
case 4:
!window.GetProperty("tooltip") ? window.SetProperty("tooltip", true) : window.SetProperty("tooltip", false);
break;
case 5:
menu_create_file(x,y);
break;
case 10:
try {
window.Reload();
} catch(e) {};
break;
case 20:
window.ShowProperties();
break;
case 30:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
///////////////////////////// Create file
var fso = new ActiveXObject("Scripting.FileSystemObject");
var output_path = fb.ProfilePath + "\\tmp_Properties\\";
function check_folder(n) {
if (!n) return;
try {
if(!fso.FolderExists(n)) {fso.CreateFolder(n)};
} catch(e) {}
}
window.GetProperty("ext",1);
var separator = Array(" ; ","\t");
var tmp_item_name_array = [];
var selected;
var shift = 0;;
var output_array = [];
var pllist_name;
create_tmp_item_name_array();
function create_tmp_item_name_array() {
for (var j = 0; j < tfname.length; j++) {
if (tfname[j].indexOf('group') < 0){
tmp_item_name_array.push(tfname[j])};
}
}
for (var j = 0; j < tmp_item_name_array.length; j++) {
window.GetProperty(j + 1,0);
}
function create_output_array() {
output_array = [];
for (var j = 0; j < tmp_item_name_array.length; j++) {
selected = window.GetProperty(j + 1);
if ( selected == 1 ) {output_array.push(tmp_item_name_array[j])};
}
createTextFile();
}
function createTextFile(){
check_folder(output_path);
count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
if (count == 0 || output_array.length ==0) return;
if (window.GetProperty("ext") == 0) {
output_file = output_path + "plist " + pllist_name + ".txt";
} else {
output_file = output_path + "plist " + pllist_name + ".xls";
}
try { file = fso.CreateTextFile( output_file )
} catch(e) {};
var text_item_name = [];
var string_item_name = "";
for (var j = 0; j < output_array.length; j++) {
text_item_name.push(output_array[j]);
}
string_item_name = text_item_name.join(separator[window.GetProperty("ext")]);
file.WriteLine(string_item_name);
file.WriteLine("");
for (var i = 0; i < count; i++) {
item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);
var text_item_value = [];
var string_item_value = "";
for (var j = 0; j < output_array.length; j++) {
value = fb.TitleFormat("[" + output_array[j] + "]").EvalWithMetadb(item);
tmp = clear_name(output_array[j]).replace(/\s/g,"");
tmp = value && measure[tmp] ? measure[tmp] : "";
text_item_value.push(value + tmp);
string_item_value = text_item_value.join(separator[window.GetProperty("ext")]);
}
try { file.WriteLine(string_item_value);
} catch(e) {};
}
file.Close();
}
function menu_create_file(x,y){
var _menu = window.CreatePopupMenu();
var i = 1;
count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
MF_STRING = count == 0 ? MF_GRAYED : MF_ENABLED;
pllist_name = plman.GetPlaylistName(plman.ActivePlaylist);
pllist_name = count == 0 ? "*" : pllist_name.replace(/[\/\:\*\?\"\<\>\|]/g,'');
_menu.AppendMenuItem(MF_STRING, i++, "Create " + pllist_name + (window.GetProperty("ext") == 0 ? ".txt" : ".xls"));
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var lines = 20;
tl = 0 + shift;
bl = tmp_item_name_array.length > lines ? lines + shift : tmp_item_name_array.length;
for (var j = tl; j < bl; j++) {
menuItem = tmp_item_name_array[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, "Select all");
_menu.AppendMenuItem(MF_ENABLED, 120, "Clear all");
if (tmp_item_name_array.length > lines) {
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(shift == 0 ? MF_GRAYED : MF_ENABLED, 130, "Up");
_menu.AppendMenuItem(shift + lines >= tmp_item_name_array.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 <= tmp_item_name_array.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):
for (var j = 1; j < tmp_item_name_array.length + 1; j++) {
window.SetProperty(j, 1);
}
menu_create_file(x,y);
break;
case (ret == 120):
for (var j = 1; j < tmp_item_name_array.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, sh, sh_color, alpha){
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 = [], sh_points = [];
var 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((radius - delta) * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2));
y_points_1.push((radius - delta) * Math.sin(Math.PI * i / 10 * 2 - Math.PI / 2));
} else {
x_points_2.push((radius - delta) / 2.61803 * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2));
y_points_2.push((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] + radius, y_points_1[i] + radius, x_points_2[i] + radius, y_points_2[i] + radius);
sh_points.push(x_points_1[i] + radius + 1, y_points_1[i] + radius + 1, x_points_2[i] + radius + 1, y_points_2[i] + radius + 1);
}
var img = gdi.CreateImage(img_size, img_size);
var temp_gr = img.GetGraphics();
temp_gr.SetSmoothingMode(2);
if (line_thickness > 0) {
sh && temp_gr.DrawPolygon(sh_color, line_thickness, sh_points);
temp_gr.DrawPolygon(color, line_thickness, points);
}
if (fill && line_thickness == 0) {
sh && temp_gr.FillPolygon(sh_color, 1, sh_points);
temp_gr.FillPolygon(color, 1, points)
}
gr.DrawImage(img, x - radius, y - radius, img_size, img_size, 0, 0, img_size, img_size, 0, alpha);
img.ReleaseGraphics(temp_gr);
img.Dispose();
temp_gr = null;
img = null;
}
посмотри на 79 странице, если на ссылку нажать не догадалсяvik-tan:Да, был, толком ничего и не нашел
Наверное лучше будет попробовать сделать изменение ширины колонок при нажатой лев.кл.(с полным перекрытием наименований)San_dr:Можно ли не рисовать колонку названий параметров
Вернуться в Секреты foobar2000