Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Control Panel for StrigUI
- // completely reworked and restyled version of control buttons panel (by eXtremeHunter1972 from FooAero)
- // Latest change: 28.09.2014 fixed performance issues with on_mouse_move func
- var height = 64;
- window.MinHeight = height;
- window.MaxHeight = height;
- window.SetProperty("TipText", true);
- var d = new Date();
- var g_textrender = gdi.CreateStyleTextRender();
- var str = "";
- // ---> Initial timers
- window.SetInterval(function() {
- if (!fb.IsPlaying || fb.IsPaused || fb.PlaybackLength == 0) return;
- window.RepaintRect(seek_x - 10 + (seek_pos > 25 ? (seek_pos - 25) : 0), seek_y, 50, seek_h); // seek area
- }, 150);
- window.SetInterval(function(){ // create timer for initial clock display
- if (fb.IsPlaying) return;
- d = new Date();
- window.RepaintRect(time_x, time_y, time_w, time_h); // time area
- }, 1000);
- // ---> Additional images
- var imgPath = fb.FoobarPath + "themes\\strigUI\\Images\\";
- var SEEK_L1 = gdi.Image(imgPath + "Buttons\\SEEK_L1.png");
- var SEEK_L2 = gdi.Image(imgPath + "Buttons\\SEEK_L2.png");
- var dsp_button_img = gdi.Image(imgPath + "Buttons\\DSP_man.png");
- var eq_button_img = gdi.Image(imgPath + "Buttons\\EQ_ICO.png");
- var output_button_img = gdi.Image(imgPath + "Buttons\\OUT_ICO.png");
- var adj_button_img = gdi.Image(imgPath + "Buttons\\DJ_ICO.png");
- var adj_button_down_img = gdi.Image(imgPath + "Buttons\\DJ_H_ICO.png");
- var queue_button_img = gdi.Image(imgPath + "Buttons\\QUEUE_ICO.png");
- var queue_button_down_img = gdi.Image(imgPath + "Buttons\\QUEUE_ICO_.png");
- // ---> More vars
- var XYinVol = XYinVol_h = vol_drag = volume_change = sac = saci = XYinSeek = XYinSeek_h = XYinMenu = lbtn_down = seek_drag = ShiftDown = volume_change = vol_timer = false;
- var vol_pos = volstate = vol_x = vol_y = vol_w = vol_h = time_x = time_y = time_w = time_h = time_pos = seek_pos = ww = wh = 0;
- // ---> RATING vars
- var g_drag = 0;
- var g_rate = fb.TitleFormat("%RATING%");
- var bool = g_metadb = rating = nrating = lrating = img = XYinRate = false;
- var R_hoffset = 15;
- var R_voffset = 25;
- var R_imgw = 22;
- var R_w = R_imgw * 5;
- // ================================================== //
- // ---> Draw a star function
- function DrawPolyStar(gr, x, y, out_radius, in_radius, points, line_thickness, line_color, fill_color, angle, opacity){
- if(!opacity && opacity != 0) opacity = 255;
- //---> Create points
- var point_arr = [];
- for (var i = 0; i != points; i++) {
- i % 2 ? r = Math.round((out_radius-line_thickness*4)/2) / in_radius : r = Math.round((out_radius-line_thickness*4)/2);
- var x_point = Math.floor(r * Math.cos(Math.PI * i / points * 2 - Math.PI / 2));
- var y_point = Math.ceil(r * Math.sin(Math.PI * i / points * 2 - Math.PI / 2));
- point_arr.push(x_point + out_radius/2);
- point_arr.push(y_point + out_radius/2);
- }
- //---> Crate poligon image
- var img = gdi.CreateImage(out_radius, out_radius);
- var _gr = img.GetGraphics();
- _gr.SetSmoothingMode(2);
- _gr.FillPolygon(fill_color, 1, point_arr);
- if(line_thickness > 0)
- _gr.DrawPolygon(line_color, line_thickness, point_arr);
- img.ReleaseGraphics(_gr);
- //---> Draw image
- gr.DrawImage(img, x, y, out_radius, out_radius, 0, 0, out_radius, out_radius, angle, opacity);
- }
- // ---> Volume funcs
- function pos2vol(p) {
- return (50 * Math.log(0.99 * p + 0.01) / Math.log(10));
- }
- function vol2pos(v) {
- return (((Math.pow(10, v / 50) - 0.01) / 0.99));
- }
- // ---> Auto DJ functions
- function id_playlist(name){
- //fb.RunMainMenuCommand("Playback/Order/Default");
- var pl_dj;
- for (var i = 0; i <= plman.PlaylistCount; i++) {
- if (plman.GetPlaylistName(i) == name) {
- pl_dj = i;
- break;
- }
- }
- return pl_dj;
- }
- function run_dj() {
- fb.RunMainMenuCommand("Playback/Order/Default");
- var pl_dj = id_playlist("Auto DJ");
- if ( pl_dj == "?" || !pl_dj ) { // is there a list like this?
- pl_dj = plman.PlaylistCount + 1;
- plman.CreatePlaylist(pl_dj, "Auto DJ");
- pl_dj = id_playlist("Auto DJ"); // double checking list id
- }
- var items = plman.GetPlaylistItems(pl_dj);
- if (items.count < 1) { // that playlist must be new, lets seed a track and start playback so foo_random_pools can start working
- //if ( plman.PlaylistItemCount(pl_dj) < 1 ) {
- var selection = fb.GetSelections(0);
- var pos = 0;
- plman.SetPlaylistFocusItem(pl_dj, pos);
- plman.InsertPlaylistItems(pl_dj, pos, selection);
- plman.ExecutePlaylistDefaultAction(pl_dj, items.count);
- }
- plman.ActivePlaylist = pl_dj;
- //var items = plman.GetPlaylistItems(plman.ActivePlaylist);
- plman.ExecutePlaylistDefaultAction(plman.ActivePlaylist, items.count - 2);
- //if ( items.count > 10 ) {
- if ( items.count > 3 && !CtrlDown ) { // clear the old playlist and start a new one (if CTRL is not down)
- plman.ClearPlaylistSelection(plman.ActivePlaylist);
- plman.SetPlaylistSelectionSingle(plman.ActivePlaylist, items.count - 2 , true); // fb.TitleFormat("%title%")
- plman.SetActivePlaylistContext();
- fb.RunMainMenuCommand("Edit/Selection/Crop");
- }
- }
- // ---> Queue track functions
- function queue_track_last() {
- var selection = fb.GetSelections(0);
- var nowplaying = plman.GetPlayingItemLocation();
- var pid;
- if (fb.IsPlaying) {
- pid = nowplaying.PlaylistItemIndex;
- if(pid>=0 && pid<plman.PlaylistItemCount(plman.PlayingPlaylist)) {
- //plman.SetPlaylistFocusItem(plman.PlayingPlaylist, pid);
- CtrlDown ? plman.InsertPlaylistItems(plman.PlayingPlaylist, plman.PlaylistItemCount(plman.PlayingPlaylist) + 1, selection) : plman.InsertPlaylistItems(plman.PlayingPlaylist, pid + 1, selection);
- }
- } else {
- pid = plman.GetPlaylistFocusItemIndex(plman.PlayingPlaylist)
- plman.ExecutePlaylistDefaultAction(plman.PlayingPlaylist, pid);
- }
- }
- /*
- // ---> CPU profiling
- var UIHacks;
- uiHacks = utils.CheckComponent("foo_ui_hacks");
- if (uiHacks) {
- UIHacks = new ActiveXObject("UIHacks");
- }
- var g_foo_cpu_usage = "";
- UIHacks.CPUUsage;
- window.SetInterval(function () {
- if(utils.IsKeyPressed(VK_ALT)) {
- g_foo_cpu_usage = UIHacks.FoobarCPUUsage.toFixed(1)+'%';
- window.RepaintRect(10, 70, 50, 12);
- } else {
- g_foo_cpu_usage = "";
- }
- }, 1000);
- */
- // ================================================== //
- function on_draw(gr, x, x2, y, w, h, img, img2, op, state) {
- gr.DrawImage(img, Math.ceil(x), Math.ceil(y), Math.ceil(w), Math.ceil(h), 0, state*h, Math.ceil(w), Math.ceil(h), 0, 255); // creating background for buttons
- gr.DrawImage(img2, Math.ceil(x2), Math.ceil(y), Math.ceil(w), Math.ceil(h), 0, 0, Math.ceil(w), Math.ceil(h), 0, 200); // draw buttons
- }
- // ================================================== //
- // ---> Callbacks
- function on_paint (gr) {
- gr.FillSolidRect(0,0,ww,wh,RGB(0,0,0))
- gr.FillGradRect(-1,-1,ww+1,20,90,RGB(240,240,240),RGB(170,170,170),1);
- gr.FillGradRect(-1,14,ww+1,wh-14,90,RGB(90,90,90),RGB(50,50,50),1);
- gr.FillSolidRect(-1,12,ww+1,1,RGB(225,225,225));
- gr.FillSolidRect(-1,13,ww+1,1,RGB(55,55,55));
- // ---> FOO %cpu info
- //if(g_foo_cpu_usage.length > 0) gr.gdiDrawText(g_foo_cpu_usage, gdi.Font("arial", 9, 1), RGB(0,0,0), 10, 15, 30, 12, DT_LEFT | DT_TOP | DT_NOPREFIX | DT_END_ELLIPSIS);
- // ---> Draw Volume
- /*
- vol_pos = vol_w * Math.exp(fb.Volume / 33.333);
- gr.DrawImage(VOL_L, vol_x+7, vol_y+7, vol_pos-4, VOL_L.height, 0, 0, VOL_L.width, VOL_L.height, 0, 255);
- gr.DrawImage(VOL, vol_x+vol_pos-4, vol_y+2, VOL.width, VOL.height/3, 0, (XYinVol && XYinVol_h) || vol_drag ? ( volstate ==2 || vol_drag ? 2*VOL.height/3 : 1*VOL.height/3) : 0*VOL.height/3, VOL.width, VOL.height/3, 0, 255);
- gr.DrawRoundRect(vol_x + 5, vol_y + 5, vol_w, 6, 2, 2, 1, RGBA(255, 255, 255, 50));
- gr.DrawRoundRect(vol_x + 6, vol_y + 6, vol_w - 2, 4, 2, 2, 1, RGBA(0, 0, 0, 50));
- */
- //if (fb.Volume > -1) var pos = vol_w-2;
- vol_pos = vol_w * vol2pos(fb.Volume);
- gr.DrawImage(VOL_L, vol_x+4, vol_y+7, vol_pos-4, VOL_L.height, 0, 0, VOL_L.width, VOL_L.height, 0, 255);
- gr.DrawImage(VOL, vol_x+vol_pos-4, vol_y+2, VOL.width, VOL.height/3, 0, (XYinVol && XYinVol_h) || vol_drag ? ( volstate ==2 || vol_drag ? 2*VOL.height/3 : 1*VOL.height/3) : 0*VOL.height/3, VOL.width, VOL.height/3, 0, 255);
- gr.DrawRoundRect(vol_x + 2, vol_y + 5, vol_w, 6, 2, 2, 1, RGBA(255, 255, 255, 50));
- gr.DrawRoundRect(vol_x + 3, vol_y + 6, vol_w - 2, 4, 2, 2, 1, RGBA(0, 0, 0, 90));
- // ---> Draw buttons
- for (var i = 0; i < $buttons.length; i++) {
- $buttons[i].draw(gr);
- }
- // ---> Draw Seek
- var s = seek_drag ? time_pos : fb.PlaybackTime;
- var hou = Math.floor((s % 86400) / 3600);
- var min = Math.floor(((s % 86400) % 3600) / 60) + ":";
- var sec = Math.floor(((s % 86400) % 3600) % 60);
- var hou = hou > 0 ? hou + ":" : "";
- var sec = sec < 10 ? "0" + sec : sec;
- var playback_time = hou + min + sec;
- if (seek_w > 10) {
- gr.DrawRoundRect(seek_x, seek_y + 5, seek_w, 4, 2, 2, 1, RGBA(255, 255, 255, 50));
- gr.DrawRoundRect(seek_x + 1, seek_y + 6, seek_w - 2, 4, 1, 1, 1, RGBA(0, 0, 0, 90));
- if (fb.IsPlaying && fb.PlaybackLength > 0 && !seek_drag) {
- seek_pos = seek_w * (fb.PlaybackTime / fb.PlaybackLength) + 1;
- }
- if (fb.IsPlaying && fb.PlaybackLength > 0){
- if (seek_pos > 5) gr.DrawImage(SEEK_L1, seek_x + 2, seek_y + 6, seek_pos - 4, SEEK_L1.height, 0, 0, SEEK_L1.width, SEEK_L1.height, 0, 255);
- if (!XYinSeek) {
- seek_pos < 18 ? se = 18 - seek_pos : se = 0;
- gr.DrawImage(SEEK_L2, seek_x + seek_pos - SEEK_L2.width + se, seek_y + 6, SEEK_L2.width, SEEK_L2.height, se, 0, SEEK_L2.width, SEEK_L2.height, 0, 255);
- } else {
- gr.DrawImage(SEEK, seek_x + seek_pos - SEEK.width / 2, seek_y + 4, SEEK.width, SEEK.height / 3, 0, XYinSeek_h || seek_drag ? (lbtn_down || seek_drag ? 2 * SEEK.height / 3 : 1 * SEEK.height / 3) : 0 * SEEK.height / 3, SEEK.width, SEEK.height / 3, 0, 255);
- }
- }
- }
- // ---> Draw Text
- //if(ww > 564) {
- if (!volume_change) fb.IsPlaying ? str = fb.TitleFormat("[%playback_time%][ - %length%]").Eval() : str = d.toLocaleTimeString();
- //var txt_len = "[ - %length%]";
- //if (!volume_change) fb.IsPlaying ? str = fb.TitleFormat("[%playback_time%]" + txt_len).Eval() : str = d.toLocaleTimeString();
- if (seek_drag) var str = playback_time + fb.TitleFormat("[ / -%playback_time_remaining%]").Eval();
- if (volume_change) var str = Math.round(vol2pos(fb.Volume) * 100) + "% (" + Math.ceil(fb.Volume) + "db)";//Math.ceil(fb.Volume) + "db";
- var time_font = gdi.font("lucida sans unicode", 13, 1);
- var time_font = gdi.font("arial", 13, 1);
- gr.SetSmoothingMode(4);
- g_textrender.GlowText(RGBA(250, 250, 255, 220), RGBA(10, 10, 10, 22), 3);
- g_textrender.EnableShadow(true);
- g_textrender.ResetShadow();
- g_textrender.RenderStringRect(gr, str, time_font, time_x, time_y + 2, time_w, time_h, StringFormat(1, 1, 3, 0x1000));
- //}
- // RATING
- if (g_metadb) {
- for (i = 1; i < 6; i++) {
- //img = DrawPolyStar(gr, R_hoffset+R_imgw*(i-1),R_voffset,22,2.62, 10, 1, RGB(40,40,40),
- img = DrawPolyStar(gr, R_hoffset+R_imgw*(i-1),R_voffset,22,1.94, 10, 1, RGB(40,40,40),
- ((i > ((g_drag && XYinRate ) ? lrating : rating)) ? RGB(110,110,110) : RGB(200,200,200) ));
- }
- };
- }
- // ================================================== //
- function on_size() {
- ww = window.Width;
- wh = window.Height;
- if (ww <= 0 || wh <= 0) return;
- seek_x = 10;
- seek_y = -2;
- seek_w = ww - seek_x*2;
- seek_h = 15;
- //(ww/2 > 300) ? time_x = ww/2-300 : time_x = 0;
- time_x = ww/2-285;
- time_y = wh-40;
- time_w = 109;
- time_h = 20;
- //var bd = 20;
- bx = ww/2-PLAY.width/2 ;
- by = wh-PLAY.height/3-4;
- vol_x = ww/2+190;
- vol_y = by+12;
- vol_w = 70;
- vol_h = 17;
- var MUTE = MUTE_ICO_3;
- if(fb.Volume < -10) MUTE = MUTE_ICO_2;
- if(fb.Volume < -23) MUTE = MUTE_ICO_1;
- if(fb.Volume < -80) MUTE = MUTE_ICO_0;
- if(fb.Volume == -100) MUTE = MUTE_ICO;
- if(fb.PlaybackOrder == 4) S_ICO = SHUFFLE_ICO_; // Shuffle tracks
- if(fb.PlaybackOrder == 5) S_ICO = SHUFFLE_ICO_2; // Shuffle albums
- if(fb.PlaybackOrder != 4 && fb.PlaybackOrder != 5) S_ICO = SHUFFLE_ICO;
- if(fb.PlaybackOrder == 2) R_ICO = REPEAT_ICO_; // Repaeat playlist
- if(fb.PlaybackOrder == 1) R_ICO = REPEAT_ICO_2; // Repeat track
- if(fb.PlaybackOrder != 1 && fb.PlaybackOrder != 2) R_ICO = REPEAT_ICO;
- var DJ_ICO;
- if(plman.GetPlaylistName(fb.PlayingPlaylist) != "Auto DJ") DJ_ICO = adj_button_img;
- if(plman.GetPlaylistName(fb.PlayingPlaylist) == "Auto DJ") DJ_ICO = adj_button_down_img;
- saci ? ST_ICO = STOP_ICO_2 : ST_ICO = STOP_ICO;
- $buttons = [
- new Button(bx-PLAY.width-PREV.width+11, bx-PLAY.width-PREV.width+11, by+8, B.width, B.height/3, B, fb.IsPlaying ? ST_ICO : STOP_ICO_, function () {
- CtrlDown == true ? fb.RunMainMenuCommand("Playback/Stop after current") : fb.Stop();
- },"Stop\n+Ctrl: Stop after current"),
- new Button(bx-PREV.width, bx-PREV.width+1, by+8, PREV.width, PREV.height/3, PREV, fb.IsPlaying ? PREV_ICO : PREV_ICO_, function () {
- fb.Prev();
- }),
- new Button(bx, bx+1, by, PLAY.width, PLAY.height / 3, PLAY, fb.IsPlaying ? (fb.IsPaused ? PLAY_ICO : PAUSE_ICO) : PLAY_ICO_, function () {
- fb.PlayOrPause();
- }),
- new Button(bx+PLAY.width, bx+PLAY.width-3, by+8, NEXT.width, NEXT.height/3, NEXT, fb.IsPlaying ? NEXT_ICO : NEXT_ICO_, function () {
- fb.Next();
- }),
- new Button(bx-155, bx-155, by+8, B.width, B.height/3, B, S_ICO, function () {
- fb.PlaybackOrder != 4 && fb.PlaybackOrder != 5 ? (CtrlDown ? fb.PlaybackOrder = 5 : fb.PlaybackOrder = 4) : (CtrlDown && fb.PlaybackOrder == 4) ? fb.PlaybackOrder = 5 : fb.PlaybackOrder = 0;
- },"Shuffle tracks\n+Ctrl: Shuffle albums"),
- new Button(bx-120, bx-120, by+8, B.width, B.height/3, B, R_ICO, function () {
- fb.PlaybackOrder != 1 && fb.PlaybackOrder != 2 ? (CtrlDown ? fb.PlaybackOrder = 1 : fb.PlaybackOrder = 2) : (CtrlDown && fb.PlaybackOrder == 2) ? fb.PlaybackOrder = 1 : fb.PlaybackOrder = 0;
- },"Repeat track\n+Ctrl: Repeat playlist"),
- new Button(bx+185, bx+185, by+8, B.width, B.height/3, B, MUTE, function () {
- fb.VolumeMute();
- },"Mute"),
- new Button(bx+105, bx+105, by+8, B.width, B.height/3, B, fb.IsPlaying ? queue_button_img : queue_button_down_img, function () {
- queue_track_last();
- },"Queue track\n+Ctrl: Queue to the end of playlist"),
- new Button(bx+145, bx+145, by+8, B.width, B.height/3, B, DJ_ICO, function () {
- run_dj();
- },"Auto DJ\n+Ctrl: Enable without clearing playlist"),
- /*new Button(ww-135, ww-135, by+8, B.width, B.height/3, B, eq_button_img, function () {
- fb.RunMainMenuCommand("View/Equalizer");
- }),*/
- new Button(ww-75, ww-75, by+8, B.width, B.height/3, B, dsp_button_img, function () {
- CtrlDown == true ? fb.RunMainMenuCommand("View/Equalizer") : fb.RunMainMenuCommand("Playback/DSP settings/Preferences");
- },"DSP settings\n+Ctrl: Equalizer"),
- new Button(ww-105, ww-105, by+8, B.width, B.height/3, B, output_button_img, function () {
- fb.RunMainMenuCommand("Playback/Device/Preferences...");
- },"Configure audio output"),
- new Button(ww-45, ww-45, by+8, ww > 482 ? B.width : 0, ww > 482 ? B.height/3 : 0, B, /*fb.IsPlaying ?*/ MENU_ICO /*: MENU_ICO_*/, function () {
- // ==================== Main Menu==================== //
- if (CtrlDown == true) {
- fb.RunMainMenuCommand("View/Layout/Enable layout editing mode");
- return;
- }
- var basemenu = window.CreatePopupMenu();
- var contextman = fb.CreateContextMenuManager();
- contextman.InitNowPlaying();
- var child1 = window.CreatePopupMenu(); //File
- var child2 = window.CreatePopupMenu(); //Edit
- var child3 = window.CreatePopupMenu(); //View
- var child4 = window.CreatePopupMenu(); //Playback
- var child5 = window.CreatePopupMenu(); //Library
- var child6 = window.CreatePopupMenu(); //Help
- var child7 = window.CreatePopupMenu(); //Now playing
- var menuman1 = fb.CreateMainMenuManager();
- var menuman2 = fb.CreateMainMenuManager();
- var menuman3 = fb.CreateMainMenuManager();
- var menuman4 = fb.CreateMainMenuManager();
- var menuman5 = fb.CreateMainMenuManager();
- var menuman6 = fb.CreateMainMenuManager();
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child1.ID, "File");
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child2.ID, "Edit");
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child3.ID, "View");
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child4.ID, "Playback");
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child5.ID, "Library");
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child6.ID, "Help");
- basemenu.AppendMenuItem(MF_STRING | MF_POPUP, child7.ID, "Now Playing");
- menuman1.Init("file");
- menuman2.Init("edit");
- menuman3.Init("View");
- menuman4.Init("playback");
- menuman5.Init("library");
- menuman6.Init("help");
- menuman1.BuildMenu(child1, 1, 200);
- menuman2.BuildMenu(child2, 201, 200);
- menuman3.BuildMenu(child3, 401, 200);
- menuman4.BuildMenu(child4, 601, 300);
- menuman5.BuildMenu(child5, 901, 300);
- menuman6.BuildMenu(child6, 1201, 100);
- contextman.InitNowPlaying();
- contextman.BuildMenu(child7, 1301, -1);
- ret = 0;
- ret = basemenu.TrackPopupMenu(ww-160, wh-200);
- switch (true) {
- case (ret >= 1 && ret < 201):
- menuman1.ExecuteByID(ret - 1);
- break;
- case (ret >= 201 && ret < 401):
- menuman2.ExecuteByID(ret - 201);
- break;
- case (ret >= 401 && ret < 601):
- menuman3.ExecuteByID(ret - 401);
- break;
- case (ret >= 601 && ret < 901):
- menuman4.ExecuteByID(ret - 601);
- break;
- case (ret >= 901 && ret < 1201):
- menuman5.ExecuteByID(ret - 901);
- break;
- case (ret >= 1201 && ret < 1301):
- menuman6.ExecuteByID(ret - 1201);
- break;
- case (ret >= 1301):
- contextman.ExecuteByID(ret - 1301);
- break;
- }
- basemenu.Dispose();
- contextman.Dispose();
- menuman1.Dispose();
- menuman2.Dispose();
- menuman3.Dispose();
- menuman4.Dispose();
- menuman5.Dispose();
- menuman6.Dispose();
- },"Main menu\n+Ctrl: Toggle layout edditing mode")
- ]
- }
- // ================================================== //
- //var voltimeout;
- function elements_on_mouse_move (x, y) {
- XYinVol = ((vol_x <= x) && (x <= vol_x + vol_w+5) && (vol_y <= y) && (y <= vol_y + vol_h));
- //XYinVol_h = ((vol_x+vol_pos-VOL.width/2 <= x) && (x <= vol_x+vol_pos-VOL.width/2 + VOL.width) && (vol_y <= y) && (y <= vol_y + vol_h));
- XYinSeek = ((seek_x <= x) && (x <= seek_x + seek_w) && (seek_y <= y) && (y <= seek_y + seek_h));
- XYinSeek_h = ((seek_x + seek_pos - SEEK.width / 2 <= x) && (x <= seek_x + seek_pos - SEEK.width / 2 + SEEK.width) && (seek_y <= y) && (y <= seek_y + seek_h));
- //window.RepaintRect(vol_x+vol_pos-VOL.width/2-3, vol_y, VOL.width+10, vol_h); // Repaint vol knob
- /*
- if (XYinVol && XYinVol_h) {
- window.RepaintRect(vol_x+vol_pos-VOL.width/2-3, vol_y, VOL.width+10, vol_h); // Repaint vol knob
- } else { // TEST THIS SHIT
- voltimeout = window.SetTimeout(function() {
- volstate = 0;
- window.RepaintRect(vol_x+vol_pos-VOL.width/2-3, vol_y, VOL.width+10, vol_h); // Repaint vol knob
- window.ClearInterval(voltimeout);
- }, 100);
- }
- */
- //var v = (x - vol_x) / vol_w;
- //if (vol_drag == true && v > 0) fb.Volume = Math.log(v) * 33.333;
- //if (vol_drag == true && v > 0) fb.Volume = pos2vol(v);
- var v = Math.max(0, Math.min(vol_w, x - vol_x)) / vol_w
- if (vol_drag == true && v >= 0) fb.Volume = pos2vol(v);
- if (vol_drag) window.RepaintRect(bx+185+B.width, by+8, vol_w+10, vol_h); // vol area; VOL.height
- if (fb.PlaybackTime > 0 && XYinSeek && seek_drag) {
- seek_pos = seek_w * (x / seek_w) - seek_x;
- time_pos = fb.PlaybackLength * (x - seek_x) / seek_w;
- }
- if (seek_drag) window.RepaintRect(seek_x - 15, 0, ww, wh); //Repaint seek area;*/
- }
- var rate_timer = rate_timeout = false;
- function rating_on_mouse_move (x, y) {
- XYinRate = ((R_hoffset <= x) && (x <= R_hoffset + R_w+5) && (R_voffset <= y) && (y <= R_voffset + R_imgw));
- if (g_metadb && XYinRate) {
- g_drag = 1;
- nrating = Math.ceil((x-R_hoffset)/R_imgw);
- if (nrating > 5) nrating = 5;
- if (nrating != lrating) {
- lrating = nrating;
- }
- }
- if (XYinRate) { // mouse enters stars area
- if (!rate_timer) rate_timer = window.SetInterval(function() {
- //if (g_metadb && XYinRate) {
- if (g_metadb) {
- window.RepaintRect(R_hoffset, R_voffset, R_imgw*5, R_imgw+5); //Repaint RATING area;
- }
- }, 80); // 80 ms refresh rate seems smooth enough
- } else { // mouse leaving stars area
- /*if (lrating !=rating) {
- g_drag = rating;
- };*/
- if (rate_timer) rate_timeout = window.SetTimeout(function() { // timeout to kill timer
- if (rate_timer) window.ClearInterval(rate_timer);
- rate_timer = false;
- //window.RepaintRect(R_hoffset, R_voffset, R_imgw*5, R_imgw+5); //Repaint RATING area;
- on_metadb_changed();
- //if (rate_timeout) window.ClearInterval(rate_timeout);
- }, 150);
- }
- }
- function on_mouse_move(x, y) {
- elements_on_mouse_move (x, y);
- rating_on_mouse_move (x, y);
- buttons_on_mouse_move(x, y);
- if (XYinVol || XYinSeek || XYinRate) {
- window.SetCursor(32649);
- } else {
- if (!hbtn) {
- window.SetCursor(32512);
- }
- }
- }
- // ================================================== //
- function on_volume_change(val) {
- volume_change = true;
- //vol_timer = window.CreateTimerTimeout(2000); // window.SetInterval(2000); //
- vol_timer = window.SetTimeout(function() {
- //if (vol_timer && id == vol_timer.ID) {
- volume_change = false;
- window.ClearInterval(vol_timer);
- //window.RepaintRect(time_x, time_y, time_w, time_h); // time area
- //}
- }, 2000);
- window.RepaintRect(time_x, time_y, time_w, time_h); // time area
- window.RepaintRect(vol_x+vol_pos-VOL.width/2-3, vol_y, VOL.width+10, vol_h); // Repaint vol knob
- on_size();
- //window.RepaintRect(bx+100, by+5, 115, B.height/3+5);
- window.RepaintRect(bx+185, by+8, B.width+5, B.height/3+5); // vol button area
- }
- // ================================================== //
- function on_mouse_lbtn_down(x, y) {
- volstate == 1 ? volstate = 2: volstate = 0;
- if (XYinVol) {
- vol_drag = true;
- //on_mouse_move(x, y);
- elements_on_mouse_move (x, y);
- }
- if (XYinSeek && fb.Isplaying) {
- seek_drag = true;
- volume_change = false;
- if (fb.PlaybackTime > 0 && seek_drag) {
- //on_mouse_move(x, y);
- elements_on_mouse_move (x, y);
- }
- }
- CtrlDown = utils.IsKeyPressed(0x11) ? true : false;
- buttons_on_mouse_lbtn_down(x, y);
- }
- // ================================================== //
- function on_mouse_lbtn_up(x, y) {
- volstate = 0;
- vol_drag = false;
- lbtn_down = false;
- if (XYinSeek && seek_drag) {
- fb.PlaybackTime = fb.PlaybackLength * (x - seek_x) / seek_w;
- }
- seek_drag = false;
- window.Repaint();
- buttons_on_mouse_lbtn_up(x, y);
- //RATING
- if (lrating !=rating && XYinRate) {if (g_metadb) {
- bool = g_metadb.UpdateFileInfoSimple("RATING",lrating);
- }}
- }
- // ================================================== //
- function on_mouse_leave() {
- XYinVol_h = XYinVol = XYinSeek = seek_drag = lbtn_down = vol_drag = XYinRate = false;
- //RATING
- //on_metadb_changed();
- if(!vol_timer)
- volume_change = false;
- buttons_on_mouse_leave();
- }
- function on_item_focus_change() {
- if (g_metadb) {window.UnwatchMetadb();}
- g_metadb = fb.GetFocusItem();
- if (fb.GetNowPlaying()) {g_metadb = fb.GetNowPlaying();}
- if (g_metadb) {
- on_metadb_changed();
- window.WatchMetadb(g_metadb);
- }
- window.RepaintRect(R_hoffset, R_voffset, R_imgw*5, R_imgw+5); //Repaint RATING area;
- }
- on_item_focus_change();
- function on_metadb_changed() {
- g_drag = 0;
- //rating = g_rate.EvalWithMetadb(g_metadb);
- if (g_metadb) {rating = g_rate.EvalWithMetadb(g_metadb);}
- if (rating == "?") {rating = 0;}
- lrating = rating;
- //window.Repaint();
- window.RepaintRect(R_hoffset, R_voffset, R_imgw*5, R_imgw+5); //Repaint RATING area;
- }
- // ================================================== //
- function on_playback_pause(state) {
- on_size();
- window.RepaintRect(bx, by, PLAY.width, PLAY.height/3-3); // PLAY/PAUSE area
- }
- // ================================================== //
- function on_playback_stop(reason) {
- if (reason != 2) {
- saci = false;
- seek_pos = 0;
- on_size();
- window.Repaint();
- }
- }
- // ================================================== //
- function on_mouse_wheel(delta) {
- volume_change = true;
- fb.Volume = fb.Volume + delta * Math.exp(-fb.Volume / 33.333);
- }
- // ================================================== //
- function on_mouse_lbtn_dblclk(x, y) {
- if(!xy && !XYinVol && !XYinRate && !XYinSeek)
- fb.ShowPreferences();
- }
- // ================================================== //
- function on_mouse_rbtn_down(x, y) {
- ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
- }
- // ================================================== //
- function on_playlist_stop_after_current_changed(state) {
- state ? sac = true : sac = false;
- if(sac == false) saci = false;
- on_size();
- window.RepaintRect(ww/2-110,22,32,32); // stop area
- }
- // ================================================== //
- function on_playback_time(time) {
- if (sac == true && Math.round(time % 2) == 1) {
- saci == false ? saci = true : saci = false;
- on_size();
- window.RepaintRect(ww/2-110,22,32,32); // stop area
- }
- if(volume_change == false) window.RepaintRect(time_x, time_y, time_w, time_h); // display volume value in time area
- }
- // ================================================== //
- function on_playback_order_changed(new_order_index) {
- on_size();
- window.RepaintRect(bx-170, by+5, 70, B.height/3+5); // PBO
- }
- // ================================================== //
- function on_playback_new_track() {
- window.RepaintRect(0, 0, ww, 20); //Repaint seek area;
- //RATING
- if (rate_timer) { window.ClearInterval(rate_timer); rate_timer = false; }
- if (rate_timeout) { window.ClearInterval(rate_timeout); rate_timeout = false; }
- g_drag = 0;
- on_item_focus_change();
- }
- // ================================================== //
- function on_mouse_rbtn_up(x, y) {
- var Menu = window.CreatePopupMenu();
- Menu.AppendMenuItem(MF_STRING, 1, "Google");
- Menu.AppendMenuItem(MF_STRING, 2, "Google Images");
- //Menu.AppendMenuItem(MF_STRING, 3, "Cover-Paradies");
- Menu.AppendMenuItem(MF_STRING, 4, "Wikipedia");
- Menu.AppendMenuItem(MF_STRING, 5, "YouTube");
- Menu.AppendMenuItem(MF_STRING, 6, "Last FM");
- Menu.AppendMenuItem(MF_STRING, 7, "Discogs");
- Menu.AppendMenuItem(MF_STRING, 8, "RuTracker");
- if(ShiftDown){
- Menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- Menu.AppendMenuItem(MF_STRING, 20, "Properties");
- Menu.AppendMenuItem(MF_STRING, 21, "Configure...");
- }
- Menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- Menu.AppendMenuItem(MF_STRING, 22, "Console");
- Menu.AppendMenuItem(MF_STRING, 23, "Restart Foobar");
- //Menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- switch (Menu.TrackPopupMenu(x, y)) {
- case 1:
- try {WshShell.run("http://images.google.com/search?q="+fb.TitleFormat("$replace(%artist%, ,+)&ie=utf-8").Eval(true));} catch (e) {};
- break;
- case 2:
- try {WshShell.run("http://images.google.com/images?hl=en&q="+fb.TitleFormat("$replace(%artist%, ,+)&ie=utf-8").Eval(true));} catch (e) {};
- break;
- //case 3:
- //try {WshShell.run("http://cover-paradies.to/?Module=ExtendedSearch&SearchString="+fb.TitleFormat("$replace(%artist%+%album%, ,+)&ie=utf-8").Eval(true));} catch (e) {};
- //break;
- case 4:
- try {WshShell.run("http://en.wikipedia.org/wiki/"+fb.TitleFormat("$replace(%artist%,' ','_','&','and')").Eval(true));} catch (e) {};
- break;
- case 5:
- try {WshShell.run("http://www.youtube.com/results?search_type=&search_query="+fb.TitleFormat("$replace(%artist%, ,+)&ie=utf-8").Eval(true));} catch (e) {};
- break;
- case 6:
- try {WshShell.run("http://www.last.fm/music/" + fb.TitleFormat("$replace(%artist%,' ','+','&','and','/','%252F')").Eval(true));} catch (e) {};
- break;
- case 7:
- try {WshShell.run("http://www.discogs.com/search?q=" + fb.TitleFormat("$replace(%artist%+%album%, ,+)&ie=utf-8").Eval(true));} catch (e) {};
- break;
- case 8:
- try {WshShell.run("http://rutracker.org/forum/tracker.php?nm=" + fb.TitleFormat("$replace(%artist%+%album%, ,+)&ie=utf-8").Eval(true));} catch (e) {};
- break;
- case 20:
- window.ShowProperties();
- break;
- case 21:
- window.ShowConfigure();
- break;
- case 22:
- fb.ShowConsole();
- break;
- case 23:
- fb.RunMainMenuCommand("File/Restart");
- break;
- }
- Menu.Dispose();
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement