Скрипты для foo_uie_wsh_panel_mod

Список разделов foobar2000 Секреты foobar2000

Описание: Кнопочки, конфиги, секреты, советы.

Сообщение #501 seriousstas » 06.09.2015, 19:47

kgena_ua
работает, только происходит перерисовка экрана
Спасибо Большое !

Добавлено спустя 5 часов 8 минут:
та я уже понял, что всегда будет "ложка дёгтя"
Ну и ещё одна - Фронтенд, для которого предназначалась сборка ,
пытается поправить этот пиксель (перезахватывает) - поэтому перерисовка происходит
четыре раза вместо двух..
seriousstas
Откуда: Украина , Ивано-Франковск
Репутация: 110
С нами: 9 лет 1 месяц

Сообщение #502 kgena_ua » 20.09.2015, 09:41

Ввод символов с клавиатуры.
Код: Выделить всё
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }

var font = gdi.Font("Arial",18,0);
var ww,wh;

ColorTypeCUI = {
   text: 0,
   selection_text: 1,
   inactive_selection_text: 2,
   background: 3,
   selection_background: 4,
   inactive_selection_background: 5,
   active_item_frame: 6
};

//var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
//var color = window.GetColorCUI(ColorTypeCUI.text);
//var color2 = window.GetColorCUI(ColorTypeCUI.selection_text);

var color = RGB(140,164,179);
var color2 = RGB(200,213,219);

DT_LEFT = 0x00000000;
DT_WORD_ELLIPSIS = 0x00040000;

htmlfile = new ActiveXObject('htmlfile');
var clipboardData;

var on_mouse = false;
var lbtn_down = false;
var lbtn_up = false;

var pos_x = 0;

var text = "";
var text_width = 0;
var text_height = 0;

var col = 20;
var row = 1;

var char_index_x = [];
var index1 = 0;
var index2 = 0;
var index1_x = 0;
var index2_x = 0;

var i_code;

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, RGB(60,68,79));
//    !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);

    text_width = gr.CalcTextWidth(text, font);
    text_height = gr.CalcTextHeight("0", font);
   
    gr.GdiDrawText(text, font, color, col, row, ww - col * 2, text_height, DT_LEFT | DT_WORD_ELLIPSIS );
   
    refresh_char_index(gr);

    var char_width = gr.CalcTextWidth(text[index1], font);

    var cursor_x = col + char_index_x[Math.max(index1, index2)];
    var def_cursor_w = gr.CalcTextWidth("0", font);
   
    var cursor_w = index1 == text.length ? def_cursor_w : char_width;
    blink && gr.DrawLine(cursor_x, text_height + 2, cursor_x + cursor_w, text_height + 2, row, color);

    if (index1 != index2) {
        gr.GdiDrawText(text.substring(Math.min(index1, index2), Math.max(index1, index2) + 1), font, color2,  Math.min(index1_x, index2_x), row, ww - col * 2, wh, DT_LEFT | DT_WORD_ELLIPSIS );
    }
}

function on_mouse_lbtn_down(x, y) {
    lbtn_down = true;
    index1 = 0;
    index1_x = 0;
    index2 = 0;
    index2_x = 0;
   
    index1 = index2 = get_cusor_index(x - col);
    index1_x = index2_x = col + char_index_x[index1];
   
    blink_t();
    window.Repaint();
}

function on_mouse_lbtn_up(x, y) {
    lbtn_down = false;
    window.Repaint();
}

function on_mouse_wheel(delta) {
}
   
function on_mouse_move(x, y) {
    if (lbtn_down) {
        index2 = get_cusor_index(x - col);
        index2_x = col + char_index_x[index2];
    }
    on_mouse = true;
    window.SetCursor(32513);
    window.Repaint();
}

function on_mouse_leave() {
    on_mouse = false;
    window.ClearInterval(timer);
    blink = true;
    window.SetCursor(32512);
    window.Repaint();
}

function on_size(){
    ww = window.Width;   
    wh = window.Height;
}

function on_char(code) {
    i_char = String.fromCharCode(code);

    switch(code){
        case 27: //ESC
            text = "";
            index1 = index2 = 0;
            char_width_array = [];
            break;
           
        case 13: //ENTER
            break;
           
        case 8: // BACK_SPACE
            if (index1 == index2){
                text = text.substring(0, Math.min(index1, index2) - 1) + text.substring( Math.max(index1, index2), text.length);
                index1 = index1 == 0 ? 0 : index1 - 1;
            } else {
                text = text.substring(0, Math.min(index1, index2)) + text.substring( Math.max(index1, index2) + 1, text.length);
                index1 =  Math.min(index1, index2);
            }
            index2 = index1;
            break;
           
        case 3:  //CTRL + C
            if (index1 != index2) {
                htmlfile.parentWindow.clipboardData.setData('text',text.substring( index1, index2 + 1));
                index2 = index1;
            }
            break;
           
        case 22: //CTRL + V
            clipboardData = htmlfile.parentWindow.clipboardData.getData('text');
         
            if (index1 == index2) {
                text = text.substring(0, index1) + clipboardData + text.substring( index1, text.length);
                index1 = index1 + clipboardData.length;
            } else {
                text = text.substring(0, Math.min(index1, index2)) + clipboardData + text.substring( Math.max(index1, index2) + 1, text.length);
                index1 = Math.min(index1, index2) + clipboardData.length;
            }
            index2 = index1;
            break;
           
        case 24: //CTRL + X
            if (index1 != index2) {
                htmlfile.parentWindow.clipboardData.setData('text',text.substring(index1, index2 + 1));

                text = text.substring(0, Math.min(index1, index2)) + text.substring( Math.max(index1, index2) + 1, text.length);
                index1 =  Math.min(index1, index2);
                index2 = index1;
            }
            break;
           
        case 9: //TAB
            break;
           
        case 1: //CTRL + A
            index1 = 0;
            index1_x = index2_x = col + char_index_x[index1];
            index2 =text.length;
            index2_x = index2_x = col + char_index_x[index2];
            break;
           
        case 26: //CTRL + Z
            break;
           
        default: //CHAR
            if (index1 == index2) {
                text = text.substring(0, index1) + i_char + text.substring(index1, text.length);
                index1 = index1 + 1;
            } else {
                text = text.substring(0, Math.min(index1, index2)) + i_char + text.substring( Math.max(index1, index2) + 1, text.length);
                index1 = index1 > text.length ? text.length : index1 + 1;
            }
            index2 = index1;
            break;
    }
    window.Repaint();
}

function on_key_down(vkey) {
    ddd = [];
    switch(vkey){
        case 0x25: // VK_LEFT
            index1 = index1 <= 0 ?  0 : index1 - 1;
            index2 = index1;
            break;

        case 0x27: // VK_RIGHT
            index1 = index1 >= text.length ?  text.length : index1 + 1;
            index2 = index1;
            break;

        case 0x24: // VK_HOME
            index1 = 0;
            index2 = index1;
            break;
           
        case 0x23: // VK_END
            index1 = text.length;
            index2 = index1;
            break;
           
        case 0x2E: // VK_DELETE
            text = text.substring(0, Math.min(index1, index2)) + text.substring( Math.max(index1, index2) + 1, text.length);
            index1 = index1 > text.length ? text.length : index1;
            index2 = index1;
            break;
           
        case 0x2D : // VK_INSERT
            clipboardData = htmlfile.parentWindow.clipboardData.getData('text');
         
            if (index1 == index2) {
                text = text.substring(0, index1) + clipboardData + text.substring( index1, text.length);
                index1 = index1 + clipboardData.length;
            } else {
                text = text.substring(0, Math.min(index1, index2)) + clipboardData + text.substring( Math.max(index1, index2) + 1, text.length);
                index1 = Math.min(index1, index2) + clipboardData.length;
            }
            index2 = index1;
            break;
    }
    window.Repaint();
}

function refresh_char_index(gr){
    char_index_x = [];
    for(var i = 0; i < text.length + 1; i++)
    char_index_x[i] = gr.EstimateLineWrap(text.substr(0,i),font,ww).toArray()[1];
}

function get_cusor_index(x){
    var i = text.length;
    while (char_index_x[i] > x)
        i--;
    return (i > 0) ? i : 0;
}

var timer;
var blink = true;
var ms = 0;

function blink_t() {
    timer && window.ClearInterval(timer);
    timer = window.SetInterval(function() {
        ms = ms +1;
        if (ms >= 8 && ms < 10) {blink = false} else {blink = true};
        if (ms >= 10) { ms = 0}
        window.Repaint();
    }, 100 );
}

function on_colors_changed() {
    window.Repaint();
}
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 10 лет 11 месяцев

Сообщение #503 MC Web » 20.09.2015, 17:16

kgena_ua, только нужно отметить, что работает с CUI.
Интересно, но для чего задумывался сей скрипт, если не секрет?
В голову ничего не приходит, где его можно использовать.
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #504 kgena_ua » 20.09.2015, 20:17

MC Web, да почему только с CUI, там только прописан выбор цветов для CUI, так я заремил для выложенного скрипта.
А цель такая - панель поиск. У меня есть панель поиска в таком виде:
1.PNG
1.PNG (5.4 КБ) Просмотров: 3290

теперь добавлю туда ввод через клавиатуру, будут наверное два варианта ввода, на выбор.
И опять - спортивный интерес. Давно хотел сделать такое. Неоднократно начинал и забрасывал. Недавно пришла опять идея, и пошло и поехало. Не получалось только с координатами курсора, пробовал различные варианты. А тут, просматривая скрипт плейлиста "TOUCH LIBRARY PANEL TREE mod_5", наткнулся на маленькую функцию, которая и помогла все свести воедино.
Осталось только тестировать, может быть добавить обработку некоторых сочетаний клавиш, или блокировку.
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 10 лет 11 месяцев

Сообщение #505 MC Web » 20.09.2015, 21:24

kgena_ua, у меня выложенный скрипт с DUI не работает - стоит мигающий курсор и все, вывода с клавиатуры нет,
В CUI все выводит нормально.
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #506 seriousstas » 20.09.2015, 21:44

У меня наоборот
CUI - стоит мигающий курсор и все, вывода с клавиатуры нет
DUI не пробовал
seriousstas
Откуда: Украина , Ивано-Франковск
Репутация: 110
С нами: 9 лет 1 месяц

Сообщение #507 kgena_ua » 21.09.2015, 19:23

MC Web, про DUI врать не буду, просто считал что разницы нет в написании скрипта для DUI и CUI.
seriousstas, та должно работать, там ничего такого нет. Хотя...
У меня есть сборки FooMist и сборка vladj, там работает, а вставил скрипт в 4Icar - не работает. Интересно.
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 10 лет 11 месяцев

Сообщение #508 Truumann » 23.09.2015, 20:22

Насчёт Br3tt JSPlaylist. Как сделать фон плейлиста прозрачным? Псевопрозрачность в нём не работает. Покопался в скрипте, так и не понял что поменять для этого можно...
Truumann
Репутация: 2
С нами: 10 лет 7 месяцев

Сообщение #509 vladj » 23.09.2015, 22:07

Что под плейлистом увидеть хочешь ? Рабочий стол, картинку бакграунда, картинку артиста ?
По щелчку правой по панели плейлиста выходит окно настроек панели (Panel Settings) ?
vladj M
Аватара
Откуда: Пермский край
Репутация: 427
С нами: 14 лет 2 месяца

