Advertisement
Guest User

DarkOne4Mod v2.0 alpha1 - ButtonPanel

a guest
Sep 5th, 2019
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==PREPROCESSOR==
  2. // @name "DarkOne4Mod - Control Panel - Left"
  3. // @version "2.0 build20190905"
  4. // @author "tedGo"
  5. // ==/PREPROCESSOR==
  6.  
  7. // =========================================================================================================
  8. // ----- Global Config Script ------------------------------------------------------------------------------
  9. // =========================================================================================================
  10.  
  11. /*
  12. Config code by tedGo.
  13.  
  14. Many thanks to the countless helpers - like super-gau, Br3tt, eXtremeHunter1972, fbuser, grimes and all the
  15. others - who provided code snippets, samples, examples and hints.
  16. My specials thanks to T.P. Wang, marc2003 and The Qwertiest for their great components!
  17. */
  18.  
  19. var configName = "darkone4mod";
  20. var configPath = fb.ProfilePath + "cui-configs\\" + configName + "\\";
  21. var imgPath = configPath + "images\\";
  22. var g_signs = gdi.Image(imgPath + "Signs.png");
  23.  
  24. var ui_type = window.InstanceType;
  25. var p_backcol = RGBA(31, 31, 31, 255);
  26. var ww = 0; wh = 0;
  27.  
  28. // ----- CREATE RGB(A) -----
  29. function RGBA(r, g, b, a) {
  30.     return ((a << 24) | (r << 16) | (g << 8) | (b));
  31. }
  32.  
  33. function RGB(r, g, b) {
  34.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  35. }
  36.  
  37. // ----- CREATE CUSTOM COLOURS -----
  38. function CustomColour(colour){
  39.     tempc = colour.split("-");
  40.     return ((tempc[3] << 24) | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
  41. }
  42.  
  43. function setAlpha(colour, a) {
  44.     return ((colour & 0x00ffffff) | (a << 24));
  45. }
  46.  
  47. function toRGB(d){
  48.     var d, r, g, b;
  49.     d = d - 0xff000000; r = d >> 16; g = d >> 8 & 0xFF; b = d & 0xFF;
  50.     return [r,g,b];
  51. }
  52.  
  53. function combColours(c1, c2, f){
  54.     var c1, c2;
  55.     c1 = toRGB(c1); c2 = toRGB(c2);
  56.  
  57.     var r, g, b;
  58.     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]));
  59.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  60. }
  61.  
  62. // ----- GET UI COLOURS -----
  63. function get_colours() {
  64.     ui_backcol = ui_type == 0 ? window.GetColourCUI(3) : window.GetColourDUI(1);
  65.     ui_textcol = ui_type == 0 ? window.GetColourCUI(0) : window.GetColourDUI(0);
  66.     ui_btntxtcol = ui_type == 0 ? window.GetColourCUI(2) : window.GetColourDUI(0);
  67. }
  68.  
  69. get_colours();
  70.  
  71. function on_colours_changed() {
  72.     get_colours();
  73.     window.Repaint();
  74. }
  75.  
  76. // ----- HELPERS -----
  77. function repeat(str, num) {
  78.     num = Number(num);
  79.  
  80.     var result = '';
  81.     while (true) {
  82.         if (num & 1) result += str;
  83.         num >>>= 1;
  84.         if (num <= 0) break;
  85.         str += str;
  86.     }
  87.  
  88.         return result;
  89. }
  90.  
  91. function capitalize(str) {
  92.     return str.charAt(0).toUpperCase() + str.slice(1);
  93. }
  94.  
  95. // ----- ACTIVE-X-OBJECTS -----
  96. function actXobj() {
  97.     var fso = new ActiveXObject("Scripting.FileSystemObject");
  98.     var sha = new ActiveXObject("Shell.Application");
  99.     var wsh = new ActiveXObject("WScript.Shell");
  100.  
  101.     this.fsoCreate = function(path1, path2) {
  102.         return fso.FileExists(path1) || fso.FileExists(path2) ? null : fso.CreateTextFile(path1, true);
  103.     }
  104.  
  105.     this.fsoSwitch = function(path1, path2) {
  106.         return fso.FileExists(path1) ? fso.MoveFile(path1, path2) : fso.MoveFile(path2, path1);
  107.     }
  108.  
  109.     this.shaOpen = function(path) {
  110.         return sha.Open(path);
  111.     }
  112.  
  113.     this.wshPopup = function(text, title, idx) {
  114.         return wsh.Popup(text, 0, title, idx);
  115.     }
  116. }
  117.  
  118. var axo = new actXobj();
  119.  
  120. // =========================================================================================================
  121. // ----- Global Button Script ------------------------------------------------------------------------------
  122. // =========================================================================================================
  123.  
  124. var ButtonStates = {normal: 0, hover: 1, down: 2, hide: 3};
  125. var Buttons = {};
  126. var btn_down = false;
  127. var cur_btn = null;
  128. var btn_tooltip;
  129.  
  130. function buttonsDraw(gr) {
  131.     for (var i in Buttons) Buttons[i].draw(gr);
  132. }
  133.  
  134. function buttonsTraceMouse(x, y) {
  135.     var btn = null;
  136.     for (var i in Buttons) {
  137.         if (Buttons[i].traceMouse(x, y) && !btn)
  138.             btn = Buttons[i];
  139.     }
  140.     return btn;
  141. }
  142.  
  143. function buttonsMouseMove(x, y) {
  144.     var btn = buttonsTraceMouse(x, y);
  145.  
  146.     if (btn != cur_btn) {
  147.         cur_btn && cur_btn.onMouseOut();
  148.         btn && btn.onMouseIn();
  149.     }
  150.  
  151.     cur_btn = btn;
  152. }
  153.  
  154. function buttonsMouseLbtnDown(x, y) {
  155.     btn_down = true;
  156.     (btn_down = cur_btn) && cur_btn.changeState(ButtonStates.down);
  157. }
  158.  
  159. function buttonsMouseLbtnUp(x, y) {
  160.     if (cur_btn) {
  161.         cur_btn.changeState(ButtonStates.hover);
  162.         btn_down == cur_btn && cur_btn.onClick(x, y);
  163.     }
  164.  
  165.     btn_down = false;
  166. }
  167.  
  168. function buttonsMouseLeave() {
  169.     cur_btn && cur_btn.changeState(ButtonStates.normal);
  170. }
  171.  
  172. // =========================================================================================================
  173. // ----- TextButton Object ---------------------------------------------------------------------------------
  174. // =========================================================================================================
  175.  
  176. function TextButton(text, func, x, y, w, h, size_options, options, colours, tiptext, funcOption) {
  177.     this.text = text;
  178.     this.func = func;
  179.     this.x = x;
  180.     this.y = y;
  181.     this.w = w;
  182.     this.h = h;
  183.  
  184.     var tmp_size = ["text_x_margin", "text_y_margin", "func_left_pad", "func_top_pad", "func_right_pad", "func_bottom_pad"];
  185.     for (var l = 0; l < 6; l++) this[tmp_size[l]] = size_options && size_options[tmp_size[l]] ? size_options[tmp_size[l]] : 0;
  186.     this.font_size = size_options && size_options.font_size ? size_options.font_size : 12;
  187.  
  188.     this.left = x + this.func_left_pad;
  189.     this.top = y + this.func_top_pad;
  190.     this.w_ = w - this.func_left_pad - this.func_right_pad;
  191.     this.h_ = h - this.func_top_pad - this.func_bottom_pad;
  192.     this.right = x + w - this.func_right_pad;
  193.     this.bottom = y + h - this.func_bottom_pad;
  194.  
  195.     var as_tmp = Math.min(this.w_, this.h_) / 2;
  196.     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);
  197.  
  198.     var tmp_opt = ["btn_style", "font_style", "line_width", "text_align_h", "text_align_v", "text_onclick_shift", "text_shadow", "btn_depth"];
  199.     for (var i = 0; i < 8; i++) this[tmp_opt[i]] = options && options[tmp_opt[i]] ? options[tmp_opt[i]] : 0;
  200.     this.font_name = options && options.font_name ? options.font_name : "";
  201.     this.text_shift = 0;
  202.  
  203.     var tmp_col = ["shadow_colour", "text_normal", "line_normal", "back_normal", "text_hover", "line_hover", "back_hover", "text_down", "line_down", "back_down"];
  204.     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]];
  205.     this.colour_text = this[tmp_col[1]];
  206.     this.colour_line = this[tmp_col[2]];
  207.     this.colour_back = this[tmp_col[3]];
  208.  
  209.     this.tiptext = tiptext ? tiptext : "";
  210.  
  211.     this.funcOption = funcOption;
  212.  
  213.     this.state = ButtonStates.normal;
  214.  
  215.     this.traceMouse = function(x, y) {
  216.         if (this.state == ButtonStates.hide) return false;
  217.  
  218.         var b = this.left < x && x < this.right && this.top < y && y < this.bottom;
  219.  
  220.         if (b) btn_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
  221.         else this.changeState(ButtonStates.normal);
  222.         return b;
  223.     }
  224.  
  225.     this.changeState = function(newstate) {
  226.         newstate != this.state && this.repaint();
  227.         this.state = newstate;
  228.  
  229.         this.text_shift = this.state == ButtonStates.down ? this.text_onclick_shift : 0;
  230.  
  231.         switch (this.state) {
  232.             case ButtonStates.normal:
  233.                 this.colour_text = this.text_normal;
  234.                 this.colour_line = this.line_normal;
  235.                 this.colour_back = this.back_normal;
  236.                 break;
  237.  
  238.             case ButtonStates.hover:
  239.                 this.colour_text = this.text_hover;
  240.                 this.colour_line = this.line_hover;
  241.                 this.colour_back = this.back_hover;
  242.                 break;
  243.  
  244.             case ButtonStates.down:
  245.                 this.colour_text = this.text_down;
  246.                 this.colour_line = this.line_down;
  247.                 this.colour_back = this.back_down;
  248.                 break;
  249.  
  250.             default:
  251.                 this.colour_text = this.colour_line = this.colour_back = null;
  252.         }
  253.     }
  254.  
  255.     this.draw = function(gr) {
  256.         if (this.btn_style == 1) {
  257.             this.colour_back && gr.FillSolidRect(this.left, this.top, this.w_, this.h_, this.colour_back);
  258.             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);
  259.             this.btn_depth > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.btn_depth, 0x3F000000);
  260.             this.colour_line && this.line_width > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
  261.         }
  262.  
  263.         if (this.btn_style == 2) {
  264.             this.colour_back && gr.FillRoundRect(this.left, this.top, this.w_, this.h_, this.arc_size, this.arc_size, this.colour_back);
  265.             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);
  266.             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);
  267.             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);
  268.         }
  269.  
  270.         if (this.btn_style == 3) {
  271.             this.colour_back && gr.FillEllipse(this.left, this.top, this.w_, this.h_, this.colour_back);
  272.             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);
  273.             this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_ - Math.ceil(this.btn_depth / 2), this.btn_depth, 0x3F000000);
  274.             this.colour_line && this.line_width > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
  275.         }
  276.  
  277.         var txt_h = this.text != "" ? gr.CalcTextHeight(this.text, gdi.Font(this.font_name, this.font_size, this.font_style)) : 0;
  278.         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;
  279.         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);
  280.         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);
  281.     }
  282.  
  283.     this.repaint = function() {
  284.         window.RepaintRect(this.x, this.y, this.w, this.h);
  285.     }
  286.  
  287.     this.onClick = function() {
  288.         this.func && this.func();
  289.     }
  290.  
  291.     this.onMouseIn = function() {
  292.         btn_tooltip = window.CreateTooltip();
  293.         btn_tooltip.Text = this.tiptext;
  294.         btn_tooltip.Activate();
  295.     }
  296.  
  297.     this.onMouseOut = function() {
  298.         btn_tooltip.Deactivate();
  299.         btn_tooltip.Dispose();
  300.     }
  301. }
  302.  
  303. // =========================================================================================================
  304. // ----- Get Optional Button Properties --------------------------------------------------------------------
  305. // =========================================================================================================
  306.  
  307. function getButtonProperties(keyIsButton) {
  308.     this.OptButton = function() {
  309.         this.BtnName;
  310.         this.Text;
  311.         this.CmdString;
  312.         this.CmdStyle;
  313.         this.Separator;
  314.         this.Exists = false;
  315.     }
  316.  
  317.     var btnOn = new OptButton();
  318.     btnOn.BtnName = keyIsButton;
  319.     btnOn.Exists = window.GetProperty(btnOn.BtnName, false);
  320.     btnOn.Separator = window.GetProperty(btnOn.BtnName + " X" + repeat("=", 24), repeat("=", 30));
  321.  
  322.     if (btnOn.Exists) {
  323.         btnOn.Text = window.GetProperty(btnOn.BtnName + " name (up to 10 letters)", btnOn.BtnName.toUpperCase());
  324.         btnOn.CmdString = window.GetProperty(btnOn.BtnName + " command string", "");
  325.         btnOn.CmdStyle = window.GetProperty(btnOn.BtnName + " command style", 0);
  326.     } else {
  327.         window.SetProperty(btnOn.BtnName + " name (up to 10 letters)", null);
  328.         window.SetProperty(btnOn.BtnName + " command string", null);
  329.         window.SetProperty(btnOn.BtnName + " command style", null);
  330.     }
  331.  
  332.     return btnOn;
  333. }
  334.  
  335. function OptBtnCmd() {
  336.     var propName = this.funcOption.BtnName + " command style";
  337.     var tmp_style = window.GetProperty(propName);
  338.     var tmp_string = this.funcOption.CmdString;
  339.     var tmp_msg;
  340.  
  341.     if (tmp_style == 0) {
  342.         if (fb.RunMainMenuCommand(tmp_string)) window.SetProperty(propName, 1);
  343.         else if (fb.RunContextCommandWithMetadb(tmp_string, fb.GetSelections())) window.SetProperty(propName, 2);
  344.         else {
  345.             try {
  346.                 eval(tmp_string);
  347.                 window.SetProperty(propName, 3);
  348.             } catch(e) {
  349.                 tmp_msg = axo.wshPopup("The command \"" + tmp_string + "\" doesn't exist!\n\nMaybe you made a typo, it is a context command and you forgot to select at least one file in the playlist before you hit the button or it is a JScript command and the error is:\n\n" + e + "\n\nPlease hit \"OK\" to correct your command string or hit \"Cancel\", select at least one file in the playlist and hit the button again.", "Optional " + this.funcOption.BtnName + " error!", 49);
  350.                 tmp_msg == 1 && window.ShowProperties();
  351.             }
  352.         }
  353.     } else {
  354.         switch (tmp_style) {
  355.             case 1:
  356.                 fb.RunMainMenuCommand(tmp_string);
  357.                 break;
  358.  
  359.             case 2:
  360.                 fb.RunContextCommandWithMetadb(tmp_string, fb.GetSelections());
  361.                 break;
  362.  
  363.             case 3:
  364.                 try {
  365.                     eval(tmp_string);
  366.                 } catch(e) {
  367.                     tmp_msg = axo.wshPopup("The command \"" + tmp_string + "\" is corrupted or obsolete!\n\nJScript error: \"" + e + "\"\n\nPlease hit \"OK\" to correct your command string.", "Optional " + this.funcOption.BtnName + " error!", 48);
  368.                     tmp_msg == 1 && window.ShowProperties();
  369.                 }
  370.                 break;
  371.         }
  372.     }
  373. }
  374.  
  375. // =========================================================================================================
  376. // ----- Common Button Options -----------------------------------------------------------------------------
  377. // =========================================================================================================
  378.  
  379. var appPreset = window.GetProperty("Buttons appearance preset", 1);
  380. var depthPreset = window.GetProperty("Buttons depth preset", 0);
  381. var btn1Opt = {}, btn2Opt = {}, btnsCol = {}, btn1Siz = {}, btn2Siz = {}, vknbOpt = {};
  382. var area, bxf, bbw, bbh, by1, by2, padX, padY, rbx = 0;
  383. var btn_panel;
  384.  
  385. function buttonsOptions() {
  386.     btn1Opt.btn_depth = Math.max(utils.GetSystemMetrics(0) / 1280, 1) * depthPreset;
  387.     btn1Opt.btn_style = appPreset > 2 ? 3 : appPreset;
  388.     btn1Opt.font_name = "Arial Black";
  389.     //btn1Opt.font_style = 0;
  390.     btn1Opt.line_width = Math.max(utils.GetSystemMetrics(0) / 1280, 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 > 3 ? appPreset - 3 : 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 > 2 ? bbw / 2 - bbh / 4 : 0;
  449.     btn1Siz.func_right_pad = btn1Siz.func_left_pad;
  450.     btn1Siz.func_top_pad = appPreset == 1 ? Math.floor(bbh / 3 * 2) : appPreset == 2 ? Math.ceil(bbh / 2) : appPreset > 2 ? 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 || appPreset == 5 ? bbw / 25 : appPreset == 3 ? (bbw - bbh) / 2 : 0;
  459.         btn2Siz.func_right_pad = btn2Siz.func_left_pad;
  460.         //btn2Siz.func_top_pad = 0;
  461.         //btn2Siz.text_x_margin = 0;
  462.         //btn2Siz.text_y_margin = 0;
  463.     }
  464. }
  465.  
  466. // =========================================================================================================
  467. // ----- Main Menu Function --------------------------------------------------------------------------------
  468. // =========================================================================================================
  469.  
  470. function getMainMenu(x, y) {
  471.     x = this.left;
  472.     y = this.top;
  473.  
  474.     var a = {}, b = {}, c = ["file", "edit", "View", "playback", "library", "help"];
  475.  
  476.     a[0] = window.CreatePopupMenu();
  477.     for (var i = 1; i < 7; i++) a[i] = fb.CreateMainMenuManager();
  478.     a[7] = fb.CreateContextMenuManager();
  479.     for (var j = 0; j < 7; j++) b[j] = window.CreatePopupMenu();
  480.  
  481.     for (var k = 0; k < 6; k++) b[k].AppendTo(a[0], 16, capitalize(c[k]));
  482.     for (var l = 1; l < 7; l++) a[l].Init(c[l - 1]);
  483.     for (var m = 1; m < 7; m++) a[m].BuildMenu(b[m - 1], m * 1000);
  484.    
  485.     if (fb.IsPlaying) {
  486.         a[7].InitNowPlaying();
  487.         a[7].BuildMenu(b[6], 7000);
  488.         a[0].AppendMenuSeparator();
  489.         b[6].AppendTo(a[0], 16, "Now Playing");
  490.     }
  491.  
  492.     var idx = a[0].TrackPopupMenu(x, y);
  493.  
  494.     switch (true) {
  495.         case idx == 0:
  496.             break;
  497.  
  498.         case (idx >= 1000 && idx < 8000):
  499.             var d = Math.floor(idx / 1000);
  500.             a[d].ExecuteByID(idx - d * 1000);
  501.             break;
  502.     }
  503.    
  504.     for (var n = 0; n < 8; n++) a[n].Dispose();
  505. }
  506.  
  507. // =========================================================================================================
  508. // ----- Panel: Control Left -------------------------------------------------------------------------------
  509. // =========================================================================================================
  510.  
  511. var presetCount = 5;
  512. var b_btns = [];
  513. btn_panel = 1;
  514.  
  515. var a_name = ["", "", "CONSOLE", "", "", "TIME"];
  516. 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()}];
  517.  
  518. var b_name = ["Button 01", "Button 02", "Button 03", "Button 04", "Button 05", "Button 06", "Button 07", "Button 08"];
  519. for (var j_ = 0; j_ < 8; j_++) b_btns.push(getButtonProperties(b_name[j_]));
  520.  
  521. // ----- CREATE BUTTONS -----
  522. buttonsOptions();
  523. buttonsColours();
  524.  
  525. function buttonsRefresh() {
  526.     var qx = [0, rbx, 0, bxf * 3, bxf * 5, rbx];
  527.     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);
  528.     for (var j = 0; j < 8; j++) if (b_btns[j].Exists) Buttons["b_" + j] = new TextButton(b_btns[j].Text.toUpperCase(), OptBtnCmd, padX + bxf * (j < 5 ? (j * 2 + 3) : (j * 2 - 3)), j < 5 ? padY : by1, bbw, bbh, btn1Siz, btn1Opt, btnsCol, "", b_btns[j]);
  529. }
  530.  
  531. // ----- CREATE BUTTON MENU -----
  532.  
  533. function getButtonMenu(x, y) {
  534.     var a = {}
  535.     for (var i = 0; i < 4; i++) a[i] = window.CreatePopupMenu();
  536.     var idx;
  537.  
  538.     for (var j = 0; j < 8; j++) a[1].AppendMenuItem(b_btns[j].Exists ? 8 : 0, j + 101, b_btns[j].Text ? b_btns[j].Text : b_name[j]);
  539.     a[1].AppendMenuSeparator();
  540.     a[1].AppendMenuItem(0, 109, "Edit buttons");
  541.     a[1].AppendMenuItem(0, 110, "Configure...");
  542.  
  543.     for (var k = 1; k >= 1 && k <= presetCount; k++) a[2].AppendMenuItem(0, k + 200, "Preset " + k);
  544.     a[2].CheckMenuRadioItem(201, 200 + presetCount, appPreset + 200);
  545.  
  546.     var tmp_arr = ["Flat", "Soft", "Medium", "Strong"];
  547.     for (var l = 0; l < 4; l++) a[3].AppendMenuItem(0, l + 301, tmp_arr[l]);
  548.     a[3].CheckMenuRadioItem(301, 304, depthPreset + 301);
  549.  
  550.     a[1].AppendTo(a[0], 0 | 16, "Optional buttons");
  551.     a[0].AppendMenuSeparator();
  552.     a[2].AppendTo(a[0], 0 | 16, "Button style");
  553.     a[3].AppendTo(a[0], 0 | 16, "Button depth");
  554.  
  555.     idx = a[0].TrackPopupMenu(x, y);
  556.  
  557.     switch (true) {
  558.         case (idx >= 101 && idx <= 108):
  559.             window.SetProperty(b_name[idx - 101], b_btns[idx - 101].Exists ? false : true);
  560.             if (b_btns[idx - 101].Exists) {
  561.                 window.Reload();
  562.                 return true;
  563.             } else {
  564.                 try {
  565.                     var ob_cmd = utils.InputBox(window.ID, "Enter your main menu, context menu or JScript command here:", "Button command", "", true);
  566.                     var ob_name = utils.InputBox(window.ID, "Enter the name for the button here\n(up to 10 letters):", "Button name", "");
  567.                     window.SetProperty(b_name[idx - 101] + " command string", ob_cmd);
  568.                     ob_name && window.SetProperty(b_name[idx - 101] + " name (up to 10 letters)", ob_name);
  569.                     window.Reload();
  570.                     return true;
  571.                 } catch (e) {
  572.                     window.SetProperty(b_name[idx - 101], false);
  573.                 }
  574.             }
  575.             break;
  576.  
  577.         case idx == 109:
  578.             window.ShowProperties();
  579.             break;
  580.  
  581.         case idx == 110:
  582.             window.ShowConfigure();
  583.             break;
  584.  
  585.         case (idx >= 201 && idx <= 200 + presetCount):
  586.             window.SetProperty("Buttons appearance preset", idx - 200);
  587.             appPreset = window.GetProperty("Buttons appearance preset");
  588.             window.NotifyOthers("ButtonPreset", appPreset);
  589.             buttonsOptions();
  590.             buttonsSizes();
  591.             buttonsRefresh();
  592.             window.Repaint();
  593.             break;
  594.  
  595.         case (idx >= 301 && idx <= 304):
  596.             window.SetProperty("Buttons depth preset", idx - 301);
  597.             depthPreset = window.GetProperty("Buttons depth preset");
  598.             window.NotifyOthers("DepthPreset", depthPreset);
  599.             buttonsOptions();
  600.             buttonsRefresh();
  601.             window.Repaint();
  602.             break;
  603.     }
  604.  
  605.     for (var m = 0; m < 4; m++) a[m].Dispose();
  606. }
  607.  
  608. // ----- CREATE TIMESWITCH OPTION -----
  609. function TimeOpt() {
  610.     t_r = window.GetProperty("Remain Time", false);
  611.     window.NotifyOthers("remTime", t_r);
  612. }
  613.  
  614. TimeOpt();
  615.  
  616. // ----- DRAW -----
  617. function on_paint(gr) {
  618.     !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, p_backcol);
  619.  
  620.     gr.SetInterpolationMode(7);
  621.     gr.SetSmoothingMode(4);
  622.  
  623.     g_signs && gr.DrawImage(g_signs, padX, padY, bbw, bbh, 1206, 396, 150, 72);
  624.     g_signs && gr.DrawImage(g_signs, (ww - area / 8) - padX, padY, bbw, bbh, 1674, 396, 150, 72);
  625.  
  626.     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);
  627.     buttonsDraw(gr);
  628. }
  629.  
  630. // ----- MOUSE ACTIONS -----
  631. function on_mouse_move(x, y) {
  632.     buttonsMouseMove(x, y);
  633. }
  634.  
  635. function on_mouse_lbtn_down(x, y) {
  636.     buttonsMouseLbtnDown(x, y);
  637. }
  638.  
  639. function on_mouse_lbtn_up(x, y) {
  640.     buttonsMouseLbtnUp(x, y);
  641. }
  642.  
  643. function on_mouse_rbtn_up(x, y) {
  644.     getButtonMenu(x, y);
  645.     return true;
  646. }
  647.  
  648. function on_mouse_leave() {
  649.     buttonsMouseLeave();
  650. }
  651.  
  652. // ----- EVENTS -----
  653. function on_size() {
  654.     ww = window.Width;
  655.     wh = window.Height;
  656.  
  657.     buttonsSizes();
  658.     buttonsRefresh();
  659. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement