Advertisement
Guest User

DO4MOD Buttons

a guest
Aug 30th, 2019
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ---------- GLOBAL PART ----------
  2. // ----- Code by tedGo, using partial code by eXtremeHunter1972
  3.  
  4. var configName = "darkone4mod";
  5. var configPath = fb.ProfilePath + "cui-configs\\" + configName + "\\";
  6. var imgPath = configPath + "images\\";
  7. var g_signs = gdi.Image(imgPath + "Signs.png");
  8.  
  9. var ui_type = window.InstanceType;
  10. var ww = 0; wh = 0;
  11.  
  12. // ----- CREATE RGB(A) -----
  13. function RGBA(r, g, b, a) {
  14.     return ((a << 24) | (r << 16) | (g << 8) | (b));
  15. }
  16.  
  17. function RGB(r, g, b) {
  18.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  19. }
  20.  
  21. // ----- CREATE CUSTOM COLOURS -----
  22. function CustomColour(colour){
  23.     tempc = colour.split("-");
  24.     return ((tempc[3] << 24) | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
  25. }
  26.  
  27. function setAlpha(colour, a) {
  28.     return ((colour & 0x00ffffff) | (a << 24));
  29. }
  30.  
  31. function toRGB(d){
  32.     var d, r, g, b;
  33.     d = d - 0xff000000; r = d >> 16; g = d >> 8 & 0xFF; b = d & 0xFF;
  34.     return [r,g,b];
  35. }
  36.  
  37. function combColours(c1, c2, f){
  38.     var c1, c2;
  39.     c1 = toRGB(c1); c2 = toRGB(c2);
  40.  
  41.     var r, g, b;
  42.     r = Math.round(c1[0] + f * (c2[0] - c1[0])); g = Math.round(c1[1] + f * (c2[1] - c1[1])); b = Math.round(c1[2] + f * (c2[2] - c1[2]));
  43.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  44. }
  45.  
  46. // ----- GET UI COLOURS -----
  47. function get_colours() {
  48.     ui_backcol = ui_type == 0 ? window.GetColourCUI(3) : window.GetColourDUI(1);
  49.     ui_textcol = ui_type == 0 ? window.GetColourCUI(0) : window.GetColourDUI(0);
  50.     ui_btntxtcol = ui_type == 0 ? window.GetColourCUI(2) : window.GetColourDUI(0);
  51. }
  52.  
  53. get_colours();
  54.  
  55. function on_colors_changed() {
  56.     get_colours();
  57.     window.Repaint();
  58. }
  59.  
  60. // ----- HELPER -----
  61. function repeat(str, num) {
  62.     num = Number(num);
  63.  
  64.     var result = '';
  65.     while (true) {
  66.         if (num & 1) result += str;
  67.         num >>>= 1;
  68.         if (num <= 0) break;
  69.         str += str;
  70.     }
  71.  
  72.         return result;
  73. }
  74.  
  75. // ----- ACTIVE-X-OBJECTS -----
  76. function actXobj() {
  77.     var fso = new ActiveXObject("Scripting.FileSystemObject");
  78.     var sha = new ActiveXObject("Shell.Application");
  79.     var vbe = new ActiveXObject("ScriptControl");
  80.     vbe.Language = "VBScript";
  81.     vbe.AllowUI = true;
  82.  
  83.     this.fsoCreate = function(path1, path2) {
  84.         return fso.FileExists(path1) || fso.FileExists(path2) ? null : fso.CreateTextFile(path1, true);
  85.     }
  86.  
  87.     this.fsoSwitch = function(path1, path2) {
  88.         return fso.FileExists(path1) ? fso.MoveFile(path1, path2) : fso.MoveFile(path2, path1);
  89.     }
  90.  
  91.     this.shaOpen = function(path) {
  92.         return sha.Open(path);
  93.     }
  94.  
  95.     function toVBStr(str) {
  96.         return str != null ? 'Unescape("' + escape(str + "") + '")' : "Empty";
  97.     }
  98.  
  99.     this.vbBox = function(key, prompt, title, value) {
  100.         if (key == 0) return vbe.eval('InputBox(' + [toVBStr(prompt), toVBStr(title), toVBStr(value)].join(",") + ')');
  101.         if (key == 1) return vbe.eval('MsgBox(' + [toVBStr(prompt), value != null ? value : "Empty", toVBStr(title)].join(",") + ')');
  102.     }
  103. }
  104.  
  105. var axo = new actXobj();
  106.  
  107.  
  108.  
  109.  
  110.  
  111. // ---------- GLOBAL BUTTON SCRIPT ----------
  112. // ----- Code by tedGo, based on a sample by T.P. Wang
  113.  
  114. var ButtonStates = {normal: 0, hover: 1, down: 2, hide: 3};
  115. var Buttons = {};
  116. var btn_down = false;
  117. var cur_btn = null;
  118. var btn_tooltip;
  119.  
  120. function buttonsDraw(gr) {
  121.     for (var i in Buttons) Buttons[i].draw(gr);
  122. }
  123.  
  124. function buttonsTraceMouse(x, y) {
  125.     var btn = null;
  126.     for (var i in Buttons) {
  127.         if (Buttons[i].traceMouse(x, y) && !btn)
  128.             btn = Buttons[i];
  129.     }
  130.     return btn;
  131. }
  132.  
  133. function buttonsMouseMove(x, y) {
  134.     var btn = buttonsTraceMouse(x, y);
  135.  
  136.     if (btn != cur_btn) {
  137.         cur_btn && cur_btn.onMouseOut();
  138.         btn && btn.onMouseIn();
  139.     }
  140.  
  141.     cur_btn = btn;
  142. }
  143.  
  144. function buttonsMouseLbtnDown(x, y) {
  145.     btn_down = true;
  146.     (btn_down = cur_btn) && cur_btn.changeState(ButtonStates.down);
  147. }
  148.  
  149. function buttonsMouseLbtnUp(x, y) {
  150.     if (cur_btn) {
  151.         cur_btn.changeState(ButtonStates.hover);
  152.         btn_down == cur_btn && cur_btn.onClick(x, y);
  153.     }
  154.  
  155.     btn_down = false;
  156. }
  157.  
  158. function buttonsMouseLeave() {
  159.     cur_btn && cur_btn.changeState(ButtonStates.normal);
  160. }
  161.  
  162.  
  163.  
  164.  
  165.  
  166. // ---------- TEXT BUTTON OBJECT ----------
  167. // ----- Code by tedGo, based on a sample by T.P. Wang
  168.  
  169. function TextButton(text, func, x, y, w, h, size_options, options, colours, tiptext, funcOption) {
  170.     this.text = text;
  171.  
  172.     this.func = func;
  173.  
  174.     this.x = x;
  175.     this.y = y;
  176.     this.w = w;
  177.     this.h = h;
  178.  
  179.     var tmp_size = ["text_x_margin", "text_y_margin", "func_left_pad", "func_top_pad", "func_right_pad", "func_bottom_pad"];
  180.     for (var l = 0; l < 6; l++) this[tmp_size[l]] = size_options && size_options[tmp_size[l]] ? size_options[tmp_size[l]] : 0;
  181.     this.font_size = size_options && size_options.font_size ? size_options.font_size : 12;
  182.  
  183.     this.left = x + this.func_left_pad;
  184.     this.top = y + this.func_top_pad;
  185.     this.w_ = w - this.func_left_pad - this.func_right_pad;
  186.     this.h_ = h - this.func_top_pad - this.func_bottom_pad;
  187.     this.right = x + w - this.func_right_pad;
  188.     this.bottom = y + h - this.func_bottom_pad;
  189.  
  190.     var as_tmp = Math.min(this.w_, this.h_) / 2;
  191.     this.arc_size = size_options && size_options.arc_size ? Math.min(as_tmp, size_options.arc_size) : Math.min(as_tmp, Math.min(this.w, this.h) / 6);
  192.  
  193.     var tmp_opt = ["btn_style", "font_style", "line_width", "text_align_h", "text_align_v", "text_onclick_shift", "text_shadow", "btn_depth"];
  194.     for (var i = 0; i < 8; i++) this[tmp_opt[i]] = options && options[tmp_opt[i]] ? options[tmp_opt[i]] : 0;
  195.     this.font_name = options && options.font_name ? options.font_name : "";
  196.     this.text_shift = 0;
  197.  
  198.     var tmp_col = ["shadow_colour", "text_normal", "line_normal", "back_normal", "text_hover", "line_hover", "back_hover", "text_down", "line_down", "back_down"];
  199.     for (var j = 0; j < 10; j++) this[tmp_col[j]] = colours && colours[tmp_col[j]] ? colours[tmp_col[j]] : j < 4 ? null : this[tmp_col[j - 3]];
  200.     this.colour_text = this[tmp_col[1]];
  201.     this.colour_line = this[tmp_col[2]];
  202.     this.colour_back = this[tmp_col[3]];
  203.  
  204.     this.tiptext = tiptext ? tiptext : "";
  205.  
  206.     this.funcOption = funcOption;
  207.  
  208.     this.state = ButtonStates.normal;
  209.  
  210.     this.traceMouse = function(x, y) {
  211.         if (this.state == ButtonStates.hide) return false;
  212.  
  213.         var b = this.left < x && x < this.right && this.top < y && y < this.bottom;
  214.  
  215.         if (b) btn_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
  216.         else this.changeState(ButtonStates.normal);
  217.         return b;
  218.     }
  219.  
  220.     this.changeState = function(newstate) {
  221.         newstate != this.state && this.repaint();
  222.         this.state = newstate;
  223.  
  224.         this.text_shift = this.state == ButtonStates.down ? this.text_onclick_shift : 0;
  225.  
  226.         switch (this.state) {
  227.             case ButtonStates.normal:
  228.                 this.colour_text = this.text_normal;
  229.                 this.colour_line = this.line_normal;
  230.                 this.colour_back = this.back_normal;
  231.                 break;
  232.  
  233.             case ButtonStates.hover:
  234.                 this.colour_text = this.text_hover;
  235.                 this.colour_line = this.line_hover;
  236.                 this.colour_back = this.back_hover;
  237.                 break;
  238.  
  239.             case ButtonStates.down:
  240.                 this.colour_text = this.text_down;
  241.                 this.colour_line = this.line_down;
  242.                 this.colour_back = this.back_down;
  243.                 break;
  244.  
  245.             default:
  246.                 this.colour_text = this.colour_line = this.colour_back = null;
  247.         }
  248.     }
  249.  
  250.     this.draw = function(gr) {
  251.         if (this.btn_style == 1) {
  252.             this.colour_back && gr.FillSolidRect(this.left, this.top, this.w_, this.h_, this.colour_back);
  253.             this.btn_depth > 0 && gr.DrawRect(this.left, this.top + Math.ceil(this.btn_depth / 2), this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.btn_depth, 0x1FFFFFFF);
  254.             this.btn_depth > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.btn_depth, 0x3F000000);
  255.             this.colour_line && this.line_width > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
  256.         }
  257.  
  258.         if (this.btn_style == 2) {
  259.             this.colour_back && gr.FillRoundRect(this.left, this.top, this.w_, this.h_, this.arc_size, this.arc_size, this.colour_back);
  260.             this.btn_depth > 0 && gr.DrawRoundRect(this.left, this.top + Math.ceil(this.btn_depth / 2), this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.arc_size, this.arc_size, this.btn_depth, 0x1FFFFFFF);
  261.             this.btn_depth > 0 && gr.DrawRoundRect(this.left, this.top, this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.arc_size, this.arc_size, this.btn_depth, 0x3F000000);
  262.             this.colour_line && this.line_width > 0 && gr.DrawRoundRect(this.left, this.top, this.w_, this.h_, this.arc_size, this.arc_size, this.line_width, this.colour_line);
  263.         }
  264.  
  265.         if (this.btn_style == 3) {
  266.             this.colour_back && gr.FillEllipse(this.left, this.top, this.w_, this.h_, this.colour_back);
  267.             this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top + Math.ceil(this.btn_depth / 2), this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.btn_depth, 0x1FFFFFFF);
  268.             this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.btn_depth, 0x3F000000);
  269.             this.colour_line && this.line_width > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
  270.         }
  271.  
  272.         var txt_h = this.text != "" ? gr.CalcTextHeight(this.text, gdi.Font(this.font_name, this.font_size, this.font_style)) : 0;
  273.         var txt_y = this.text_align_v == 1 ? this.y + Math.floor((this.h - txt_h) / 2) : this.text_align_v == 2 ? this.y + Math.floor(this.h / 3 * 2) : this.y;
  274.         txt_h > 0 && this.text_shadow > 0 && gr.GdiDrawText(this.text, gdi.Font(this.font_name, this.font_size, this.font_style), this.shadow_colour, this.x + this.text_x_margin + Math.abs(this.text_shift) + this.text_shadow, txt_y + this.text_y_margin + this.text_shift + this.text_shadow, this.w, txt_h, this.text_align_h);
  275.         txt_h > 0 && gr.GdiDrawText(this.text, gdi.Font(this.font_name, this.font_size, this.font_style), this.colour_text, this.x + this.text_x_margin + Math.abs(this.text_shift), txt_y + this.text_y_margin + this.text_shift, this.w, txt_h, this.text_align_h);
  276.     }
  277.  
  278.     this.repaint = function() {
  279.         window.RepaintRect(this.x, this.y, this.w, this.h);
  280.     }
  281.  
  282.     this.onClick = function() {
  283.         this.func && this.func();
  284.     }
  285.  
  286.     this.onMouseIn = function() {
  287.         btn_tooltip = window.CreateTooltip();
  288.         btn_tooltip.Text = this.tiptext;
  289.         btn_tooltip.Activate();
  290.     }
  291.  
  292.     this.onMouseOut = function() {
  293.         btn_tooltip.Deactivate();
  294.         btn_tooltip.Dispose();
  295.     }
  296. }
  297.  
  298.  
  299.  
  300.  
  301.  
  302. // ---------- GET ADDITIONAL BUTTON PROPERTIES ----------
  303. // ----- Code by tedGo and super-gau
  304.  
  305. function getButtonProperties(keyIsButton) {
  306.     this.AddButton = function() {
  307.         this.BtnName;
  308.         this.Text;
  309.         this.CmdString;
  310.         this.CmdStyle;
  311.         this.Separator;
  312.         this.Exists = false;
  313.     }
  314.  
  315.     var btnOn = new AddButton();
  316.     btnOn.BtnName = keyIsButton;
  317.     btnOn.Exists = window.GetProperty(btnOn.BtnName, false);
  318.     btnOn.Separator = window.GetProperty(btnOn.BtnName + " X" + repeat("=", 24), repeat("=", 30));
  319.  
  320.     if (btnOn.Exists) {
  321.         btnOn.Text = window.GetProperty(btnOn.BtnName + " name (up to 10 letters)", btnOn.BtnName.toUpperCase());
  322.         btnOn.CmdString = window.GetProperty(btnOn.BtnName + " command string", "");
  323.         btnOn.CmdStyle = window.GetProperty(btnOn.BtnName + " command style", 0);
  324.     } else {
  325.         window.SetProperty(btnOn.BtnName + " name (up to 10 letters)", null);
  326.         window.SetProperty(btnOn.BtnName + " command string", null);
  327.         window.SetProperty(btnOn.BtnName + " command style", null);
  328.     }
  329.  
  330.     return btnOn;
  331. }
  332.  
  333. function AddBtnCmd() {
  334.     var propName = this.funcOption.BtnName + " command style";
  335.     var tmp_style = window.GetProperty(propName);
  336.     var tmp_string = this.funcOption.CmdString;
  337.  
  338.     if (tmp_style == 0) {
  339.         if (fb.RunMainMenuCommand(tmp_string)) window.SetProperty(propName, 1);
  340.         else if (fb.RunContextCommandWithMetadb(tmp_string, fb.GetSelections(), 8)) window.SetProperty(propName, 2);
  341.         else {
  342.             try {
  343.                 eval(tmp_string);
  344.                 window.SetProperty(propName, 3);
  345.             } catch(e) {
  346.                 var tmp_msg = axo.vbBox(1, "The entered command couldn't be assigned!\n\nMaybe you made a typo, the command doesn't exists, it was a JavaScript command and the error is: \"" + e + "\" or it was a context command and you forgot to select at least one file in the playlist before you tried to assign the button command.\n\nPlease hit \"OK\" to correct your \"command string\" or hit \"Cancel\", select at least one file in the playlist and retry to assign the command by a single click on your new button.", "Optional button error", 65585);
  347.                 tmp_msg == 1 && window.ShowProperties();
  348.             }
  349.         }
  350.     } else {
  351.         switch (tmp_style) {
  352.             case 1:
  353.                 fb.RunMainMenuCommand(tmp_string);
  354.                 break;
  355.  
  356.             case 2:
  357.                 fb.RunContextCommandWithMetadb(tmp_string, fb.GetSelections(), 8);
  358.                 break;
  359.  
  360.             case 3:
  361.                 try {
  362.                     eval(tmp_string);
  363.                 } catch(e) {
  364.                     fb.ShowPopupMessage("Optional button: " + e);
  365.                 }
  366.                 break;
  367.         }
  368.     }
  369. }
  370.  
  371.  
  372.  
  373.  
  374.  
  375. // ---------- COMMON BUTTON OPTIONS ----------
  376. // ----- code by tedGo
  377.  
  378. var appPreset = window.GetProperty("Buttons appearance preset", 1);
  379. var depthPreset = window.GetProperty("Buttons depth preset", 0);
  380. var btn1Opt = {}, btn2Opt = {}, btnsCol = {}, btn1Siz = {}, btn2Siz = {}, vknbOpt = {};
  381. var area, bxf, bbw, bbh, by1, by2, padX, padY, rbx = 0;
  382. var p_backcol = RGBA(31, 31, 31, 255);
  383. var btn_panel;
  384.  
  385. function buttonsOptions() {
  386.     btn1Opt.btn_depth = Math.floor(utils.GetSystemMetrics(0) / 1280 * depthPreset);
  387.     btn1Opt.btn_style = appPreset === 4 ? 3 : appPreset;
  388.     btn1Opt.font_name = "Arial Black";
  389.     //btn1Opt.font_style = 0;
  390.     btn1Opt.line_width = 1;
  391.     btn1Opt.text_align_h = 1;
  392.     //btn1Opt.text_align_v = 0;
  393.     //btn1Opt.text_onclick_shift = 0;
  394.     //btn1Opt.text_shadow = 0;
  395.  
  396.     if (btn_panel != 3) {
  397.         btn2Opt.btn_depth = btn1Opt.btn_depth;
  398.         btn2Opt.btn_style = appPreset === 4 ? 1 : appPreset;
  399.         //btn2Opt.font_name = btn1Opt.font_name;
  400.         //btn2Opt.font_style = 0;
  401.         btn2Opt.line_width = btn1Opt.line_width;
  402.         //btn2Opt.text_align_h = 1;
  403.         //btn2Opt.text_align_v = 0;
  404.         //btn2Opt.text_onclick_shift = 0;
  405.         //btn2Opt.text_shadow = 0;
  406.     }
  407.  
  408.     if (btn_panel == 2) {
  409.         vknbOpt.knob_depth = btn1Opt.btn_depth;
  410.         vknbOpt.line_width = btn1Opt.line_width;
  411.     }
  412. }
  413.  
  414. function buttonsColours() {
  415.     btnsCol.back_down = RGBA(255, 255, 255, 8);
  416.     btnsCol.back_hover = RGBA(255, 255, 255, 16);
  417.     //btnsCol.back_normal = RGBA(0, 0, 0, 0);
  418.     //btnsCol.line_down = RGBA(0, 0, 0, 0);
  419.     //btnsCol.line_hover = RGBA(0, 0, 0, 0);
  420.     btnsCol.line_normal = RGBA(0, 0, 0, 255);
  421.     //btnsCol.shadow_colour = RGB(0, 0, 0);
  422.     //btnsCol.text_down = RGB(0, 0, 0);
  423.     //btnsCol.text_hover = RGB(0, 0, 0);
  424.     btnsCol.text_normal = ui_btntxtcol;
  425.  
  426.     if (btn_panel == 2) {
  427.         vknbOpt.back_hover = RGBA(255, 255, 255, 16);
  428.         //vknbOpt.back_normal = RGBA(0, 0, 0, 0);
  429.         //vknbOpt.line_hover = RGBA(0, 0, 0, 0);
  430.         vknbOpt.line_normal = RGBA(0, 0, 0, 255);
  431.     }
  432. }
  433.  
  434. function buttonsSizes() {
  435.     area = ww / 21 * 20;
  436.     padX = ww / 42;
  437.     padY = btn_panel === 3 ? Math.floor(wh / 3) : Math.floor(ww / 105 * 4);
  438.     bxf = area / 16;
  439.     bbw = btn_panel === 3 ? ww - 8 : Math.floor(area / 8);
  440.     bbh = Math.floor(bbw / 25 * 12);
  441.     by1 = Math.floor(area / 80 * 7) + padY;
  442.     by2 = wh - bbh - padY;
  443.     rbx = (ww - area / 8) - (padX * 2);
  444.  
  445.     //btn1Siz.arc_size = 0;
  446.     btn1Siz.font_size = bbw * 7 / 50;
  447.     //btn1Siz.func_bottom_pad = 0;
  448.     btn1Siz.func_left_pad = appPreset === 2 ? bbw / 25 : appPreset === 3 || appPreset === 4 ? bbw / 2 - bbh / 4 : 0;
  449.     btn1Siz.func_right_pad = appPreset === 2 ? bbw / 25 : appPreset === 3 || appPreset === 4 ? bbw / 2 - bbh / 4 : 0;
  450.     btn1Siz.func_top_pad = appPreset === 1 ? Math.floor(bbh / 3 * 2) : appPreset === 2 ? Math.ceil(bbh / 2) : appPreset === 3 || appPreset === 4 ? bbh / 2 : 0;
  451.     //btn1Siz.text_x_margin = 0;
  452.     //btn1Siz.text_y_margin = 0;
  453.  
  454.     if (btn_panel != 3) {
  455.         //btn2Siz.arc_size = 0;
  456.         //btn2Siz.font_size = bbw * 7 / 50;
  457.         //btn2Siz.func_bottom_pad = 0;
  458.         btn2Siz.func_left_pad = appPreset === 2 ? bbw / 25 : appPreset === 3 ? (bbw - bbh) / 2 : 0;
  459.         btn2Siz.func_right_pad = appPreset === 2 ? bbw / 25 : appPreset === 3 ? (bbw - bbh) / 2 : 0;
  460.         //btn2Siz.func_top_pad = 0;
  461.         //btn2Siz.text_x_margin = 0;
  462.         //btn2Siz.text_y_margin = 0;
  463.     }
  464. }
  465.  
  466.  
  467.  
  468.  
  469.  
  470. // ---------- MAIN MENU FUNCTION ----------
  471. // ----- Code by tedGo and super-gau
  472.  
  473. function PopupMenuCreator(parentMenu, name, isActive) {
  474.     var active = (isActive == undefined) ? true : isActive;
  475.     var childMenu = window.CreatePopupMenu();
  476.     active && childMenu.AppendTo(parentMenu, 16, name);
  477.     return childMenu;
  478. }
  479.  
  480. function MainMenuCreator(name, menu, start, count) {
  481.     var menuManager = fb.CreateMainMenuManager();
  482.     menuManager.Init(name);
  483.     menuManager.BuildMenu(menu, start, count);
  484.     return menuManager;
  485. }
  486.  
  487. function getMainMenu(x, y) {
  488.     x = this.left;
  489.     y = this.top;
  490.  
  491.     var a = window.CreatePopupMenu();
  492.     var b = fb.CreateContextMenuManager();
  493.     var idx = 0;
  494.  
  495.     var c = MainMenuCreator("file", PopupMenuCreator(a, "File"), 1, 200);
  496.     var d = MainMenuCreator("edit", PopupMenuCreator(a, "Edit"), 201, 200);
  497.     var e = MainMenuCreator("View", PopupMenuCreator(a, "View"), 401, 200);
  498.     var f = MainMenuCreator("playback", PopupMenuCreator(a, "Playback"), 601, 300);
  499.     var g = MainMenuCreator("library", PopupMenuCreator(a, "Library"), 901, 300);
  500.     var h = MainMenuCreator("help", PopupMenuCreator(a, "Help"), 1201, 100);
  501.    
  502.     b.InitNowPlaying();    
  503.     b.BuildMenu(PopupMenuCreator(a, "Now Playing", fb.IsPlaying), 1301, -1);
  504.  
  505.     a.AppendMenuSeparator();
  506.     a.AppendMenuItem(0, 10001, "Manual");
  507.  
  508.     idx = a.TrackPopupMenu(x, y);
  509.  
  510.     switch (true) {
  511.         case (idx >= 1 && idx < 201):
  512.             c.ExecuteByID(idx - 1);
  513.             break;
  514.  
  515.         case (idx >= 201 && idx < 401):
  516.             d.ExecuteByID(idx - 201);
  517.             break;
  518.  
  519.         case (idx >= 401 && idx < 601):
  520.             e.ExecuteByID(idx - 401);
  521.             break;
  522.  
  523.         case (idx >= 601 && idx < 901):
  524.             f.ExecuteByID(idx - 601);
  525.             break;
  526.  
  527.         case (idx >= 901 && idx < 1201):
  528.             g.ExecuteByID(idx - 901);
  529.             break;
  530.  
  531.         case (idx >= 1201 && idx < 1301):
  532.             h.ExecuteByID(idx - 1201);
  533.             break;
  534.  
  535.         case (idx >= 1301 && idx < 10001):
  536.             b.ExecuteByID(idx - 1301);
  537.             break;
  538.  
  539.         case (idx == 10001):
  540.             axo.shaOpen(configPath + "Manual.pdf");
  541.             break;
  542.     }
  543.  
  544.     a.Dispose();
  545.     b.Dispose();
  546.     c.Dispose();
  547.     d.Dispose();
  548.     e.Dispose();
  549.     f.Dispose();
  550.     g.Dispose();
  551.     h.Dispose();
  552. }
  553.  
  554.  
  555.  
  556.  
  557.  
  558. // ---------- LEFT CONTROL PANEL ----------
  559. // ----- code by tedGo
  560.  
  561. var presetCount = 4;
  562. var b_btns = [];
  563. btn_panel = 1;
  564.  
  565. var a_name = ["", "", "CONSOLE", "", "", "TIME"];
  566. var a_func = [function(){fb.Exit()}, getMainMenu, function(){fb.ShowConsole()}, function(){fb.RunMainMenuCommand("View/Show Status pane")}, function(){fb.RunMainMenuCommand("View/Show Status bar")}, function(){window.SetProperty("Remain Time", t_r ? false : true); TimeOpt()}];
  567.  
  568. var b_name = ["Button 01", "Button 02", "Button 03", "Button 04", "Button 05", "Button 06", "Button 07", "Button 08"];
  569. for (var j_ = 0; j_ < 8; j_++) b_btns.push(getButtonProperties(b_name[j_]));
  570.  
  571. // ----- CREATE BUTTONS -----
  572. buttonsOptions();
  573. buttonsColours();
  574.  
  575. function buttonsRefresh() {
  576.     var qx = [0, rbx, 0, bxf * 3, bxf * 5, rbx];
  577.     for (var i = 0; i < 6; i++) Buttons["a_" + i] = new TextButton(a_name[i], a_func[i], padX + qx[i], i > 1 ? by1 : padY, bbw, bbh, i > 1 ? btn1Siz : btn2Siz, i > 1 ? btn1Opt : btn2Opt, btnsCol);
  578.     for (var j = 0; j < 8; j++) if (b_btns[j].Exists) Buttons["b_" + j] = new TextButton(b_btns[j].Text.toUpperCase(), AddBtnCmd, padX + bxf * (j < 5 ? (j * 2 + 3) : (j * 2 - 3)), j < 5 ? padY : by1, bbw, bbh, btn1Siz, btn1Opt, btnsCol, "", b_btns[j]);
  579. }
  580.  
  581. // ----- CREATE TIMESWITCH OPTION -----
  582. function TimeOpt() {
  583.     t_r = window.GetProperty("Remain Time", false);
  584.     window.NotifyOthers("remTime", t_r);
  585. }
  586.  
  587. TimeOpt();
  588.  
  589. // ----- DRAW -----
  590. function on_paint(gr) {
  591.     !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, p_backcol);
  592.  
  593.     gr.SetInterpolationMode(7);
  594.     gr.SetSmoothingMode(4);
  595.  
  596.     g_signs && gr.DrawImage(g_signs, padX, padY, bbw, bbh, 1206, 396, 150, 72);
  597.     g_signs && gr.DrawImage(g_signs, (ww - area / 8) - padX, padY, bbw, bbh, 1674, 396, 150, 72);
  598.  
  599.     gr.GdiDrawText("PANE --- STATUS --- BAR", gdi.Font(btn1Opt.font_name, btn1Siz.font_size), btnsCol.text_normal, padX + bxf * 3, by1, bbw * 2, Math.ceil(bbh / 3 * 2), 1);
  600.     buttonsDraw(gr);
  601. }
  602.  
  603. // ----- MOUSE ACTIONS -----
  604. function on_mouse_move(x, y) {
  605.     buttonsMouseMove(x, y);
  606. }
  607.  
  608. function on_mouse_lbtn_down(x, y) {
  609.     buttonsMouseLbtnDown(x, y);
  610. }
  611.  
  612. function on_mouse_lbtn_up(x, y) {
  613.     buttonsMouseLbtnUp(x, y);
  614. }
  615.  
  616. function on_mouse_rbtn_up(x, y) {
  617.     var a = window.CreatePopupMenu();
  618.     var b = window.CreatePopupMenu();
  619.     var c = window.CreatePopupMenu();
  620.     var d = window.CreatePopupMenu();
  621.     var idx;
  622.  
  623.     for (var i = 0; i < 8; i++) b.AppendMenuItem(b_btns[i].Exists ? 8 : 0, i + 101, b_btns[i].Text ? b_btns[i].Text : b_name[i]);
  624.     b.AppendMenuSeparator();
  625.     b.AppendMenuItem(0, 109, "Edit buttons");
  626.  
  627.     for (var j = 1; j >= 1 && j <= presetCount; j++) c.AppendMenuItem(0, j + 200, "Preset " + j);
  628.     c.CheckMenuRadioItem(201, 200 + presetCount, appPreset + 200);
  629.  
  630.     var tmp_arr = ["Flat", "Soft", "Medium", "Strong"];
  631.     for (var k = 0; k < 4; k++) d.AppendMenuItem(0, k + 301, tmp_arr[k]);
  632.     d.CheckMenuRadioItem(301, 304, depthPreset + 301);
  633.  
  634.     b.AppendTo(a, 0 | 16, "Optional buttons");
  635.     a.AppendMenuSeparator();
  636.     c.AppendTo(a, 0 | 16, "Button style");
  637.     d.AppendTo(a, 0 | 16, "Button depth");
  638.  
  639.     idx = a.TrackPopupMenu(x, y);
  640.  
  641.     if (idx >= 101 && idx <= 108) {
  642.         window.SetProperty(b_name[idx - 101], b_btns[idx - 101].Exists ? false : true);
  643.         if (b_btns[idx - 101].Exists) window.Reload();
  644.         else {
  645.             var vb_cmmnd = axo.vbBox(0, "Enter your desired command here.", "Button command", "");
  646.             if (vb_cmmnd) {
  647.                 getButtonProperties(b_name[idx - 101]);
  648.                 var vb_name = axo.vbBox(0, "Enter the name for the button here.", "Button name", "");
  649.                 window.SetProperty(b_name[idx - 101] + " command string", vb_cmmnd);
  650.                 vb_name && window.SetProperty(b_name[idx - 101] + " name (up to 10 letters)", vb_name);
  651.                 window.Reload();
  652.             } else window.SetProperty(b_name[idx - 101], false);
  653.         }
  654.     }
  655.  
  656.     if (idx === 109) window.ShowProperties();
  657.  
  658.     if (idx >= 201 && idx <= 200 + presetCount) {
  659.         window.SetProperty("Buttons appearance preset", idx - 200);
  660.         appPreset = window.GetProperty("Buttons appearance preset");
  661.         window.NotifyOthers("ButtonPreset", appPreset);
  662.         buttonsOptions();
  663.         buttonsSizes();
  664.         buttonsRefresh();
  665.         window.Repaint();
  666.     }
  667.  
  668.     if (idx >= 301 && idx <= 304) {
  669.         window.SetProperty("Buttons depth preset", idx - 301);
  670.         depthPreset = window.GetProperty("Buttons depth preset");
  671.         window.NotifyOthers("DepthPreset", depthPreset);
  672.         buttonsOptions();
  673.         buttonsRefresh();
  674.         window.Repaint();
  675.     }
  676.  
  677.     a.Dispose();
  678.     b.Dispose();
  679.     c.Dispose();
  680.     d.Dispose();
  681.  
  682.     return true;
  683. }
  684.  
  685. function on_mouse_leave() {
  686.     buttonsMouseLeave();
  687. }
  688.  
  689. // ----- EVENTS -----
  690. function on_size() {
  691.     ww = window.Width;
  692.     wh = window.Height;
  693.  
  694.     buttonsSizes();
  695.     buttonsRefresh();
  696. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement