Advertisement
Guest User

buttonpanel-test

a guest
Oct 28th, 2016
182
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 "1.1 build20161028"
  4. // @author "tedGo, based on a sample created by T.P. Wang, using partial code by super-gau"
  5. // ==/PREPROCESSOR==
  6.  
  7. // ----- Global Config Script --------------------------------------------------------------------------------------------
  8. // ----- Code by tedGo, using partial code by eXtremeHunter1972
  9.  
  10. var configName = "darkone4mod";
  11. var configPath = fb.ProfilePath + "cui-configs\\" + configName + "\\";
  12. var imgPath = configPath + "images\\";
  13. var g_signs = gdi.Image(imgPath + "Signs.png");
  14.  
  15. var ui_type = window.InstanceType;
  16. var ww = 0; wh = 0;
  17.  
  18. // ----- CREATE RGB(A) -----
  19. function RGBA(r, g, b, a) {
  20.     return ((a << 24) | (r << 16) | (g << 8) | (b));
  21. }
  22.  
  23. function RGB(r, g, b) {
  24.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  25. }
  26.  
  27. // ----- CREATE CUSTOM COLOURS -----
  28. function CustomColour(colour){
  29.     tempc = colour.split("-");
  30.     return ((tempc[3] << 24) | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
  31. }
  32.  
  33. function setAlpha(color, a) {
  34.     return ((color & 0x00ffffff) | (a << 24));
  35. }
  36.  
  37. function toRGB(d){
  38.     var d, r, g, b;
  39.     d = d - 0xff000000; r = d >> 16; g = d >> 8 & 0xFF; b = d & 0xFF;
  40.     return [r,g,b];
  41. }
  42.  
  43. function combColours(c1, c2, f){
  44.     var c1, c2;
  45.     c1 = toRGB(c1); c2 = toRGB(c2);
  46.  
  47.     var r, g, b;
  48.     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]));
  49.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  50. }
  51.  
  52. // ----- GET UI COLOURS -----
  53. function get_colors() {
  54.     ui_backcol = ui_type == 0 ? window.GetColorCUI(3) : window.GetColorDUI(1);
  55.     ui_textcol = ui_type == 0 ? window.GetColorCUI(0) : window.GetColorDUI(0);
  56.     ui_btntxtcol = ui_type == 0 ? window.GetColorCUI(2) : window.GetColorDUI(0);
  57. }
  58.  
  59. get_colors();
  60.  
  61. function on_colors_changed() {
  62.     get_colors();
  63.     window.Repaint();
  64. }
  65.  
  66. // ----- TextButton Object -----------------------------------------------------------------------------------------------
  67. // ----- Code by tedGo, based on a sample by T.P. Wang
  68.  
  69. function TextButton(text, func, x, y, w, h, size_options, options, colours, tiptext, funcOption) {
  70.     this.text = text;
  71.  
  72.     this.func = func;
  73.  
  74.     this.x = x;
  75.     this.y = y;
  76.     this.w = w;
  77.     this.h = h;
  78.  
  79.     var tmp_size = ["text_x_margin", "text_y_margin", "func_left_pad", "func_top_pad", "func_right_pad", "func_bottom_pad"];
  80.     for (var l in tmp_size) this[tmp_size[l]] = size_options && size_options[tmp_size[l]] ? size_options[tmp_size[l]] : 0;
  81.     this.font_size = size_options && size_options.font_size ? size_options.font_size : 12;
  82.  
  83.     this.left = x + this.func_left_pad;
  84.     this.top = y + this.func_top_pad;
  85.     this.w_ = w - this.func_left_pad - this.func_right_pad;
  86.     this.h_ = h - this.func_top_pad - this.func_bottom_pad;
  87.     this.right = x + w - this.func_right_pad;
  88.     this.bottom = y + h - this.func_bottom_pad;
  89.  
  90.     var as_tmp = Math.min(this.w_, this.h_) / 2;
  91.     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);
  92.  
  93.     var tmp_opt = ["btn_style", "font_style", "line_width", "text_align_h", "text_align_v", "text_onclick_shift", "text_shadow", "btn_depth"];
  94.     for (var i in tmp_opt) this[tmp_opt[i]] = options && options[tmp_opt[i]] ? options[tmp_opt[i]] : 0;
  95.     this.font_name = options && options.font_name ? options.font_name : "";
  96.     this.text_shift = 0;
  97.  
  98.     var tmp_col = ["shadow_colour", "text_normal", "line_normal", "back_normal", "text_hover", "line_hover", "back_hover", "text_down", "line_down", "back_down"];
  99.     for (var j = 0; j >= 0 && j <= 3; j++) this[tmp_col[j]] = colours && colours[tmp_col[j]] ? colours[tmp_col[j]] : null;
  100.     for (var k = 4; k >= 4 && k <= 9; k++) this[tmp_col[k]] = colours && colours[tmp_col[k]] ? colours[tmp_col[k]] : this[tmp_col[k - 3]];
  101.     this.colour_text = this[tmp_col[1]];
  102.     this.colour_line = this[tmp_col[2]];
  103.     this.colour_back = this[tmp_col[3]];
  104.  
  105.     this.tiptext = tiptext ? tiptext : "";
  106.  
  107.     this.funcOption = funcOption;
  108.  
  109.     this.state = ButtonStates.normal;
  110.  
  111.     this.traceMouse = function(x, y) {
  112.         if (this.state == ButtonStates.hide) return false;
  113.  
  114.         var b = this.left < x && x < this.right && this.top < y && y < this.bottom;
  115.  
  116.         if (b) btn_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
  117.         else this.changeState(ButtonStates.normal);
  118.         return b;
  119.     }
  120.  
  121.     this.changeState = function(newstate) {
  122.         newstate != this.state && this.repaint();
  123.         this.state = newstate;
  124.  
  125.         this.text_shift = this.state == ButtonStates.down ? this.text_onclick_shift : 0;
  126.  
  127.         switch (this.state) {
  128.             case ButtonStates.normal:
  129.                 this.colour_text = this.text_normal;
  130.                 this.colour_line = this.line_normal;
  131.                 this.colour_back = this.back_normal;
  132.                 break;
  133.  
  134.             case ButtonStates.hover:
  135.                 this.colour_text = this.text_hover;
  136.                 this.colour_line = this.line_hover;
  137.                 this.colour_back = this.back_hover;
  138.                 break;
  139.  
  140.             case ButtonStates.down:
  141.                 this.colour_text = this.text_down;
  142.                 this.colour_line = this.line_down;
  143.                 this.colour_back = this.back_down;
  144.                 break;
  145.  
  146.             default:
  147.                 this.colour_text = this.colour_line = this.colour_back = null;
  148.         }
  149.     }
  150.  
  151.     this.draw = function(gr) {
  152.         if (this.btn_style == 1) {
  153.             this.colour_back && gr.FillSolidRect(this.left, this.top, this.w_, this.h_, this.colour_back);
  154.             this.btn_depth > 0 && gr.DrawRect(this.left, this.top + this.btn_depth, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x1FFFFFFF);
  155.             this.btn_depth > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x3F000000);
  156.             this.colour_line && this.line_width > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
  157.         }
  158.  
  159.         if (this.btn_style == 2) {
  160.             this.colour_back && gr.FillRoundRect(this.left, this.top, this.w_, this.h_, this.arc_size, this.arc_size, this.colour_back);
  161.             this.btn_depth > 0 && gr.DrawRoundRect(this.left, this.top + this.btn_depth, this.w_, this.h_ - this.btn_depth, this.arc_size, this.arc_size, this.btn_depth, 0x1FFFFFFF);
  162.             this.btn_depth > 0 && gr.DrawRoundRect(this.left, this.top, this.w_, this.h_ - this.btn_depth, this.arc_size, this.arc_size, this.btn_depth, 0x3F000000);
  163.             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);
  164.         }
  165.  
  166.         if (this.btn_style == 3) {
  167.             this.colour_back && gr.FillEllipse(this.left, this.top, this.w_, this.h_, this.colour_back);
  168.             this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top + this.btn_depth, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x1FFFFFFF);
  169.             this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x3F000000);
  170.             this.colour_line && this.line_width > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
  171.         }
  172.  
  173.         var txt_h = this.text != "" ? gr.CalcTextHeight(this.text, gdi.Font(this.font_name, this.font_size, this.font_style)) : 0;
  174.         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;
  175.         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);
  176.         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);
  177.     }
  178.  
  179.     this.repaint = function() {
  180.         window.RepaintRect(this.x, this.y, this.w, this.h);
  181.     }
  182.  
  183.     this.onClick = function() {
  184.         this.func && this.func();
  185.     }
  186.  
  187.     this.onMouseIn = function() {
  188.         btn_tooltip = window.CreateTooltip();
  189.         btn_tooltip.Text = this.tiptext;
  190.         btn_tooltip.Activate();
  191.     }
  192.  
  193.     this.onMouseOut = function() {
  194.         btn_tooltip.Deactivate();
  195.         btn_tooltip.Dispose();
  196.     }
  197. }
  198.  
  199. // ----- Global Button Script --------------------------------------------------------------------------------------------
  200. // ----- Code by tedGo, based on a sample by T.P. Wang
  201.  
  202. var ButtonStates = {normal: 0, hover: 1, down: 2, hide: 3};
  203. var Buttons = {};
  204. var btn_down = false;
  205. var cur_btn = null;
  206. var btn_tooltip;
  207.  
  208. function buttonsDraw(gr) {
  209.     for (var i in Buttons) Buttons[i].draw(gr);
  210. }
  211.  
  212. function buttonsTraceMouse(x, y) {
  213.     var btn = null;
  214.     for (var i in Buttons) {
  215.         if (Buttons[i].traceMouse(x, y) && !btn)
  216.             btn = Buttons[i];
  217.     }
  218.     return btn;
  219. }
  220.  
  221. function buttonsMouseMove(x, y) {
  222.     var btn = buttonsTraceMouse(x, y);
  223.  
  224.     if (btn != cur_btn) {
  225.         cur_btn && cur_btn.onMouseOut();
  226.         btn && btn.onMouseIn();
  227.     }
  228.  
  229.     cur_btn = btn;
  230. }
  231.  
  232. function buttonsMouseLbtnDown(x, y) {
  233.     btn_down = true;
  234.     (btn_down = cur_btn) && cur_btn.changeState(ButtonStates.down);
  235. }
  236.  
  237. function buttonsMouseLbtnUp(x, y) {
  238.     if (cur_btn) {
  239.         cur_btn.changeState(ButtonStates.hover);
  240.         btn_down == cur_btn && cur_btn.onClick(x, y);
  241.     }
  242.  
  243.     btn_down = false;
  244. }
  245.  
  246. function buttonsMouseLeave() {
  247.     cur_btn && cur_btn.changeState(ButtonStates.normal);
  248. }
  249.  
  250. // ----- Get Additional Button Properties --------------------------------------------------------------------------------
  251. // ----- Code by super-gau and tedGo
  252.  
  253. function getButtonProperties(keyIsButton, keyTextButton, defaultName, keyCmdStyle, keyCmdString) {
  254.     this.AddButton = function() {
  255.         this.Text;
  256.         this.CmdStyle = 0;
  257.         this.CmdString;
  258.         this.Exists = false;
  259.     }
  260.  
  261.     var btnOn = new AddButton();
  262.     btnOn.Exists = window.GetProperty(keyIsButton, false);
  263.  
  264.     if (btnOn.Exists) {
  265.         btnOn.Text = window.GetProperty(keyTextButton, defaultName);
  266.         btnOn.CmdStyle = window.GetProperty(keyCmdStyle, 0);
  267.         btnOn.CmdString = window.GetProperty(keyCmdString, "");
  268.     } else {
  269.         window.SetProperty(keyTextButton, null);
  270.         window.SetProperty(keyCmdStyle, null);
  271.         window.SetProperty(keyCmdString, null);
  272.     }
  273.  
  274.     return btnOn;
  275. }
  276.  
  277. function AddBtnCmd() {
  278.     var str = this.funcOption.CmdString;
  279.     this.funcOption.CmdStyle == 0 && fb.RunMainMenuCommand(str);
  280.     this.funcOption.CmdStyle == 1 && fb.RunContextCommandWithMetadb(str, fb.GetSelections(), 8);
  281.     if (this.funcOption.CmdStyle == 2) {
  282.         var str_arr = str.split(";");
  283.         for (var i in str_arr) eval("(" + str_arr[i] + ")");
  284.     }
  285. }
  286.  
  287. // ----- Main Menu Function ----------------------------------------------------------------------------------------------
  288. // ----- Code by tedGo and super-gau
  289.  
  290. function getMainMenu(x, y) {
  291.     x = this.left;
  292.     y = this.top;
  293.  
  294.     this.PopupMenuCreator = function(parentMenu, name, isActive) {
  295.         var active = (isActive == undefined) ? true : isActive;
  296.         var childMenu = window.CreatePopupMenu();
  297.         active && childMenu.AppendTo(parentMenu, 16, name);
  298.         return childMenu;
  299.     }
  300.  
  301.     this.MainMenuCreator = function(name, menu, start, count) {
  302.         var menuManager = fb.CreateMainMenuManager();
  303.         menuManager.Init(name);
  304.         menuManager.BuildMenu(menu, start, count);
  305.         return menuManager;
  306.     }
  307.  
  308.     var a = window.CreatePopupMenu();
  309.     var b = fb.CreateContextMenuManager();
  310.  
  311.     var d1 = this.MainMenuCreator("file", this.PopupMenuCreator(a, "File"), 1, 200);
  312.     var d2 = this.MainMenuCreator("edit", this.PopupMenuCreator(a, "Edit"), 201, 200);
  313.     var d3 = this.MainMenuCreator("View", this.PopupMenuCreator(a, "View"), 401, 200);
  314.     var d4 = this.MainMenuCreator("playback", this.PopupMenuCreator(a, "Playback"), 601, 300);
  315.     var d5 = this.MainMenuCreator("library", this.PopupMenuCreator(a, "Library"), 901, 300);
  316.     var d6 = this.MainMenuCreator("help", this.PopupMenuCreator(a, "Help"), 1201, 100);
  317.    
  318.     b.InitNowPlaying();    
  319.     b.BuildMenu(this.PopupMenuCreator(a, "Now Playing", fb.IsPlaying), 1301, -1);
  320.  
  321.     a.AppendMenuSeparator();
  322.     a.AppendMenuItem(0, 10001, "Manual");
  323.  
  324.     ret = 0;
  325.     ret = a.TrackPopupMenu(x, y);
  326.  
  327.     switch (true) {
  328.         case (ret >= 1 && ret < 201):
  329.             d1.ExecuteByID(ret - 1);
  330.             break;
  331.  
  332.         case (ret >= 201 && ret < 401):
  333.             d2.ExecuteByID(ret - 201);
  334.             break;
  335.  
  336.         case (ret >= 401 && ret < 601):
  337.             d3.ExecuteByID(ret - 401);
  338.             break;
  339.  
  340.         case (ret >= 601 && ret < 901):
  341.             d4.ExecuteByID(ret - 601);
  342.             break;
  343.  
  344.         case (ret >= 901 && ret < 1201):
  345.             d5.ExecuteByID(ret - 901);
  346.             break;
  347.  
  348.         case (ret >= 1201 && ret < 1301):
  349.             d6.ExecuteByID(ret - 1201);
  350.             break;
  351.  
  352.         case (ret >= 1301 && ret < 10001):
  353.             b.ExecuteByID(ret - 1301);
  354.             break;
  355.  
  356.         case (ret == 10001):
  357.             var axo = new ActiveXObject("Shell.Application");
  358.             axo.Open(configPath + "Manual.pdf");
  359.             break;
  360.     }
  361.  
  362.     a.Dispose();
  363.     b.Dispose();
  364.     d1.Dispose();
  365.     d2.Dispose();
  366.     d3.Dispose();
  367.     d4.Dispose();
  368.     d5.Dispose();
  369.     d6.Dispose();
  370. }
  371.  
  372. // ----- PANEL -----------------------------------------------------------------------------------------------------------
  373. // -----------------------------------------------------------------------------------------------------------------------
  374. // -----------------------------------------------------------------------------------------------------------------------
  375.  
  376. var appPreset = window.GetProperty("Buttons appearance preset", 1);
  377. var depthPreset = window.GetProperty("Buttons depth preset", 0);
  378. var btn1Opt = {}, btn2Opt = {}, btnsCol = {}, btn1Siz = {}, btn2Siz = {};
  379. var presetCount;
  380. var b_btns = [];
  381.  
  382. var a_name = ["", "", "CONSOLE", "", "", "TIME"];
  383. var a_func = [function(){fb.Exit()}, getMainMenu, function(){fb.ShowConsole()}, function(){fb.RunMainMenuCommand("Show Status pane")}, function(){fb.RunMainMenuCommand("Show Status bar")}, function(){window.SetProperty("Remain Time", t_r ? false : true); TimeOpt()}];
  384. var b_name = ["Button 01", "Button 02", "Button 03", "Button 04", "Button 05", "Button 06", "Button 07", "Button 08"];
  385.  
  386. for (var j_ in b_name) b_btns.push(getButtonProperties(b_name[j_], b_name[j_] + " name (up to 10 letters)", b_name[j_].toUpperCase(), b_name[j_] + " command (0=main, 1=context, 2=func)", b_name[j_] + " command string"));
  387. for (var k_ in b_name) window.GetProperty(b_name[k_] + " X========================", "=========================");
  388.  
  389. var p_backcol = RGBA(31, 31, 31, 255);
  390. var bxf, bby, bbw, bbh, rbx = 0;
  391. presetCount = 3;
  392.  
  393. // ----- CREATE BUTTONS -----
  394. function buttonsOptions() {
  395.     btn1Opt.btn_style = appPreset;
  396.     btn2Opt.btn_style = appPreset == 1 || appPreset == 3 ? 1 : appPreset;
  397.     btn1Opt.font_name = "Arial Black";
  398.     btn1Opt.line_width = btn2Opt.line_width = btn1Opt.text_align_h = 1;
  399.     btn1Opt.btn_depth = btn2Opt.btn_depth = Math.floor(utils.GetSystemMetrics(0) / 1280 * depthPreset);
  400. }
  401.  
  402. function buttonsColours() {
  403.     btnsCol.text_normal = ui_btntxtcol;
  404.     btnsCol.line_normal = RGBA(0, 0, 0, 255);
  405.     btnsCol.back_hover = RGBA(255, 255, 255, 16);
  406.     btnsCol.back_down = RGBA(255, 255, 255, 8);
  407. }
  408.  
  409. function buttonsSizes() {
  410.     bxf = ww / 16;
  411.     bby = Math.floor(ww / 80 * 7) - 1;
  412.     bbw = Math.floor(ww / 8);
  413.     bbh = Math.floor(bbw / 25 * 12);
  414.     rbx = ww - ww / 8 - 1;
  415.  
  416.     btn1Siz.font_size = ww * 7 / 400;
  417.  
  418.     if (appPreset == 1) {
  419.         btn1Siz.func_top_pad = Math.ceil(bbh / 3 * 2);
  420.         btn1Siz.func_left_pad = btn2Siz.func_left_pad = btn1Siz.func_right_pad = btn2Siz.func_right_pad = 0;
  421.     } else if (appPreset == 2) {
  422.         btn1Siz.func_top_pad = Math.ceil(bbh / 2);
  423.         btn1Siz.func_left_pad = btn2Siz.func_left_pad = btn1Siz.func_right_pad = btn2Siz.func_right_pad = ww / 200;
  424.     } else if (appPreset == 3) {
  425.         btn1Siz.func_top_pad = bbh / 2;
  426.         btn1Siz.func_left_pad = btn1Siz.func_right_pad = bbw / 2 - bbh / 4;
  427.         btn2Siz.func_left_pad = btn2Siz.func_right_pad = 0;
  428.     } else btn1Siz.func_left_pad = btn2Siz.func_left_pad = btn1Siz.func_right_pad = btn2Siz.func_right_pad = btn1Siz.func_top_pad = 0;
  429. }
  430.  
  431. function buttonsRefresh() {
  432.     var qx = [0, rbx, 0, bxf * 3, bxf * 5, rbx];
  433.     for (var i = 0; i >= 0 && i <= 5; i++) Buttons["a_" + i] = new TextButton(a_name[i], a_func[i], qx[i], i > 1 ? bby : 0, bbw, bbh, i > 1 ? btn1Siz : btn2Siz, i > 1 ? btn1Opt : btn2Opt, btnsCol);
  434.     for (var j = 0; j >= 0 && j <= 7; j++) if (b_btns[j].Exists) Buttons["b_" + j] = new TextButton(b_btns[j].Text.toUpperCase(), AddBtnCmd, bxf * (j < 5 ? (j * 2 + 3) : (j * 2 - 3)), j < 5 ? 0 : bby, bbw, bbh, btn1Siz, btn1Opt, btnsCol, "", b_btns[j]);
  435. }
  436.  
  437. buttonsOptions();
  438. buttonsColours();
  439.  
  440. // ----- CREATE TIMESWITCH OPTION -----
  441. function TimeOpt() {
  442.     t_r = window.GetProperty("Remain Time", false);
  443.     window.NotifyOthers("remTime", t_r);
  444. }
  445.  
  446. TimeOpt();
  447.  
  448. // ----- DRAW -----
  449. function on_paint(gr) {
  450.     !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, p_backcol);
  451.  
  452.     gr.SetInterpolationMode(7);
  453.     gr.SetSmoothingMode(4);
  454.  
  455.     g_signs && gr.DrawImage(g_signs, 0, 0, bbw, bbh, 1206, 396, 150, 72);
  456.     g_signs && gr.DrawImage(g_signs, ww - ww / 8 - 1, 0, bbw, bbh, 1674, 396, 150, 72);
  457.  
  458.     gr.GdiDrawText("PANE --- STATUS --- BAR", gdi.Font(btn1Opt.font_name, btn1Siz.font_size), btnsCol.text_normal, bxf * 3, bby, bbw * 2, Math.ceil(bbh / 3 * 2), 1);
  459.     buttonsDraw(gr);
  460. }
  461.  
  462. // ----- MOUSE ACTIONS -----
  463. function on_mouse_move(x, y) {
  464.     buttonsMouseMove(x, y);
  465. }
  466.  
  467. function on_mouse_lbtn_down(x, y) {
  468.     buttonsMouseLbtnDown(x, y);
  469. }
  470.  
  471. function on_mouse_lbtn_up(x, y) {
  472.     buttonsMouseLbtnUp(x, y);
  473. }
  474.  
  475. function on_mouse_rbtn_up(x, y) {
  476.     var a = window.CreatePopupMenu();
  477.     var b = window.CreatePopupMenu();
  478.     var c = window.CreatePopupMenu();
  479.     var d = window.CreatePopupMenu();
  480.     var idx;
  481.  
  482.     for (var i = 0; i < b_name.length; i++) b.AppendMenuItem(b_btns[i].Exists ? 8 : 0, i + 101, b_btns[i].Text ? b_btns[i].Text : b_name[i]);
  483.     for (var j = 1; j >= 1 && j <= presetCount; j++) c.AppendMenuItem(0, j + 200, "Preset " + j);
  484.     c.CheckMenuRadioItem(201, 200 + presetCount, appPreset + 200);
  485.     var tmp_arr = ["Flat", "Soft", "Medium", "Strong"];
  486.     for (var k = 0; k >= 0 && k <= 3; k++) d.AppendMenuItem(0, k + 301, tmp_arr[k]);
  487.     d.CheckMenuRadioItem(301, 304, depthPreset + 301);
  488.  
  489.     b.AppendTo(a, 0 | 16, "Optional buttons");
  490.     a.AppendMenuSeparator();
  491.     c.AppendTo(a, 0 | 16, "Button style");
  492.     d.AppendTo(a, 0 | 16, "Button depth");
  493.  
  494.     idx = a.TrackPopupMenu(x, y);
  495.  
  496.     if (idx >= 101 && idx <= 100 + b_name.length) {
  497.         window.SetProperty(b_name[idx - 101], b_btns[idx - 101].Exists ? false : true);
  498.         if (b_btns[idx - 101].Exists) window.Reload();
  499.         else {
  500.             getButtonProperties(b_name[idx - 101], b_name[idx - 101] + " name (up to 10 letters)", b_name[idx - 101].toUpperCase(), b_name[idx - 101] + " command (0=main, 1=context, 2=func)", b_name[idx - 101] + " command string");
  501.             window.ShowProperties();
  502.         }
  503.     }
  504.  
  505.     if (idx >= 201 && idx <= 200 + presetCount) {
  506.         window.SetProperty("Buttons appearance preset", idx - 200);
  507.         appPreset = window.GetProperty("Buttons appearance preset");
  508.         window.NotifyOthers("ButtonPreset", appPreset);
  509.         buttonsOptions();
  510.         buttonsSizes();
  511.         buttonsRefresh();
  512.         window.Repaint();
  513.     }
  514.  
  515.     if (idx >= 301 && idx <= 304) {
  516.         window.SetProperty("Buttons depth preset", idx - 301);
  517.         depthPreset = window.GetProperty("Buttons depth preset");
  518.         window.NotifyOthers("DepthPreset", depthPreset);
  519.         buttonsOptions();
  520.         buttonsRefresh();
  521.         window.Repaint();
  522.     }
  523.  
  524.     a.Dispose();
  525.     b.Dispose();
  526.     c.Dispose();
  527.     d.Dispose();
  528.  
  529.     return true;
  530. }
  531.  
  532. function on_mouse_leave() {
  533.     buttonsMouseLeave();
  534. }
  535.  
  536. // ----- EVENTS -----
  537. function on_size() {
  538.     ww = window.Width;
  539.     wh = window.Height;
  540.  
  541.     buttonsSizes();
  542.     buttonsRefresh();
  543. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement