Скрипты для foo_uie_wsh_panel_mod

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

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

Сообщение #401 kgena_ua » 01.07.2015, 16:28

MC Web:Есть одна заковырка с названием станции chillout:justlisten!
MC Web, меняем имя файла chilloutjustlisten!.png на chillout justlisten.png, ну не должно быть в имени файл ':' и ' ! ' (! на всякий случай). Далее убираем из title ':' и '!' для сравнения с имеющимися файлами.
Замените function getRadioLogImage() в Radio Logo Script.js на
Код: Выделить всё
function  getRadioLogImage() {
    path = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
    title = fb.Titleformat("[%title%]").EvalWithMetadb(metadb).replace(' ','');
   
    file_name = "";
    get_files_from_dir();
   
    for (var i = 0; i < files.length; i++){
        var file = files[i].replace(/.jpg|.jpeg|.png|.gif|.bmp|.tiff/g,'').replace(' ','');
        title = title.replace(/[:\!]/g,'');
        if (title.toLowerCase(title).match(file) != null) file_name = files[i];
    }
    window.Repaint();
}
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #402 MC Web » 01.07.2015, 16:42

kgena_ua:меняем имя файла chilloutjustlisten!.png на chillout justlisten.png, ну не должно быть в имени файл ':' и ' ! ' (! на всякий случай). Далее убираем из title ':' и '!' для сравнения с имеющимися файлами.
Это и ежу понятно, у меня имя файла chillout justlisten.png и стоит, но со старым вариантом скрипта Radio Logo Script.js работало, как описывал выше. После замены function getRadioLogImage() в Radio Logo Script.js данная проблема вроде как исчезла. Спасибо!!!!
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #403 kgena_ua » 01.07.2015, 16:54

MC Web:данная проблема вроде как исчезла
MC Web, это хорошо. Нужно посмотреть как в точности работает функция string.match(), может она ищет примерное совпадение.
MC Web:Это и ежу понятно
Это я просто рассуждал вслух :smile:
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #404 MC Web » 01.07.2015, 17:29

kgena_ua, у меня еще одна идея, возможно и бредовая - сам не решил:
есть ли возможность подключения скрипта в ELP для отображения групп и в всплывающем окне. Единственное, что смущает - размер отображаемой картинки, больно мелкие:
Спойлер
Image 11.png
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #405 kgena_ua » 01.07.2015, 18:12

MC Web, если я правильно понял, Вы хотите отображать лого станции в каждой группе, т.к. у Вас станция это отдельная группа. Я думаю это не получится. Почему. Мы можем взять лого (картинку) только если станция воспроизводится, мы сравниваем title с имеющимися файлами. У меня вообще весь плайлмст в одной группе (для радио своя ELP).
Безымянный.jpg

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

Сообщение #406 MC Web » 01.07.2015, 18:49

kgena_ua, так и думал.
Проехали...
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #407 AHAPXICT » 03.07.2015, 16:28

Всем доброго дня! Уже появился))) Неделя отсутствия и опять как в новый мир попал, перечитаю все темы на форуме отпишусь.
AHAPXICT M
Аватара
Откуда: Киев
Репутация: 252
С нами: 10 лет 5 месяцев

Сообщение #408 kgena_ua » 05.07.2015, 11:21

WSH properties
Вывод рейтинга символами.
Мелкие изменения.
Безымянный.png
Безымянный.png (23.38 КБ) Просмотров: 2226

Код: Выделить всё
// ==PREPROCESSOR==
// @name "properties"
// @author "kgena_ua"
// ==/PREPROCESSOR==

function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}

ColorTypeCUI = { background: 3,};
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);

var g_font = gdi.Font("Areal",12,0);
var g_font2 = gdi.Font("Tahoma",9,1);
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 color1 = RGB(140,164,179);
//var color1 = RGB(140,140,140);
var color2 = RGB(255,255,245);
var color3 = RGB(90,105,114);

var tfarray = [];
var widestring = [];

var g_tooltip = window.CreateTooltip();
var ttText = "";
g_tooltip.SetMaxWidth(300);

window.GetProperty("skip",0);
var name, value, measure, t_height;
var path = "", title;
var g_drag = false;
var g_drag_y = 0;
var s = 0;
var col1 = 10;
var col2 = 110;
var col3;

var metadb;
on_item_focus_change();

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

    t_height = gr.CalcTextHeight("text", g_font) + 2;
    tfarray = [];
    widestring = [];
   
    for (j = 0; j < tfname.length; j++) {
        group = false;
        LM = false;

        if (tfname[j].search('lastfm') >= 0) LM = true;
        if (tfname[j].search('group') >= 0 || tfname[j] == "line" ) group = true;

        if ((path.substr(0,4) == "http" || path.substr(0,4) == "mms:") && fb.IsPlaying  && tfname[j] != "%genre%" || LM) {
            value = fb.TitleFormat("[" + tfname[j] + "]").Eval();
        } else {
            if (metadb) value = fb.TitleFormat("[" + tfname[j] + "]").EvalWithMetadb(metadb);
        }
       
        if ( window.GetProperty("skip") == 1) {
            if (value != 0 || group) tfarray.push(tfname[j],value);
        } else {
            tfarray.push(tfname[j],value);
        }
    }

    for (i = 0; i < tfarray.length; i = i + 2) {
        line = false;
        group = false;
        measure = "";
        measureR = "";
       
        if (tfarray[i].search('line') >= 0) line = true;
        if (tfarray[i].search('group') >= 0) group = true;

        name = tfarray[i].replace(/[%\$\(\)]|info|meta|group |line|lastfm/g,'').replace(/_/g,' ').replace('directory pathpath','directory path');
        value = tfarray[i + 1];

        if (name && value){
            if (tfarray[i] == "$info(bitrate)") measure = "  kbps";
            if (tfarray[i] == "$info(samplerate)") measure = "  Hz";
            if (tfarray[i] == "$info(bitspersample)") measure = "  bps";
            if (tfarray[i] == "$info(channels)") measure = "  ch";
           
            if (tfarray[i] == "$meta(rating)") measureR = "  (tag)";
            if (tfarray[i] == "%rating%" || tfarray[i] == "$meta(rating)")  {var reting = []; while (reting.length < value) {reting.push("★")}; value = reting.join(" ");}
        }
       
        row =  i / 2 * t_height + s;
        line_row = row + t_height / 2;
        line && gr.DrawLine(col1, line_row, ww - col1, line_row, 1, color3);
       
        gr.GdiDrawText(name + measureR, group ? g_font2 : g_font, group ? color3 : color1, col1, row, ww - col1 * 2, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);       
        var font = tfarray[i] == "%rating%" || tfarray[i] == "$meta(rating)" ? g_fontR : g_font;
       
        gr.GdiDrawText(value, font, color2, col2, row, ww - col2 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);       
       
        t_width = gr.CalcTextWidth(value, g_font);
        col3 = col2 + t_width;
        gr.GdiDrawText(measure, g_font, color1, col3, row, ww - col3 - col1, t_height, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);       
       
        if (t_width > ww - col2 - col1) {   widestring.push(row,value)};
    }

    g_tooltip.Text = ttText;
    if (ttText) {
        g_tooltip.Activate();}
    else {
        g_tooltip.Deactivate();
    }
   
    gr.GdiDrawText("", g_font, color2, 0, 140, ww, wh, DT_RIGHT | DT_WORD_ELLIPSIS);
    gr.GdiDrawText("", g_font2, color2, 0, 160, 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;
}
var pos_y;
function on_mouse_move(x, y) {
    window.SetCursor(32649);
   
    pos_y = y;
   
    ttText = "";

    for (i = 0; i < widestring.length; i = i + 2) {
        if (y > widestring[i] && y < widestring[i] + t_height && x > col2) {
                ttText = widestring[i + 1];
            if (ttText) return;
        } else {
//            ttText = "";
        }
    }
   
    if (g_drag) {
        if (s <= 0 && (tfarray.length / 2 * t_height) >= wh) {s = y - g_drag_y};
        applyDelta();
    }
   
    if (s == 0 || s == wh - tfarray.length / 2 * t_height) g_drag_y = (y - s);
    window.Repaint();
}

function on_mouse_wheel(step) {
    if (s <= 0 && tfarray.length / 2 * t_height >= wh) {s = s + step * t_height};
    applyDelta();
}

function applyDelta() {
    s = s > 0 ? 0 : s;
    s = s < (wh - tfarray.length / 2 * t_height) && s < 0 ? (wh - tfarray.length / 2 * t_height) : s;
    window.Repaint();
}

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

var title, artist, album;

function on_metadb_changed() {
    path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
}

function on_item_focus_change() {
    metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem() ,true;
    if (metadb) on_metadb_changed();
    window.Repaint();
}

function on_playback_new_track(metadb) { 
    on_item_focus_change();
}

function on_playback_time(time){
    on_item_focus_change();
}

function on_selection_changed(metadb) {
    on_item_focus_change();
}

function on_playlist_switch() {
    on_item_focus_change();
}

function on_playback_stop() {
}

var wh_old;

function on_size() {
    ww = window.Width;
    wh = window.Height;
    if (wh != wh_old  && s < 0) {
        s = wh >= wh_old ? s + 1 : s;
        wh_old = wh;
    }
}

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

    MF_ENABLED = 0x00000000;
    MF_GRAYED = 0x00000001;
   
    _menu.AppendMenuItem(MF_ENABLED, 1, "skip if empty");
    _menu.CheckMenuItem(1, window.GetProperty("skip"));

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

    ret = _menu.TrackPopupMenu(x,y);

    switch (ret) {
    case 1:   
        window.SetProperty("skip", window.GetProperty("skip") == 0 ? 1 : 0);
        if (s < 0) s = 0;
        break;
    case 10:
        window.Reload();
        break;
    case 20:
        window.ShowProperties();
        break;   
    case 30:
        window.ShowConfigure();      
        break;
   }
    _menu.Dispose();
    return true;
}

var tfname = new Array(
"%artist%",
"%title%",
"%album%",
"%date%",
"%genre%",
"%composer%",
"%performer%",
"%publisher%",
"%album artist%",
"%track number%",
"%totaltracks%",
"%discnumber%",
"%totaldiscs%",
"%comment%",
"%rating%",
"$meta(rating)",
"line",
"group G E N E R A L",
"$info(samplerate)",
"$info(channels)",
"$info(bitspersample)",
"$info(bitrate)",
"%codec%",
"$info(codec_profile)",
"$info(encoding)",
"%length%",
"$info(tool)",
"$info(cue_embedded)",
"line",
"group L O C A T I O N",
"%filename_ext%",
//"%path%",
"$directory_path(%path%)",
"%subsong%",
"%filesize_natural%",
"%last_modified%",
"%folder name%",
"line",
"group P L A Y B A C K   S T A T I S T I C S",
"%play_count%",
"%first_played%",
"%last_played%",
"%added%",
"line",
"group L A S T F M",
"%lastfm_bio%",
"%lastfm_similar_artist%",
"%lastfm_artist_playcount%",
"%lastfm_artist_listeners%",
"%lastfm_album_playcount%",
"%lastfm_album_listeners%",
"%lastfm_album_content%"
);
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #409 MC Web » 06.07.2015, 18:20

Хотел еще раз поблагодарить kgena_ua за помощь и AHAPXICT (воспользовался некоторыми скриптами).
Вот что получилось
Изображение
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #410 AHAPXICT » 06.07.2015, 18:50

MC Web, а я уже успел и видео посмотреть)))) Сейчас в городе стоит такая жара, а я сижу с ноутом ковыряюсь(забиваю программами и т.п.). Хотел черкнуть у тебя на форуме, но обломался. Потом обязательно скачаю и по тестирую!!! Вы с kgena_ua, хорошую идею развиваете. :beer: Потом и сам позаимствую. А пока со своими граблями не разберусь, застрял на CompactOne, нечего делать не буду.
AHAPXICT M
Аватара
Откуда: Киев
Репутация: 252
С нами: 10 лет 5 месяцев

Сообщение #411 kgena_ua » 07.07.2015, 02:48

MC Web, красиво получилось.

Вот решил продолжить теме включения воспроизведения по таймеру.
Безымянный.png
Безымянный.png (9.3 КБ) Просмотров: 2128

Добавил возможность выбора play или stop - пункт 3.
Возможность выбора изменяемых величин - пункт 2, т.к., к примеру, неудобно выставить две минуты, имея изменяемую величину только секунды (120 раз мышкой клацать). При удержании ShiftDown шаг увеличивается - для секунд 10 секунд, для минут - 10 минут.
Увеличение илиуменьшение - пункт 1.
Безымянный2.png
Безымянный2.png (9.3 КБ) Просмотров: 2128

Запуск таймера - пункт 1.
Отключение таймера после запуска - пункт 5.
Безымянный3.png
Безымянный3.png (9.38 КБ) Просмотров: 2128

Код: Выделить всё
// ==PREPROCESSOR==      

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

ColorTypeCUI = { background: 3,};                     
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);                     

DT_LEFT = 0x00000000;                     
DT_RIGHT = 0x00000002;                     
DT_CENTER = 0x00000001;                     
DT_VCENTER = 0x00000004;                     
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;

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

    var color1 = window.GetProperty("on_off") == "play" ? RGB(0,70,0): RGB(205,67,0);
    gr.FillSolidRect (0, 0, ww, wh, s_play > 0 && s_play <= 3 && timer_started ? color1 : bgcolor);
   
    var color2 = window.GetProperty("on_off") == "play" ? RGB(128,255,128) : RGB(255,175,89);
    gr.GdiDrawText(sec2time(s_play), font, timer_started ? s_play > 3 ? color2 : RGB(255,255,255) : RGB(150,150,150), 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}

var ttttt = 0;

var set_time = 0;
var s_play = 0;

var timer_started = false;
var stop_timer = false;

function timer_play() {
    if ((fb.IsPlaying && window.GetProperty("on_off") == "play") || (!fb.IsPlaying && window.GetProperty("on_off") == "stop")) {
        s_play = 0;
        set_time = 0;
        return;
    }; 
   
    timer_started = true;
    stop_timer = false;
   
    window.ClearInterval(timer);
    var timer = window.SetInterval(function() {
        s_play = s_play - 1;
        window.Repaint();
        if (s_play <= 0 || stop_timer) {
            window.ClearInterval(timer);
            s_play = 0;
            set_time = 0;
            timer_started = false;

            if (stop_timer) return;
           
            if ((!fb.IsPlaying || fb.IsPaused) && window.GetProperty("on_off") == "play") {
                fb.Play();
            };
           
            if (fb.IsPlaying && window.GetProperty("on_off") == "stop") {
                fb.Stop();
            };
        };
    }, 1000 );
}

var m2 = ["seconds","minute","hour"];
window.GetProperty("m2","seconds");
var m3f, m3l
choice_s_m_h();

function choice_s_m_h() {   
    var m3 = [];   
    for (var i = 0; i < m2.length; i++) {    
        if(m2[i] != window.GetProperty("m2")) m3.push(m2[i]);   
    }   
    m3f = m3[0];   
    m3l = m3[1];   
}   

var step1, step_2;   
set_step();   

function set_step() {   // if ShiftDown pressed
    if (window.GetProperty("m2") == "seconds") {step1 = 1; step2 = 10};   
    if (window.GetProperty("m2") == "minute") {step1 = 60; step2 = 600};   
    if (window.GetProperty("m2") == "hour") {step1 = 3600; step2 = 3600};
}

function sec2time(sec) {
    var h, m, s;
    h = Math.floor(sec / 3600);
    m = Math.floor((sec - h * 3600) / 60);
    s = sec - h * 3600 - m * 60;
    if ( m < 10 && h != 0) m = "0" + m;
    if ( s < 10) s = "0" + s;
    return (h == 0 ? "" : h + " : ") + m + " : " + s;
}

function on_mouse_lbtn_up (x, y){
    set_time = set_time <= 0 ? 0 : set_time;
    set_time = set_time >= 86400 ? 86400 : set_time;
       
    if (!timer_started) s_play = set_time;   
       
    window.Repaint();   

    MF_ENABLED = 0x00000000;   
    MF_GRAYED = 0x00000001;   

    var _menu = window.CreatePopupMenu();   
    var i = 1;   
       
    MF_STATE1 = set_time == 0 || set_time == 86400 ? MF_GRAYED : MF_ENABLED;   

    _menu.AppendMenuItem(MF_STATE1, i++, timer_started ? "timer ..." : sec2time(set_time));   
    _menu.AppendMenuItem(0x00000800, 0, 0);    
    _menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + "  +");   
    _menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + "  -");   
    _menu.AppendMenuItem(0x00000800, 0, 0);      
    _menu.AppendMenuItem(0x00000000, i++, m3f);   
    _menu.AppendMenuItem(0x00000000, i++, m3l);   
    _menu.AppendMenuItem(0x00000800, 0, 0);   
   
    MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;   
    _menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("on_off"));   
       
    if (timer_started) {   
        _menu.AppendMenuItem(0x00000800, 0, 0);      
        _menu.AppendMenuItem(0x00000000, i++, "clear timer");   
    }   
           
    ShiftDown = utils.IsKeyPressed(0x10) ? true : false;   

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

    switch (ret) {
    case 1:
        if (set_time > 0) {s_play = set_time; timer_play()};
        break;
    case 2:
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
        set_time =  set_time + (ShiftDown ? step2 : step1);
        on_mouse_lbtn_up (x, y);
        break;
    case 3:
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
        set_time = set_time - (ShiftDown ? step2 : step1);
        on_mouse_lbtn_up(x,y);
        break;
    case 4:
        window.SetProperty("m2",m3f);
        choice_s_m_h();
        set_step();
        on_mouse_lbtn_up(x,y);
        break;
    case 5:
        window.SetProperty("m2",m3l);
        choice_s_m_h();
        set_step();
        on_mouse_lbtn_up(x,y);
        break;
    case 6:
       window.GetProperty("on_off") == "play" ? window.SetProperty("on_off","stop") : window.SetProperty("on_off","play");
        on_mouse_lbtn_up(x,y);
        break;
       
    case 7:
        stop_timer = true;
        timer_started = false;
        break;
    }
    _menu.Dispose();
    if (!timer_started) set_time = 0;
    window.SetProperty("m2","seconds");
    choice_s_m_h();
}

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

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

function on_size(){
    ww = window.Width;   
    wh = window.Height;
}
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #412 MC Web » 07.07.2015, 12:51

kgena_ua:Вот решил продолжить теме включения воспроизведения по таймеру
У меня при нажатии ЛКМ (foo_uie_wsh_panel_mod_1.5.6):
Код: Выделить всё
File: <main>
Ln: 127, Col: 5
<source text only available at compile time>
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #413 kgena_ua » 07.07.2015, 13:40

MC Web, ошибку нашел при очистке Properties
При нажатии на левую клавишу проверяется свойство "on_off" ( window.GetProperty("on_off") ), а оно не объявлено.
Попробуйте вставить в любой место строку window.GetProperty("on_off", "play");
или все заменить:
Код: Выделить всё
// ==PREPROCESSOR==     

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

ColorTypeCUI = { background: 3,};                     
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);                     

DT_LEFT = 0x00000000;                     
DT_RIGHT = 0x00000002;                     
DT_CENTER = 0x00000001;                     
DT_VCENTER = 0x00000004;                     
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;

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

    var color1 = window.GetProperty("on_off") == "play" ? RGB(0,70,0): RGB(205,67,0);
    gr.FillSolidRect (0, 0, ww, wh, s_play > 0 && s_play <= 3 && timer_started ? color1 : bgcolor);
   
    var color2 = window.GetProperty("on_off") == "play" ? RGB(128,255,128) : RGB(255,175,89);
    gr.GdiDrawText(sec2time(s_play), font, timer_started ? s_play > 3 ? color2 : RGB(255,255,255) : RGB(150,150,150), 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}

var ttttt = 0;

var set_time = 0;
var s_play = 0;

var timer_started = false;
var stop_timer = false;

window.GetProperty("on_off", "play");

function timer_play() {
    if ((fb.IsPlaying && window.GetProperty("on_off") == "play") || (!fb.IsPlaying && window.GetProperty("on_off") == "stop")) {
        s_play = 0;
        set_time = 0;
        return;
    };
   
    timer_started = true;
    stop_timer = false;
   
    window.ClearInterval(timer);
    var timer = window.SetInterval(function() {
        s_play = s_play - 1;
        window.Repaint();
        if (s_play <= 0 || stop_timer) {
            window.ClearInterval(timer);
            s_play = 0;
            set_time = 0;
            timer_started = false;

            if (stop_timer) return;
           
            if ((!fb.IsPlaying || fb.IsPaused) && window.GetProperty("on_off") == "play") {
                fb.Play();
            };
           
            if (fb.IsPlaying && window.GetProperty("on_off") == "stop") {
                fb.Stop();
            };
        };
    }, 1000 );
}

var m2 = ["seconds","minute","hour"];
window.GetProperty("m2","seconds");
var m3f, m3l
choice_s_m_h();

function choice_s_m_h() {   
    var m3 = [];   
    for (var i = 0; i < m2.length; i++) {   
        if(m2[i] != window.GetProperty("m2")) m3.push(m2[i]);   
    }   
    m3f = m3[0];   
    m3l = m3[1];   
}   

var step1, step_2;   
set_step();   

function set_step() {   // if ShiftDown pressed
    if (window.GetProperty("m2") == "seconds") {step1 = 1; step2 = 10};   
    if (window.GetProperty("m2") == "minute") {step1 = 60; step2 = 600};   
    if (window.GetProperty("m2") == "hour") {step1 = 3600; step2 = 3600};
}

function sec2time(sec) {
    var h, m, s;
    h = Math.floor(sec / 3600);
    m = Math.floor((sec - h * 3600) / 60);
    s = sec - h * 3600 - m * 60;
    if ( m < 10 && h != 0) m = "0" + m;
    if ( s < 10) s = "0" + s;
    return (h == 0 ? "" : h + " : ") + m + " : " + s;
}

function on_mouse_lbtn_up (x, y){
    set_time = set_time <= 0 ? 0 : set_time;
    set_time = set_time >= 86400 ? 86400 : set_time;
       
    if (!timer_started) s_play = set_time;   
       
    window.Repaint();   

    MF_ENABLED = 0x00000000;   
    MF_GRAYED = 0x00000001;   

    var _menu = window.CreatePopupMenu();   
    var i = 1;   
       
    MF_STATE1 = set_time == 0 || set_time == 86400 ? MF_GRAYED : MF_ENABLED;   

    _menu.AppendMenuItem(MF_STATE1, i++, timer_started ? "timer ..." : sec2time(set_time));   
    _menu.AppendMenuItem(0x00000800, 0, 0);   
    _menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + "  +");   
    _menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + "  -");   
    _menu.AppendMenuItem(0x00000800, 0, 0);     
    _menu.AppendMenuItem(0x00000000, i++, m3f);   
    _menu.AppendMenuItem(0x00000000, i++, m3l);   
    _menu.AppendMenuItem(0x00000800, 0, 0);   
   
    MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;   
    _menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("on_off"));   
       
    if (timer_started) {   
        _menu.AppendMenuItem(0x00000800, 0, 0);     
        _menu.AppendMenuItem(0x00000000, i++, "clear timer");   
    }   
           
    ShiftDown = utils.IsKeyPressed(0x10) ? true : false;   

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

    switch (ret) {
    case 1:
        if (set_time > 0) {s_play = set_time; timer_play()};
        break;
    case 2:
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
        set_time =  set_time + (ShiftDown ? step2 : step1);
        on_mouse_lbtn_up (x, y);
        break;
    case 3:
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
        set_time = set_time - (ShiftDown ? step2 : step1);
        on_mouse_lbtn_up(x,y);
        break;
    case 4:
        window.SetProperty("m2",m3f);
        choice_s_m_h();
        set_step();
        on_mouse_lbtn_up(x,y);
        break;
    case 5:
        window.SetProperty("m2",m3l);
        choice_s_m_h();
        set_step();
        on_mouse_lbtn_up(x,y);
        break;
    case 6:
       window.GetProperty("on_off") == "play" ? window.SetProperty("on_off","stop") : window.SetProperty("on_off","play");
        on_mouse_lbtn_up(x,y);
        break;
       
    case 7:
        stop_timer = true;
        timer_started = false;
        break;
    }
    _menu.Dispose();
    if (!timer_started) set_time = 0;
    window.SetProperty("m2","seconds");
    choice_s_m_h();
}

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

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

function on_size(){
    ww = window.Width;   
    wh = window.Height;
}
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #414 MC Web » 07.07.2015, 15:10

kgena_ua, обнаружились интересные моменты:
- Проверял в окне компонента foo_dockable_panels своей сборки, исправленный скрипт запустился и меню ЛКМ выводит без ошибок. Кстати посмотрел скрипт и возникли сомнения, что после локализации будет работать - сомнения не подтвердились! Никак не мог запустить таймер:
kgena_ua:Запуск таймера - пункт 1.
А нужно - пункт 4, ну ладно с этим разобрался...
- Пока не разобрался с запуском таймера решил поставить на "чистый" официальный foobar2000 + foo_uie_wsh_panel_mod и на нем получил:
Код: Выделить всё
File: <main>
Ln: 8, Col: 1
<source text only available at compile time>

Идея-предложение, а что если объединить скрипт Digital Clock

Image 1.png


и скрипт Timer c возможностью выбора через меню (в выделенной области скриншота) помимо текущего времени (для меня это вообще спорная необходимость), времени таймера или времени воспроизведения с десятыми/сотыми долями секунды (как например в Adobe_Audition) - включать/отключать в меню доли секунд. Воспользовался бы foo_timedisplay, но он к сожалению не встраивается - только в виде отдельного окна.
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #415 kgena_ua » 07.07.2015, 15:41

MC Web, стр.8:
ColorTypeCUI = { background: 3,};
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);

это из
Код: Выделить всё
/ Used in window.GetColorCUI()
ColorTypeCUI = {
   text: 0,
   selection_text: 1,
   inactive_selection_text: 2,
   background: 3,
   selection_background: 4,
   inactive_selection_background: 5,
   active_item_frame: 6
};
Только для CUI
тут все стандартно. Я поставил чистый,только три плагина - все нормально.
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #416 MC Web » 07.07.2015, 18:26

kgena_ua, с 8 строкой понятно, привык что скрипты WSH и в DUI работают, поэтому и не смотрел внимательно. :smile:

Пытаюсь переделать для темы DarkOne, добавил при выводе слово Таймер: 0:00, обнаружил баг:
- при установке часов (больше 2-х) слово Таймер: пропадает
- если было выбрано на таймере время в часах/минутах (и в оригинальном скрипте то же), после запуска и сброса таймера (все сбрасывается), но при дальнейшем прибавлении (из меню) секунд - начинают прибавляться часы/минуты
Измененный скрипт
Код: Выделить всё
// ==PREPROCESSOR==     

function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }                     
var font = gdi.Font("DarkOne", 76, 0);                     
var ww,wh;                     

ColorTypeCUI = { background: 7,};                     
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);                     

DT_LEFT = 0x00000000;                     
DT_RIGHT = 0x00000002;                     
DT_CENTER = 0x00000001;                     
DT_VCENTER = 0x00000004;                     
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;

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

    var color1 = window.GetProperty("on_off") == "Воспроизвести" ? RGB(0,70,0): RGB(205,67,0);
    gr.FillSolidRect (0, 0, ww, wh, s_play > 0 && s_play <= 3 && timer_started ? color1 : bgcolor);
   
    var color2 = window.GetProperty("on_off") == "Воспроизвести" ? RGB(128,255,128) : RGB(255,175,89);
    gr.GdiDrawText(sec2time(s_play), font, timer_started ? s_play > 3 ? color2 : RGB(255,255,255) : RGB(128,192,255), 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}

var ttttt = 0;

var set_time = 0;
var s_play = 0;

var timer_started = false;
var stop_timer = false;

window.GetProperty("on_off", "Воспроизвести");

function timer_play() {
    if ((fb.IsPlaying && window.GetProperty("on_off") == "Воспроизвести") || (!fb.IsPlaying && window.GetProperty("on_off") == "Остановить")) {
        s_play = 0;
        set_time = 0;
        return;
    };
   
    timer_started = true;
    stop_timer = false;
   
    window.ClearInterval(timer);
    var timer = window.SetInterval(function() {
        s_play = s_play - 1;
        window.Repaint();
        if (s_play <= 0 || stop_timer) {
            window.ClearInterval(timer);
            s_play = 0;
            set_time = 0;
            timer_started = false;

            if (stop_timer) return;
           
            if ((!fb.IsPlaying || fb.IsPaused) && window.GetProperty("on_off") == "Воспроизвести") {
                fb.Play();
            };
           
            if (fb.IsPlaying && window.GetProperty("on_off") == "Остановить") {
                fb.Stop();
            };
        };
    }, 1000 );
}

var m2 = ["Секунды","Минуты","Часы"];
window.GetProperty("m2","Секунды");
var m3f, m3l
choice_s_m_h();

function choice_s_m_h() {   
    var m3 = [];   
    for (var i = 0; i < m2.length; i++) {   
        if(m2[i] != window.GetProperty("m2")) m3.push(m2[i]);   
    }   
    m3f = m3[0];   
    m3l = m3[1];   
}   

var step1, step_2;   
set_step();   

function set_step() {   // if ShiftDown pressed
    if (window.GetProperty("m2") == "Секунды") {step1 = 1; step2 = 10};   
    if (window.GetProperty("m2") == "Минуты") {step1 = 60; step2 = 600};   
    if (window.GetProperty("m2") == "Часы") {step1 = 3600; step2 = 3600};
}

function sec2time(sec) {
    var h, m, s;
    h = Math.floor(sec / 3600);
    m = Math.floor((sec - h * 3600) / 60);
    s = sec - h * 3600 - m * 60;
    if ( m < 10 && h != 0) m = "0" + m;
    if ( s < 10) s = "0" + s;
    return ("ТАЙМЕР: " + (h == 0 ? "" : h + ":") + m + ":" + s);
}

function on_mouse_lbtn_up (x, y){
    set_step();
    set_time = set_time <= 0 ? 0 : set_time;
    set_time = set_time >= 86400 ? 86400 : set_time;
       
    if (!timer_started) s_play = set_time;   
       
    window.Repaint();   

    MF_ENABLED = 0x00000000;   
    MF_GRAYED = 0x00000001;   

    var _menu = window.CreatePopupMenu();   
    var i = 1;   
       
    MF_STATE1 = set_time == 0 || set_time == 86400 ? MF_GRAYED : MF_ENABLED;   

    _menu.AppendMenuItem(MF_STATE1, i++, timer_started ? "Таймер..." : sec2time(set_time));   
    _menu.AppendMenuItem(0x00000800, 0, 0);   
    _menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + "  +");   
    _menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + "  -");   
    _menu.AppendMenuItem(0x00000800, 0, 0);     
    _menu.AppendMenuItem(0x00000000, i++, m3f);   
    _menu.AppendMenuItem(0x00000000, i++, m3l);   
    _menu.AppendMenuItem(0x00000800, 0, 0);   
   
    MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;   
    _menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("on_off"));   
       
    if (timer_started) {   
        _menu.AppendMenuItem(0x00000800, 0, 0);     
        _menu.AppendMenuItem(0x00000000, i++, "Сбросить таймер");   
    }   
           
    ShiftDown = utils.IsKeyPressed(0x10) ? true : false;   

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

    switch (ret) {
    case 1:
        if (set_time > 0) {s_play = set_time; timer_play()};
        break;
    case 2:
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
        set_time =  set_time + (ShiftDown ? step2 : step1);
        on_mouse_lbtn_up (x, y);
        break;
    case 3:
        ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
        set_time = set_time - (ShiftDown ? step2 : step1);
        on_mouse_lbtn_up(x,y);
        break;
    case 4:
        window.SetProperty("m2",m3f);
        choice_s_m_h();
        set_step();
        on_mouse_lbtn_up(x,y);
        break;
    case 5:
        window.SetProperty("m2",m3l);
        choice_s_m_h();
        set_step();
        on_mouse_lbtn_up(x,y);
        break;
    case 6:
       window.GetProperty("on_off") == "Воспроизвести" ? window.SetProperty("on_off","Остановить") : window.SetProperty("on_off","Воспроизвести");
        on_mouse_lbtn_up(x,y);
        break;
       
    case 7:
        stop_timer = true;
        timer_started = false;
        break;
    }
    _menu.Dispose();
    if (!timer_started) set_time = 0;
    window.SetProperty("m2","Секунды");
    choice_s_m_h();
}

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

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

function on_size(){
    ww = window.Width;   
    wh = window.Height;
}
Последний раз редактировалось MC Web 07.07.2015, 19:43, всего редактировалось 1 раз.
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #417 kgena_ua » 07.07.2015, 18:57

MC Web, по пункту 2:
Давайте попробуем при входе в меню проверять значение переменной step

function on_mouse_lbtn_up (x, y){
set_step();
set_time = set_time <= 0 ? 0 : set_time;
set_time = set_time >= 86400 ? 86400 : set_time;
kgena_ua M
Аватара
Откуда: Украина, Днепр
Репутация: 504
С нами: 11 лет

Сообщение #418 MC Web » 07.07.2015, 19:17

kgena_ua, одну ошибку исправили... :clap:

И с другой ошибкой, "методом тыка" - разобрался (мой косяк).
Исправил и в скрипте из своего предыдущего сообщения. :smile:
MC Web
Репутация: 248
С нами: 10 лет 7 месяцев

Сообщение #419 AHAPXICT » 07.07.2015, 21:38

Недавно чуть "пофиксил" шрифт, перенёс нижнее подчёркивание на ячейку ниже "_", "У" в английском на" Y" и непонятного снеговика на "&" . Сохранил в .otf(старый в .ttf), так что лучше старый удалить вручную, так как они теперь могут жить вместе. Ну и придётся "пофиксить" рамку календаря на часах(v3.1строка 114-115: 0-y , 28-y).
Y__& (FIX).png
Y__& (FIX).png (1.6 КБ) Просмотров: 2004

tedGo's DarkOne_NEW MATRIX 140x140x75(Y__&).rar
(12.04 КБ) Скачиваний: 310

kgena_ua, есть к вам вопрос как к разработчику бегущей строки. У меня никак не получается прицепить команду для режима паузы и стоп:
Код: Выделить всё
var tfo = fb.TitleFormat("[%tracknumber%. ]$upper(%title%)[ %length%]");

if (fb.IsPlaying) {
      text1, text2 = fb.IsPaused ? "- PAUSE -" : tfo.Eval();
      } else {
      text1, text2 = "- NO TRACK -";
      }
Этот кусок кода из скрипта CompactOne Control Panel. Лучшее что у меня получилось так это плавающая пауза по экрану)))))
Вот последняя ваша редакция Scroll Text с крутыми цветовыми переходами:
Код: Выделить всё
// Scroll Text
// author kgena_ua
// modifed AHAPXICT for CompactOne v1.0 by tedGo
// version 2.1
// WSH Panel Mod component by Tianpeng Wang

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));}
MF_SEPARATOR = 0x00000800;
MF_STRING = 0x00000000;
var font = gdi.Font("DarkOne",19,0);  //FONT
var ww,wh;
var txt_row = 2;
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;
get_color();

function on_paint(gr) {
   
    show1 = window.GetProperty("|1| Title",1);
    show2 = window.GetProperty("|2| Artist",1);
    show3 = window.GetProperty("|3| Album",1);
    mode = window.GetProperty("|5| Mode",1);
    showi = window.GetProperty("|4| Info",1);
   
    if (show1 == 1) {t1 = fb.TitleFormat("$upper([[%tracknumber%. ]%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);
   
    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};
        }
    }
 String.prototype.repeat = function(n) {
return new Array(n + 1).join(this);
}   
// ========BACKGROUND & BLOCKS======== //
//  gr.FillSolidRect (0, 0, ww, wh, RGB(19,30,38));
    gr.FillGradRect(0, 0, ww, 85, 90, RGBA(18, 29, 37, 255), RGBA(26, 47, 66, 195));
    gr.GdiDrawText( "\u2598".repeat(18), font, block_rgb, 0, txt_row, ww, wh);
// ========TEXT======== //   
    d = gr.CalcTextWidth("1000", font);
    gr.DrawString( text1, font, font_rgb, step1, txt_row, t_width1 + d, wh);
    gr.DrawString( text2, font, font_rgb, step2, txt_row, t_width2 + d, wh);
}

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

var seek_timer;
var speed = window.GetProperty("|7| Speed Scroll", 50);
function on_playback_new_track(info) {
    seek_timer && window.ClearInterval(seek_timer);
    seek_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();
    }, speed );
}

function on_playback_stop() {
    window.ClearInterval(seek_timer);
    window.Repaint();
}

function on_playback_time(){
    if(!seek_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("|1| Title", show1 == 0 ? 1 : 0);
        break;
    case 2:
        window.SetProperty("|2| Artist", show2 == 0 ? 1 : 0);
        break;
    case 3:
        window.SetProperty("|3| Album", show3 == 0 ? 1 : 0);
        break;
    case 4:
        window.SetProperty("|4| Info", showi == 0 ? 1 : 0);
        break;
    case 5:
        window.SetProperty("|5| Mode", mode == 0 ? 1 : 0);
        break;
    }
    _menu.Dispose();
    return true;
}
// ========Menu======== //
function on_mouse_rbtn_up(x, y) {

    var _menu = window.CreatePopupMenu();
   
    _menu.AppendMenuItem(MF_STRING, 1, "Default");
    _menu.AppendMenuItem(MF_STRING, 2, "Blue");
    _menu.AppendMenuItem(MF_STRING, 3, "Green");
    _menu.AppendMenuItem(MF_STRING, 4, "Red");
    _menu.AppendMenuItem(MF_STRING, 5, "White");
    _menu.AppendMenuItem(MF_STRING, 6, "Yellow")
    _menu.AppendMenuItem(MF_STRING, 7, "Grey")
    _menu.CheckMenuRadioItem(1, 7, window.GetProperty("|6| Color", 1));   

    _menu.AppendMenuItem(MF_SEPARATOR, 0, 0)
    _menu.AppendMenuItem(MF_STRING, 8, "Properties...");
    _menu.AppendMenuItem(MF_STRING, 9, "Configure...");

    idx = _menu.TrackPopupMenu(x, y);
    switch (idx) {

    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
       
        ch_color(idx);
 
        break;   
    case 8:
        window.ShowProperties();
        break;
    case 9:
        window.ShowConfigure();
        break;
}
    _menu.Dispose();
return true
}

var block_rgb, font_rgb;

function get_color() {
    if (window.GetProperty("|6| Color") == 1)  font_rgb = RGB(191,228,255), block_rgb = RGB(24,37,46);   //Default   
    if (window.GetProperty("|6| Color") == 2)  font_rgb = RGB(128,192,255), block_rgb = RGB(22,36,46);   //Blue   
    if (window.GetProperty("|6| Color") == 3)  font_rgb = RGB(0,255,0), block_rgb = RGB(18,38,38);       //Green   
    if (window.GetProperty("|6| Color") == 4)  font_rgb = RGB(255,0,0), block_rgb = RGB(38,26,34);       //Red   
    if (window.GetProperty("|6| Color") == 5)  font_rgb = RGB(255,255,255), block_rgb = RGB(26,38,46);   //White   
    if (window.GetProperty("|6| Color") == 6)  font_rgb = RGB(255,255,0), block_rgb = RGB(26,38,38);     //Yellow
    if (window.GetProperty("|6| Color") == 7)  font_rgb = RGB(85,136,171), block_rgb = RGB(22,36,45);    //Grey
}