Сообщение #510 Truumann » 23.09.2015, 22:42

vladj, картинку панели сзади. У плейлиста/скрипта сам по себе фон чёрный когда музыка не включена. Когда включена/на паузе показывается картинка артиста, либо бэкграунд и это настраивается в Panel Settings. Но мне нужно именно фон плейлиста сделать прозрачным, а не чёрным; это в panel settings не настраивается к сожалению, или я просто что-то не то делаю. Надеюсь, понятно объяснил...
Изображение
Truumann
Репутация: 2
С нами: 10 лет 7 месяцев

Сообщение #511 seriousstas » 24.09.2015, 00:09

Truumann
В Apperance можно поменять цвет фона ,
а прозрачность вроде здесь есть :
http://rghost.ru/private/8r2RcNMlh/3e2a785fea2e218a6f4aa2792d7973df
seriousstas
Откуда: Украина , Ивано-Франковск
Репутация: 110
С нами: 9 лет 1 месяц

Сообщение #512 Truumann » 24.09.2015, 00:39

seriousstas, там ещё метод скролла сильно переделан в скрипте, из-за чего скролится туго. Но строчку, где прозрачность добавляется я нашёл и она работает, спасибо большое!
Truumann
Репутация: 2
С нами: 10 лет 7 месяцев

Сообщение #513 seriousstas » 24.09.2015, 00:50

метод скролла
'
Кстати бета с новым методом :
http://br3tt.deviantart.com/art/JSSmoothPlaylist-beta20150912-559263371
seriousstas
Откуда: Украина , Ивано-Франковск
Репутация: 110
С нами: 9 лет 1 месяц

Сообщение #514 kgena_ua » 24.09.2015, 10:30

Truumann:Как сделать фон плейлиста прозрачным?
Truumann, в function on_paint(gr) { строки с 1055 по 1061
Код: Выделить всё
            // draw background under playlist
            if(fb.IsPlaying && p.wallpaperImg && properties.showwallpaper) {
                gr.GdiDrawBitmap(p.wallpaperImg, 0, p.list.y, ww, wh-p.list.y, 0, p.list.y, p.wallpaperImg.Width, p.wallpaperImg.Height-p.list.y);
                gr.FillSolidRect(0, p.list.y, ww, wh-p.list.y, g_color_normal_bg & RGBA(255,255,255,properties.wallpaperalpha));
            }; else {
                gr.FillSolidRect(0, p.list.y, ww, wh-p.list.y, g_color_normal_bg);
            };
если их заремить, и поставит галочку в Pseudo Trahspatent, то панедь будет прозрачной.
Или заремить одну из строк, в зависимости от того что нужно. Если я правильно понял, то надо заремить строку 1060

gr.FillSolidRect(0, p.list.y, ww, wh-p.list.y, g_color_normal_bg);
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 10 лет 11 месяцев

Сообщение #515 duzzy » 25.09.2015, 03:24

Truumann,
там ещё метод скролла сильно переделан в скрипте, из-за чего скролится туго.
для этого там есть настройки я про скролл, один раз кликни на плейлист левой кнопкой мыши, затем нажми Shift + правую кнопку мыши, затем в появившемся контекстном меню выбери пункт "Properties" там будут настройки прокрутки мыши и др.
красным отмечены настройки скорости прокрутки...
2015-09-25_021551.png
2015-09-25_021551.png (934 байт) Просмотров: 3128
Снимок.PNG
Снимок.PNG (37.14 КБ) Просмотров: 3128
duzzy
Репутация: 25
С нами: 8 лет 8 месяцев

Сообщение #516 kgena_ua » 19.10.2015, 13:25

Скрипт "Рейтинг" (на тестирование):
- изменение рейтинга для выбранного или выбранных треков;
- сохранение рейтинга в теги или базу данных;
- проверка на read - only (возможность изменения), cue - файл и ИРадио при записи в тег.
Для удобства тестирования убрана привязка к img - файлам - рейтинг выводится символами "0".
Код: Выделить всё
// ==PREPROCESSOR==
// @name "Rating & file attributes"
// @author "kgena_ua"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

// foo_playcount.dll required

function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",10,0);
var font_2 = gdi.Font("Arial",12,1);
var ww,wh;

DT_LEFT = 0x00000000;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
/*
ColorTypeCUI = {
    text: 0,
    selection_text: 1,
    inactive_selection_text: 2,
    background: 3,
    selection_background: 4,
    inactive_selection_background: 5,
    active_item_frame: 6
};

var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
var color1 = window.GetColorCUI(ColorTypeCUI.text);
var color2 = window.GetColorCUI(ColorTypeCUI.inactive_selection_background);
*/
var Tooltip = window.CreateTooltip();
/*
var img_path = fb.ProfilePath + "\\maybe\\textures\\rating\\";

var img_bg = gdi.Image( img_path + "star_bg_12.png");
var img_rating_white = gdi.Image( img_path + "star_12.png");
var img_rating_blue = gdi.Image( img_path + "star_12_blue.png");
var img_rating_red = gdi.Image( img_path + "star_12_red.png");
*/
var p_size = 12;
var offset = 16;

var posx, posy;
var col = 40;
var row = 0;

var g_drag = false;
var on_mouse = false;

var rating = 0, TAGrating, DBrating, nrating = 0;
var rating_m = window.GetProperty("def_rating_m", 0);
var rating_5 = window.GetProperty("rating_5", 2);;

var fso = new ActiveXObject("Scripting.FileSystemObject");
var file, file_path = "", file_ext = "";
var file_attributes, readwrite;
var read_only = false, cue_file = false, stream = false;

var metadb;
var count;
on_item_focus_change();

function getNRating() {
    nrating = Math.ceil(( posx - col ) / offset );
    if (nrating > 5) nrating = 5;
    if (nrating < 0) nrating = 0;
    if (nrating != 0) nrating = rating_5 == 1 ? 5 : nrating;
}

function getRating(){
    if (metadb.Count != null) {
        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_m == 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_m == 0 ? DBrating : TAGrating;
    }
}

function on_paint(gr){
   !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, RGB(20,20,20));

     for (var i = 0; i < (5 * offset); i = i + offset) {   
        //gr.DrawImage( img_bg , col + i, row, p_size, p_size, 0, 0, p_size, p_size, 0, 255 );
        gr.GdiDrawText( "0" , font_2, RGB(100,100,100), col + i, row, ww, wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    }
       
    for (var i = 0; i < ((g_drag ? nrating : rating) * offset); i = i + offset) {   
        //gr.DrawImage( readwrite ? img_rating_blue : img_rating_red , col + i, row, p_size, p_size, 0, 0, p_size, p_size, 0, 255);
        gr.GdiDrawText( "0" , font_2, readwrite ? RGB(255,255,200) : RGB(255,128,64), col + i, row, ww, wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    }

    gr.GdiDrawText(rating_m == 0 ? "  DB" : "  TAG" , font, on_mouse ? RGB(150,150,150) : RGB(105,100,100), 0, 0, ww, wh, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
}

function on_mouse_lbtn_up(x,y){
   if ((nrating != rating) && metadb) {   
        if (rating_m == 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_m == 1) {
        Tooltip.Activate();
        Tooltipdelay()
    }
}

function on_mouse_lbtn_down(x,y) {
    g_drag = true;
    posx = x;
    getNRating();
    window.Repaint();
}   

function on_mouse_move(x, y) {
    on_mouse = true;
    window.SetCursor(32649);      
    if (g_drag){   
        posx = x ;
        getNRating();   
    }   
    window.Repaint();
}   

function on_mouse_leave() {   
    on_mouse = false;
    window.SetCursor(32512);
    window.Repaint();
}   

function on_mouse_wheel(delta) {   
    if (delta > 0) {rating_m = 0};
    if (delta < 0) {rating_m = 1};
    window.SetProperty("def_rating_m", rating_m);
    on_item_focus_change();
    window.Repaint();
}

function on_mouse_rbtn_up (x, y){   
    var _menu = window.CreatePopupMenu();
    var i = 1;

    _menu.AppendMenuItem(0x00000000, i++, "Store Ratings in the database");
    _menu.AppendMenuItem(0x00000000, i++, "Store Ratings in the file tags");
    _menu.CheckMenuRadioItem(1, i, rating_m + 1);      
   _menu.EnableMenuItem(rating_m + 1, 1);   
   
    _menu.AppendMenuItem(0x00000800, 0, 0);
    _menu.AppendMenuItem(0x00000000, i++, "Set Rating 5");
    _menu.CheckMenuItem(i-1, rating_5 - 2);   
   
    var txt = "";
   
    switch (file_attributes) {
    case 32:   
        txt = "read - only";
        break;     
    case 33:   
        txt = "read - write";
        break;     
    }

    if ( txt != "") {
        _menu.AppendMenuItem(0x00000800, 0, 0);   
        _menu.AppendMenuItem(0x00000000, i++, "change file" + (count > 1 ? "s" : "") + " to  " + txt);
    }

    ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
//    if (ShiftDown) {
        _menu.AppendMenuItem(0x00000800, 0, 0);
        _menu.AppendMenuItem(0x00000000, 20, "Properties");
        _menu.AppendMenuItem(0x00000000, 30, "Configure...");
//    }

    ret = _menu.TrackPopupMenu(x, y);
    if (ret == 0) return;

    switch (ret) {
    case 1:
        rating_m = 0;
        window.SetProperty("def_rating_m", rating_m);
        on_item_focus_change();
        break;
    case 2:
        rating_m = 1;
        window.SetProperty("def_rating_m", rating_m);
        on_item_focus_change();
        break;
    case 3:
        rating_5 = rating_5 == 1 ? 2 : 1;
        window.SetProperty("rating_5", 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 20:
        window.ShowProperties();
        break;   
    case 30:
        window.ShowConfigure();      
        break; 
    }
    _menu.Dispose();
    return true;
}

function change_file_attributes(k) {
    for (var i = 0; i < count; i++) {
        item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);   
        file_path = fb.Titleformat("%path%").EvalWithMetadb(item);
        try {
            file = fso.GetFile(file_path);
            file.Attributes = k;
        } catch(e) {};
    }   
}

function get_attributes() {            
    file_attributes = 0;            
    for (var i = 0; i < count; i++) {            
        item = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Item(i);            
        file_path = fb.Titleformat("%path%").EvalWithMetadb(item);            
        file_ext = fb.Titleformat("$ext([%filename_ext%])").EvalWithMetadb(item);            
        try {            
            file = fso.GetFile(file_path);            
            file_attributes += parseInt(file.Attributes);            
        } catch(e) {};             
    }             
    file_attributes = Math.round(file_attributes / count);   

    read_only = file_attributes == 33 ? true : false;
    cue_file = file_ext == 'cue' ? true : false;
    stream = file_path.indexOf('://') > 0 ? true : false;

    Tooltip.Text = read_only ? " file" + (count > 1 ? "s are " : " is ") + "read only " : cue_file ? " cue file " : stream ? " stream " : "";
                    
    if ((file_attributes == 33 || file_ext == 'cue' || file_path.indexOf('://') > 0) && rating_m == 1 ) {             
        readwrite = false;                  
    } else {            
        readwrite = true;                     
    }                  
}   

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.GetSelections().Count > 1 ? fb.GetSelections() : fb.GetNowPlaying()) : (fb.GetSelections().Count > 1 ? fb.GetSelections() : fb.GetFocusItem());
     //metadb = fb.IsPlaying ? fb.GetNowPlaying() : false;
    if (metadb) on_metadb_changed();
}

function on_metadb_changed() {
    count = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
    if (metadb) {
        //if (window.GetProperty("def_rating_m") == 0) {rating_m = TAGrating > 0 ? 1 : 0};
        //if (window.GetProperty("def_rating_m") == 1) {rating_m = DBrating > 0 ? 0 : 1};     
        rating_m = window.GetProperty("def_rating_m") == 0 ? 0 : 1; 
        getRating();
        get_attributes();
    }
    window.Repaint();
}
/*
function on_colors_changed(){
    bgcolor = window.GetColorCUI(ColorTypeCUI.background);
    color1 = window.GetColorCUI(ColorTypeCUI.text);
    color2 = window.GetColorCUI(ColorTypeCUI.inactive_selection_background);
   window.Repaint();
}
*/
function on_size(){
    ww = window.Width;   
   wh = window.Height;
}

function Tooltipdelay(){
    var timer = window.SetTimeout(function() {
        Tooltip.Deactivate();
        window.ClearTimeout(timer);
    }, 1500);
}

kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 10 лет 11 месяцев

Сообщение #517 kgena_ua » 22.10.2015, 16:59

Скрипт "свойства и экспорт данных в файл" (окончательная версия)
Особенность: не требуются граф.файлы для вывода рейтинга звездами.
Безымянный.png
Безымянный.png (9.85 КБ) Просмотров: 2907

Код: Выделить всё
// ==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);
var g_fontR = gdi.Font("Areal",10,0);

DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_RIGHT = 0x00000002;
DT_WORD_ELLIPSIS = 0x00040000;
DT_SINGLELINE = 0x00000020;
var ww, wh;

var 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;
window.GetProperty("Tooltip", 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;
var pos_x;
var wh_old = wh

function on_paint(gr) {
   !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);

    show_array2(gr);
}

function on_mouse_lbtn_down(x, y) {
    g_drag = true;
    g_drag_y = (y - s);
}

function on_mouse_lbtn_up(x, y) {
    g_drag = false;
}

function on_mouse_move(x, y) {
    window.SetCursor(32649);
    pos_y = y;
    pos_x = x;
   
    tstring = Math.floor((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();
    }
   
    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 ? s + 1 : s;
        wh_old = wh;
    }
}

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;

var delay_flag = false;
var timer;
function delay() {
    timer = window.SetTimeout(function() {
        delay_flag = true;
        window.ClearTimeout(timer);
    }, 1000);
}

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_array2(gr) {
    t_height = gr.CalcTextHeight("text", font) + 2;
    for (var i = 0; i < name_array.length; i++) {
        line = false;
        group = false;
       
        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]; r++){
                 Draw_star(gr, col2 + star_r + star_r * 2.5 * r, row + star_r * 2, color2)
             }
        } else {
            gr.GdiDrawText(value_array[i], font, color2, col2, row, ww - col2 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);       
        }
    }
}