function getRed(color) {
   return ((color >> 16) & 0xff);
}

function getGreen(color) {
   return ((color >> 8) & 0xff);
}

function getBlue(color) {
   return (color & 0xff);
}

var g_timer;

function ch_color(idx) {
    get_color();
    old_R = getRed(font_rgb);   
    old_G = getGreen(font_rgb);   
    old_B = getBlue(font_rgb);

    window.SetProperty("|6| Color", idx);   
   
    get_color();

    new_R = getRed(font_rgb);   
    new_G = getGreen(font_rgb);   
    new_B = getBlue(font_rgb);

    step_R = (new_R - old_R)/255; step_G = (new_G - old_G)/255; step_B = (new_B - old_B)/255;

    g_timer = window.SetInterval(function() {
        old_R = old_R + step_R; old_G = old_G + step_G; old_B = old_B + step_B;
        R = old_R; G = old_G; B = old_B;
        font_rgb = RGB(R,G,B)
        window.Repaint();
       
        if (
            step_R < 0 && R <= new_R || step_G < 0 && G <= new_G || step_B < 0 && B <= new_B ||
            step_R > 0 && R >= new_R || step_G > 0 && G >= new_G || step_B > 0 && B >= new_B
        ) {window.ClearInterval(g_timer); R = new_R; G = new_G; B = new_B; font_rgb = RGB(R,G,B)};
    }, 5);
}

//--END
AHAPXICT M
Аватара
Откуда: Киев
Репутация: 252
С нами: 10 лет 5 месяцев

Сообщение #420 kgena_ua » 07.07.2015, 22:50

У меня есть скрипт WSH properties. Решил заменить рейтинг с цифр на символ звезда. Пришел не работу - никаких звезд нет, одни кубики. Ну ясное дело. Решил звезды рисовать. Т.к. в WSH не умеет рисовать линиями. Для большого размера желательно отображать только контуры, а для маленького отображать все линии, которые удалось просчитать - получается эффект заливки.
Безымянный.png

Код: Выделить всё
// ==PREPROCESSOR==
// @name "Star"
// @author "kgena_ua"
// ==/PREPROCESSOR==

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

DT_LEFT = 0x00000000;
DT_WORD_ELLIPSIS = 0x00040000;

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

var line = 1;
var color = RGB (255,255,240);

function on_paint(gr){
    gr.FillSolidRect (0, 0, ww, wh, RGB(50,50,50));
   
    var radius = 20;
   
    var fill = false;
   
    var x = ww / 2;
    var y = ww / 2;
   
    var step1 = 5;
    var step2 = step1 * 2;

    var x_points_1 = [];
    var y_points_1 = [];
   
    var x_points_2 = [];
    var y_points_2 = [];
   
    gr.SetSmoothingMode(4);
       
    for (var i = 0; i < 5; i++) {
        var x1 = (radius * Math.cos(Math.PI * i / step1 * 2 - Math.PI / 2));
        var y1 = (radius * Math.sin(Math.PI * i / step1 * 2 - Math.PI / 2));
       
        fill && gr.DrawLine(x, y, x + x1, y + y1, 1, color);

        x_points_1.push(x + (radius * Math.cos(Math.PI * i / step1 * 2 - Math.PI / 2)));
        y_points_1.push(y + (radius * Math.sin(Math.PI * i / step1 * 2 - Math.PI / 2)));
    }
   
    for (var i = 0; i < step2; i++) {
        var x2 = (radius / 2.61803 * Math.cos(Math.PI * i / step2 * 2 - Math.PI / 2));
        var y2 = (radius / 2.61803 * Math.sin(Math.PI * i / step2 * 2 - Math.PI / 2));

        fill && gr.DrawLine(x, y, x + x2, y + y2, 1, color);
       
        x_points_2.push(x + (radius / 2.61803 * Math.cos(Math.PI * i / 10 * 2 - Math.PI / 2)));
        y_points_2.push(y + (radius / 2.61803 * Math.sin(Math.PI * i / 10 * 2 - Math.PI / 2)));
    }
   
    gr.DrawLine(x_points_1[0], y_points_1[0], x_points_2[1], y_points_2[1], line, color);
    gr.DrawLine(x_points_1[0], y_points_1[0], x_points_2[9], y_points_2[9], line, color);
    gr.DrawLine(x_points_1[1], y_points_1[1], x_points_2[1], y_points_2[1], line, color);
    gr.DrawLine(x_points_1[1], y_points_1[1], x_points_2[3], y_points_2[3], line, color);
    gr.DrawLine(x_points_1[2], y_points_1[2], x_points_2[3], y_points_2[3], line, color);
    gr.DrawLine(x_points_1[2], y_points_1[2], x_points_2[5], y_points_2[5], line, color);
    gr.DrawLine(x_points_1[3], y_points_1[3], x_points_2[5], y_points_2[5], line, color);
    gr.DrawLine(x_points_1[3], y_points_1[3], x_points_2[7], y_points_2[7], line, color);
    gr.DrawLine(x_points_1[4], y_points_1[4], x_points_2[7], y_points_2[7], line, color);
    gr.DrawLine(x_points_1[4], y_points_1[4], x_points_2[9], y_points_2[9], line, color);
   
    fill && gr.DrawLine(x_points_1[0], y_points_1[0], x_points_1[2], y_points_1[2], 1, color);
    fill && gr.DrawLine(x_points_1[0], y_points_1[0], x_points_1[3], y_points_1[3], 1, color);
    fill && gr.DrawLine(x_points_1[4], y_points_1[4], x_points_1[1], y_points_1[1], 1, color);
    fill && gr.DrawLine(x_points_1[4], y_points_1[4], x_points_1[2], y_points_1[2], 1, color);
    fill && gr.DrawLine(x_points_1[1], y_points_1[1], x_points_1[3], y_points_1[3], 1, color);
}

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

Пред.След.

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