var metadb;
on_item_focus_change();

function on_item_focus_change() {
   metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
    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;

    MF_ENABLED = 0x00000000;
    MF_GRAYED = 0x00000001;
   
    _menu.AppendMenuItem(MF_ENABLED, i++, "Tooltip");
    _menu.CheckMenuItem(1, window.GetProperty("Tooltip"));

    _menu.AppendMenuItem(MF_ENABLED, i++, "Create txt/xls file");
   
    ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
   
//    if (ShiftDown) {
        _menu.AppendMenuItem(0x00000800, 0, 0);
        _menu.AppendMenuItem(0x00000000, 10, "Reload");
        _menu.AppendMenuItem(0x00000800, 0, 0);
        _menu.AppendMenuItem(0x00000000, 20, "Properties");
        _menu.AppendMenuItem(0x00000000, 30, "Configure ...");
//    }

    ret = _menu.TrackPopupMenu(x,y);

    switch (ret) {
    case 1:   
        window.GetProperty("Tooltip") == 0 ? window.SetProperty("Tooltip",1) : window.SetProperty("Tooltip",0);
        break;
    case 2:
        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 txt/xls 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 tag = [];
create_tag_array();

function  create_tag_array() {
    for (var j = 0; j < tfname.length; j++) {   
        if (tfname[j].indexOf('line') < 0  && tfname[j].indexOf('group') < 0){
        tag.push(tfname[j])};
    }
}

var outtag = [];
var separator = Array(" ; ","\t"); 

for (var j = 0; j < tag.length; j++) {   
    window.GetProperty(j + 1,0);
}

window.GetProperty("ext",0);
window.GetProperty("skip",0);
var selected;
var shift = 0;;

function  create_output_array() {
    outtag = [];
    for (var j = 0; j < tag.length; j++) {   
        selected = window.GetProperty(j + 1);
        if ( selected == 1 ) {outtag.push(tag[j])};
    }
    createTextFile();
}

function createTextFile(){
    if (fb.GetSelections().Count == 0 || outtag.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 < outtag.length; j++) {
            text.push(outtag[j]);       
        }
        string = text.join(separator[window.GetProperty("ext")]);
        file.WriteLine(string);
        file.WriteLine("");
    }

    for (var i = 0; i < fb.GetSelections().Count; i++) {
        item = fb.GetSelections().Item(i);
        text = [];
        string = "";
        for (var j = 0; j < outtag.length; j++) {   
            select = fb.TitleFormat("[" + outtag[j] + "]").EvalWithMetadb(item);
            var measure = "";
            if (select != "" ) {
                if (outtag[j] == "$info(bitrate)") measure = " kbps";
                if (outtag[j] == "$info(samplerate)") measure = " Hz";
                if (outtag[j] == "$info(bitspersample)") measure = " bps";
                if (outtag[j] == "$info(channels)") measure = " ch";
            }
            if (select != "" || window.GetProperty("skip") == 0) {
                text.push(select + 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;

    MF_ENABLED = 0x00000000;
    MF_GRAYED = 0x00000001;
   
    MF = fb.GetSelections().Count == 0 ? MF_GRAYED : MF_ENABLED;
  //  t = window.GetProperty("ext") == 0 ? "*.txt" : "*.xls";
   
    _menu.AppendMenuItem(MF, i++, "create  " + (window.GetProperty("ext") == 0 ? "*.txt" : "*.xls") + " file");
    _menu.AppendMenuItem(0x00000800, 0, 0);
   
    var lines = 20;   
    tl = 0 + shift;
    bl = tag.length > lines ? lines + shift : tag.length;

    for (var j = tl; j < bl; j++) {
        menuItem = tag[j].replace(/[%\$\(\)]|info|meta/g,'').replace(/_/g,' ');
        _menu.AppendMenuItem(MF_ENABLED, i++, menuItem);   
        _menu.CheckMenuItem(i-1, window.GetProperty(i - 2 + shift));
    }
   
    _menu.AppendMenuItem(0x00000800, 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(0x00000800, 0, 0);
    _menu.AppendMenuItem(MF_ENABLED, 110, "skip if empty");
    _menu.CheckMenuItem(110, window.GetProperty("skip"));
   
    _menu.AppendMenuItem(0x00000800, 0, 0);
    _menu.AppendMenuItem(MF_ENABLED, 120, "clear all");

    if (tag.length > lines) {
        _menu.AppendMenuItem(0x00000800, 0, 0);
        _menu.AppendMenuItem(shift == 0 ? MF_GRAYED : MF_ENABLED, 130, "up");
        _menu.AppendMenuItem(shift + lines >= tag.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 <= tag.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 < tag.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();
}

var star_r = 5;

function Draw_star(gr,x,y,color){
    var x_points_1 = [], y_points_1 = [];
    var x_points_2 = [], y_points_2 = [];
   
    gr.SetSmoothingMode(4);

    for (var j = star_r; j > 0; j--) { 
        for (var i = 0; i < 5; i++) {
            x_points_1.push(x + (j * Math.cos(Math.PI * i / 5 * 2 - Math.PI / 2)));
            y_points_1.push(y + (j * Math.sin(Math.PI * i / 5 * 2 - Math.PI / 2)));
        }
   
        for (var i = 1; i < 10; i = i + 2) {
            x_points_2.push(x + (j / 2.61803 * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2)));
            y_points_2.push(y + (j / 2.61803 * Math.sin(Math.PI * i / 10 * 2 - Math.PI / 2)));
        }
    }

    for (var j = 0; j < star_r * 5 - 5; j = j + 5) { 
        gr.DrawLine(x_points_1[0+j], y_points_1[0+j], x_points_2[0+j], y_points_2[0+j], 1, color);
        gr.DrawLine(x_points_1[0+j], y_points_1[0+j], x_points_2[4+j], y_points_2[4+j], 1, color);
        gr.DrawLine(x_points_1[1+j], y_points_1[1+j], x_points_2[0+j], y_points_2[0+j], 1, color);
        gr.DrawLine(x_points_1[1+j], y_points_1[1+j], x_points_2[1+j], y_points_2[1+j], 1, color);
        gr.DrawLine(x_points_1[2+j], y_points_1[2+j], x_points_2[1+j], y_points_2[1+j], 1, color);
        gr.DrawLine(x_points_1[2+j], y_points_1[2+j], x_points_2[2+j], y_points_2[2+j], 1, color);
        gr.DrawLine(x_points_1[3+j], y_points_1[3+j], x_points_2[2+j], y_points_2[2+j], 1, color);
        gr.DrawLine(x_points_1[3+j], y_points_1[3+j], x_points_2[3+j], y_points_2[3+j], 1, color);
        gr.DrawLine(x_points_1[4+j], y_points_1[4+j], x_points_2[3+j], y_points_2[3+j], 1, color);
        gr.DrawLine(x_points_1[4+j], y_points_1[4+j], x_points_2[4+j], y_points_2[4+j], 1, color);
    }
}
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 10 лет 11 месяцев

Сообщение #518 seriousstas » 27.10.2015, 01:43

kgena_ua
вставил скрипт в 4Icar - не работает. Интересно.
В той, что собрал на MPS - есть прогресс - появляется возможность ввода (в отличии от той , что на PSS),
но реакции в плейлисте все-же нет(что-то "мешает") .

теперь добавлю туда ввод через клавиатуру, будут наверное два варианта ввода, на выбор.
если получится "допилить" было-бы здорово :)
seriousstas
Откуда: Украина , Ивано-Франковск
Репутация: 110
С нами: 9 лет 1 месяц

Сообщение #519 megane68 » 29.10.2015, 23:25

Добрый день аксакалам WSH.
У меня такая проблема - есть скрипт Cover Panel, не устраивает отображение Custom Pictures.
Хочется, чтобы была возможность установить любое количество отображаемых картинок в Custom Pictures и указания нескольких мест хранения для каждой из этих картинок, например через $findfile($replace(%path%,%filename_ext%,)..\..\..\Artwork\$if2(%album artist%,%artist%)\artist.*,$replace(%path%,%filename_ext%,)..\..\..\..\Artwork\$if2(%album artist%,%artist%)\artist.*))

Код: Выделить всё
// ==PREPROCESSOR==
// @name "DarkOne Cover Panel"
// @version "3.0"
// @author "tedGo, includes partial code by T.P Wang"
// @import "%fb2k_path%themes\DarkOne\Others\WSH Scripts\DO Global Script.js"
// ==/PREPROCESSOR==

var g_img = null;
var descr_timer = null;
var cycle_timer = null;
var g_active = false;
var g_fade = 255;
var g_state = 0;
var metadb;

// ----- CREATE OPTIONS --------------------------------------------
var a_arr = new Array("Picture 1", "Picture 2", "Picture 3", "Picture 4", "Picture 5", "Picture 6");
var b_arr = new Array("Front Cover", "Back Cover", "Disc", "Icon", "Artist");

function artType() {
   at = window.GetProperty("Enable Custom Pictures", false);
   c_arr = at ? a_arr : b_arr;
}

artType();

function aspectRatio() {
   ar = window.GetProperty("Aspect ratio", 0);
   if (typeof ar < 0 || ar > 2) ar = 0;
   return ar;
}

aspectRatio();

// ----- GET PICTURE -----------------------------------------------
var imgPath = configPath + "Images\\";
var a_img = gdi.Image(imgPath + "DarkOne.png");
var b_img = gdi.Image(imgPath + "Radio.png");
var c_img = gdi.Image(imgPath + "AudioCD.png");
var d_img = gdi.Image(imgPath + "NoImage.png");

var e_arr = [];
e_arr[0] = gdi.Image(imgPath + "NoFront.png");
e_arr[1] = gdi.Image(imgPath + "NoBack.png");
e_arr[2] = gdi.Image(imgPath + "NoDisc.png");
e_arr[3] = gdi.Image(imgPath + "NoIcon.png");
e_arr[4] = gdi.Image(imgPath + "NoArtist.png");

var f_arr = [];
f_arr[0] = window.GetProperty(a_arr[0],"");
f_arr[1] = window.GetProperty(a_arr[1],"");
f_arr[2] = window.GetProperty(a_arr[2],"");
f_arr[3] = window.GetProperty(a_arr[3],"");
f_arr[4] = window.GetProperty(a_arr[4],"");
f_arr[5] = window.GetProperty(a_arr[5],"");

var g_ext = window.GetProperty("File extension order", "jpg|png|gif|bmp|tif");
var g_arr = g_ext.split("|");

var g_art = null;

function getRightImage(switchstate) {
   metadb = fb.GetNowPlaying();

   if (g_art) {
      g_img.Dispose();
      g_art = null;
   }

   if (metadb) {
      var f_img = null;
      if (fb.PlaybackLength <= 0) {
         f_img = b_img;
         g_active = false;
      } else if (metadb.RawPath.indexOf("cdda://") == 0) {
         f_img = c_img;
         g_active = false;
      } else {
         var old_state = g_state;
         do {
            switchstate && switchState();
            if (at) {
               var arr = utils.Glob(fb.TitleFormat(f_arr[g_state]).Eval() + ".*").toArray();
               var g_break = false;
               for (var n = 0; n < g_arr.length && !g_break; n++) {
                  for (var i = 0; i < arr.length; i++) {
                     var re = new RegExp("\." + g_arr[n] + "$", "i");
                     if (arr[i].match(re)) {
                        g_art = gdi.Image(arr[i]);
                        g_break = true;
                        break;
                     }
                  }
               }
               f_img = g_art;
            } else {
               g_art = utils.GetAlbumArtV2(metadb, g_state);
               f_img = g_art;
            }
         }
         while (switchstate && old_state != g_state && !f_img);
         g_active = true;
      }
   } else {
      f_img = a_img;
      g_active = false;
   }

   if (f_img) g_img = f_img;
   else if (!switchstate) g_img = at ? d_img : e_arr[g_state];

   return g_img ? true : false;
}

getRightImage(false);

// ----- CREATE ACTIONS --------------------------------------------
function getTimer() {
   if (descr_timer) {
      descr_timer.Dispose(),
      descr_timer = null;
   }
   descr_timer = window.CreateTimerTimeout(1500);
   window.Repaint();
}

function switchState() {
   if (g_state == 4) g_state = 0;
   else g_state++;
}

function switchType() {
   window.SetProperty("Enable Custom Pictures", at ? false : true);
   artType();
   g_state = 0;
   getRightImage(false);
   if (g_active && !g_art) getRightImage(true);
   getTimer();
}

// ----- CREATE MENU -----------------------------------------------
function CustomMenu(x, y) {
   var a = window.CreatePopupMenu();
   var idx;

   a.AppendMenuItem(0, 1, "Keep aspect ratio");
   a.AppendMenuItem(0, 2, "Noexpansion");
   a.AppendMenuItem(0, 3, "Stretch");
   a.CheckMenuRadioItem(1, 3, ar + 1);
   a.AppendMenuItem(2048, 0, 0);
   a.AppendMenuItem(0, 4, at ? "Album Art" : "Custom Pictures");
   a.AppendMenuItem(2048, 0, 0);

   if (!ac) {
      for (var i = 0; i < c_arr.length; i++) {
         a.AppendMenuItem(0, 5 + i, c_arr[i]);
      }
      a.CheckMenuRadioItem(5, 9, g_state + 5);
      a.AppendMenuItem(2048, 0, 0);
   }

   a.AppendMenuItem(ac ? 8 : 0, 10, "Auto Cycle Image");
   ac && a.AppendMenuItem(ct ? 8 : 0, 11, "Faded Transition");
   a.AppendMenuItem(2048, 0, 0);
   a.AppendMenuItem(0, 12, "Properties");
   a.AppendMenuItem(0, 13, "Configure...");

   idx = a.TrackPopupMenu(x, y);

   switch (true) {
      case (idx >= 1 && idx <= 3):
         window.SetProperty("Aspect ratio", idx - 1);
         aspectRatio();
         window.Repaint();
         break;

      case (idx == 4):
         switchType();
         break;

      case (idx >= 5 && idx <= 9):
         g_state = idx - 5;
         getRightImage(false);
         getTimer();
         break;

      case (idx == 10):
         window.SetProperty("Auto Cycle Image", ac ? false : true);
         ac = window.GetProperty("Auto Cycle Image");
         break;

      case (idx == 11):
         window.SetProperty("Auto Cycle Transition Fader on", ct ? false : true);
         ct = window.GetProperty("Auto Cycle Transition Fader on");
         break;

      case (idx == 12):
         window.ShowProperties();
         break;

      case (idx == 13):
         window.ShowConfigure();
         break;
   }

   a.Dispose();
}

// ----- DRAW ------------------------------------------------------
var overlay_active = window.GetProperty("Back Overlay: Activate", true);
var overlay_colour = window.GetProperty("Back Overlay: Colour", "63-100-127-72");
var g_acol = CustomColour(overlay_colour);

var descr_tcolour = window.GetProperty("Description: Text Colour", "128-192-255-255");
var g_bcol = CustomColour(descr_tcolour);

var descr_bcolour = window.GetProperty("Description: Back Colour", "19-30-38-224");
var g_ccol = CustomColour(descr_bcolour);

function on_paint(gr) {
   if (!window.IsTransparent) gr.FillSolidRect(0, 0, ww, wh, ui_backcol);
   if (fb.IsPlaying && overlay_active) gr.FillSolidRect(0, 0, ww, wh, g_acol);

   if (g_img) {
      var w, h, x, y;
      if (ar == 0 || ar == 1 && (g_img.Width > ww || g_img.Height > wh)) {
         var img_scale = Math.min(ww / g_img.Width, wh / g_img.Height);
         w = g_img.Width * img_scale;
         h = g_img.Height * img_scale;
         x = (ww - w) / 2;
         y = (wh - h) / 2;
      } else if (ar == 1) {
         w = g_img.Width;
         h = g_img.Height;
         x = (ww - w) / 2;
         y = (wh - h) / 2;
      } else {
         w = ww;
         h = wh;
         x = y = 0;
      }
      gr.DrawImage(g_img, x, y, w, h, 0, 0, g_img.Width, g_img.Height, 0, Math.abs(g_fade));
   }

   if (descr_timer) {
      gr.SetSmoothingMode(2);
      gr.FillRoundRect(5, 5, 129, 29, 3, 3, g_ccol);
      gr.GdiDrawText(c_arr[g_state], dsp_font, g_bcol, 10, 10, 125, 30, 33);
   }
}

// ----- MOUSE ACTIONS ---------------------------------------------
function on_mouse_move(x, y) {
   if (!ac && g_active) window.SetCursor(32649);
}

function on_mouse_lbtn_down(x, y) {
   if (!ac && g_active) {
      getRightImage(true);
      getTimer();
   }
}

function on_mouse_mbtn_down(x, y) {
   g_active && switchType();
}

function on_mouse_rbtn_up(x, y) {
   if (g_active) {
      CustomMenu(x, y);
      return true;
   }
}

// ----- EVENTS ----------------------------------------------------
var ac = window.GetProperty("Auto Cycle Image", false);
var ci = window.GetProperty("Auto Cycle Interval in s", 15);
var ct = window.GetProperty("Auto Cycle Transition Fader on", false);

function on_size() {
   ww = window.Width;
   wh = window.Height;
}

function on_timer(id) {
   if (cycle_timer && id == cycle_timer.ID) {
      g_fade -= 51;
      if (g_fade <= -255) {
         g_fade = 255;
         cycle_timer.Dispose();
         cycle_timer = null;
      }
      if (g_fade == 0) getRightImage(true);
      window.Repaint();
   } else if (descr_timer && id == descr_timer.ID) {
      window.RepaintRect(5, 5, 130, 30);
      descr_timer.Dispose();
      descr_timer = null;
   }
}

function on_playback_new_track(metadb) {
   getRightImage(false);
   window.Repaint();
}

function on_playback_time(time) {
   if (ac && g_active && g_art && time > 1 && Math.round(time % ci) == 1) {
      if (ct) {
         if (cycle_timer) {
            cycle_timer.Dispose();
            cycle_timer = null;
         }
         cycle_timer = window.CreateTimerInterval(50);
      } else {
         getRightImage(true);
         window.Repaint();
      }
   }
}

function on_playback_stop(reason) {
   if (cycle_timer) {
      cycle_timer.Dispose();
      cycle_timer = null;
      g_fade = 255;
   }

   if (descr_timer) {
      descr_timer.Dispose();
      descr_timer = null;
   }

   if (reason != 2) {
      getRightImage(false);
      window.Repaint();
   }
}
megane68 M
Репутация: -18
С нами: 15 лет 1 месяц

Сообщение #520 egen17 » 07.11.2015, 00:00

При запуске всплывает такое окно:

Панель WSH (модуль)
Scripting Engine Initialization Failed (WSH Timer & Alarm clock & Clock by kgena_ua, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error).

Подскажите, будьте добры, как исправить? Win. XP. Сборка foobar2000 RU DarkOne + DUIFoon от MC Web
dotNetFramework и visual.c.+++? обновлен - не помогает!
egen17
Репутация: 0
С нами: 8 лет 4 месяца

Пред.След.

Вернуться в Секреты foobar2000