Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "DarkOne4Mod - Control Panel - Left"
- // @version "1.1 build20161028"
- // @author "tedGo, based on a sample created by T.P. Wang, using partial code by super-gau"
- // ==/PREPROCESSOR==
- // ----- Global Config Script --------------------------------------------------------------------------------------------
- // ----- Code by tedGo, using partial code by eXtremeHunter1972
- var configName = "darkone4mod";
- var configPath = fb.ProfilePath + "cui-configs\\" + configName + "\\";
- var imgPath = configPath + "images\\";
- var g_signs = gdi.Image(imgPath + "Signs.png");
- var ui_type = window.InstanceType;
- var ww = 0; wh = 0;
- // ----- CREATE RGB(A) -----
- function RGBA(r, g, b, a) {
- return ((a << 24) | (r << 16) | (g << 8) | (b));
- }
- function RGB(r, g, b) {
- return (0xff000000 | (r << 16) | (g << 8) | (b));
- }
- // ----- CREATE CUSTOM COLOURS -----
- function CustomColour(colour){
- tempc = colour.split("-");
- return ((tempc[3] << 24) | (tempc[0]<<16) | (tempc[1]<<8) | (tempc[2]));
- }
- function setAlpha(color, a) {
- return ((color & 0x00ffffff) | (a << 24));
- }
- function toRGB(d){
- var d, r, g, b;
- d = d - 0xff000000; r = d >> 16; g = d >> 8 & 0xFF; b = d & 0xFF;
- return [r,g,b];
- }
- function combColours(c1, c2, f){
- var c1, c2;
- c1 = toRGB(c1); c2 = toRGB(c2);
- var r, g, b;
- 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]));
- return (0xff000000 | (r << 16) | (g << 8) | (b));
- }
- // ----- GET UI COLOURS -----
- function get_colors() {
- ui_backcol = ui_type == 0 ? window.GetColorCUI(3) : window.GetColorDUI(1);
- ui_textcol = ui_type == 0 ? window.GetColorCUI(0) : window.GetColorDUI(0);
- ui_btntxtcol = ui_type == 0 ? window.GetColorCUI(2) : window.GetColorDUI(0);
- }
- get_colors();
- function on_colors_changed() {
- get_colors();
- window.Repaint();
- }
- // ----- TextButton Object -----------------------------------------------------------------------------------------------
- // ----- Code by tedGo, based on a sample by T.P. Wang
- function TextButton(text, func, x, y, w, h, size_options, options, colours, tiptext, funcOption) {
- this.text = text;
- this.func = func;
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- var tmp_size = ["text_x_margin", "text_y_margin", "func_left_pad", "func_top_pad", "func_right_pad", "func_bottom_pad"];
- for (var l in tmp_size) this[tmp_size[l]] = size_options && size_options[tmp_size[l]] ? size_options[tmp_size[l]] : 0;
- this.font_size = size_options && size_options.font_size ? size_options.font_size : 12;
- this.left = x + this.func_left_pad;
- this.top = y + this.func_top_pad;
- this.w_ = w - this.func_left_pad - this.func_right_pad;
- this.h_ = h - this.func_top_pad - this.func_bottom_pad;
- this.right = x + w - this.func_right_pad;
- this.bottom = y + h - this.func_bottom_pad;
- var as_tmp = Math.min(this.w_, this.h_) / 2;
- 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);
- var tmp_opt = ["btn_style", "font_style", "line_width", "text_align_h", "text_align_v", "text_onclick_shift", "text_shadow", "btn_depth"];
- for (var i in tmp_opt) this[tmp_opt[i]] = options && options[tmp_opt[i]] ? options[tmp_opt[i]] : 0;
- this.font_name = options && options.font_name ? options.font_name : "";
- this.text_shift = 0;
- var tmp_col = ["shadow_colour", "text_normal", "line_normal", "back_normal", "text_hover", "line_hover", "back_hover", "text_down", "line_down", "back_down"];
- for (var j = 0; j >= 0 && j <= 3; j++) this[tmp_col[j]] = colours && colours[tmp_col[j]] ? colours[tmp_col[j]] : null;
- 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]];
- this.colour_text = this[tmp_col[1]];
- this.colour_line = this[tmp_col[2]];
- this.colour_back = this[tmp_col[3]];
- this.tiptext = tiptext ? tiptext : "";
- this.funcOption = funcOption;
- this.state = ButtonStates.normal;
- this.traceMouse = function(x, y) {
- if (this.state == ButtonStates.hide) return false;
- var b = this.left < x && x < this.right && this.top < y && y < this.bottom;
- if (b) btn_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
- else this.changeState(ButtonStates.normal);
- return b;
- }
- this.changeState = function(newstate) {
- newstate != this.state && this.repaint();
- this.state = newstate;
- this.text_shift = this.state == ButtonStates.down ? this.text_onclick_shift : 0;
- switch (this.state) {
- case ButtonStates.normal:
- this.colour_text = this.text_normal;
- this.colour_line = this.line_normal;
- this.colour_back = this.back_normal;
- break;
- case ButtonStates.hover:
- this.colour_text = this.text_hover;
- this.colour_line = this.line_hover;
- this.colour_back = this.back_hover;
- break;
- case ButtonStates.down:
- this.colour_text = this.text_down;
- this.colour_line = this.line_down;
- this.colour_back = this.back_down;
- break;
- default:
- this.colour_text = this.colour_line = this.colour_back = null;
- }
- }
- this.draw = function(gr) {
- if (this.btn_style == 1) {
- this.colour_back && gr.FillSolidRect(this.left, this.top, this.w_, this.h_, this.colour_back);
- this.btn_depth > 0 && gr.DrawRect(this.left, this.top + this.btn_depth, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x1FFFFFFF);
- this.btn_depth > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x3F000000);
- this.colour_line && this.line_width > 0 && gr.DrawRect(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
- }
- if (this.btn_style == 2) {
- this.colour_back && gr.FillRoundRect(this.left, this.top, this.w_, this.h_, this.arc_size, this.arc_size, this.colour_back);
- 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);
- 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);
- 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);
- }
- if (this.btn_style == 3) {
- this.colour_back && gr.FillEllipse(this.left, this.top, this.w_, this.h_, this.colour_back);
- this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top + this.btn_depth, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x1FFFFFFF);
- this.btn_depth > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_ - this.btn_depth, this.btn_depth, 0x3F000000);
- this.colour_line && this.line_width > 0 && gr.DrawEllipse(this.left, this.top, this.w_, this.h_, this.line_width, this.colour_line);
- }
- var txt_h = this.text != "" ? gr.CalcTextHeight(this.text, gdi.Font(this.font_name, this.font_size, this.font_style)) : 0;
- 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;
- 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);
- 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);
- }
- this.repaint = function() {
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- this.onClick = function() {
- this.func && this.func();
- }
- this.onMouseIn = function() {
- btn_tooltip = window.CreateTooltip();
- btn_tooltip.Text = this.tiptext;
- btn_tooltip.Activate();
- }
- this.onMouseOut = function() {
- btn_tooltip.Deactivate();
- btn_tooltip.Dispose();
- }
- }
- // ----- Global Button Script --------------------------------------------------------------------------------------------
- // ----- Code by tedGo, based on a sample by T.P. Wang
- var ButtonStates = {normal: 0, hover: 1, down: 2, hide: 3};
- var Buttons = {};
- var btn_down = false;
- var cur_btn = null;
- var btn_tooltip;
- function buttonsDraw(gr) {
- for (var i in Buttons) Buttons[i].draw(gr);
- }
- function buttonsTraceMouse(x, y) {
- var btn = null;
- for (var i in Buttons) {
- if (Buttons[i].traceMouse(x, y) && !btn)
- btn = Buttons[i];
- }
- return btn;
- }
- function buttonsMouseMove(x, y) {
- var btn = buttonsTraceMouse(x, y);
- if (btn != cur_btn) {
- cur_btn && cur_btn.onMouseOut();
- btn && btn.onMouseIn();
- }
- cur_btn = btn;
- }
- function buttonsMouseLbtnDown(x, y) {
- btn_down = true;
- (btn_down = cur_btn) && cur_btn.changeState(ButtonStates.down);
- }
- function buttonsMouseLbtnUp(x, y) {
- if (cur_btn) {
- cur_btn.changeState(ButtonStates.hover);
- btn_down == cur_btn && cur_btn.onClick(x, y);
- }
- btn_down = false;
- }
- function buttonsMouseLeave() {
- cur_btn && cur_btn.changeState(ButtonStates.normal);
- }
- // ----- Get Additional Button Properties --------------------------------------------------------------------------------
- // ----- Code by super-gau and tedGo
- function getButtonProperties(keyIsButton, keyTextButton, defaultName, keyCmdStyle, keyCmdString) {
- this.AddButton = function() {
- this.Text;
- this.CmdStyle = 0;
- this.CmdString;
- this.Exists = false;
- }
- var btnOn = new AddButton();
- btnOn.Exists = window.GetProperty(keyIsButton, false);
- if (btnOn.Exists) {
- btnOn.Text = window.GetProperty(keyTextButton, defaultName);
- btnOn.CmdStyle = window.GetProperty(keyCmdStyle, 0);
- btnOn.CmdString = window.GetProperty(keyCmdString, "");
- } else {
- window.SetProperty(keyTextButton, null);
- window.SetProperty(keyCmdStyle, null);
- window.SetProperty(keyCmdString, null);
- }
- return btnOn;
- }
- function AddBtnCmd() {
- var str = this.funcOption.CmdString;
- this.funcOption.CmdStyle == 0 && fb.RunMainMenuCommand(str);
- this.funcOption.CmdStyle == 1 && fb.RunContextCommandWithMetadb(str, fb.GetSelections(), 8);
- if (this.funcOption.CmdStyle == 2) {
- var str_arr = str.split(";");
- for (var i in str_arr) eval("(" + str_arr[i] + ")");
- }
- }
- // ----- Main Menu Function ----------------------------------------------------------------------------------------------
- // ----- Code by tedGo and super-gau
- function getMainMenu(x, y) {
- x = this.left;
- y = this.top;
- this.PopupMenuCreator = function(parentMenu, name, isActive) {
- var active = (isActive == undefined) ? true : isActive;
- var childMenu = window.CreatePopupMenu();
- active && childMenu.AppendTo(parentMenu, 16, name);
- return childMenu;
- }
- this.MainMenuCreator = function(name, menu, start, count) {
- var menuManager = fb.CreateMainMenuManager();
- menuManager.Init(name);
- menuManager.BuildMenu(menu, start, count);
- return menuManager;
- }
- var a = window.CreatePopupMenu();
- var b = fb.CreateContextMenuManager();
- var d1 = this.MainMenuCreator("file", this.PopupMenuCreator(a, "File"), 1, 200);
- var d2 = this.MainMenuCreator("edit", this.PopupMenuCreator(a, "Edit"), 201, 200);
- var d3 = this.MainMenuCreator("View", this.PopupMenuCreator(a, "View"), 401, 200);
- var d4 = this.MainMenuCreator("playback", this.PopupMenuCreator(a, "Playback"), 601, 300);
- var d5 = this.MainMenuCreator("library", this.PopupMenuCreator(a, "Library"), 901, 300);
- var d6 = this.MainMenuCreator("help", this.PopupMenuCreator(a, "Help"), 1201, 100);
- b.InitNowPlaying();
- b.BuildMenu(this.PopupMenuCreator(a, "Now Playing", fb.IsPlaying), 1301, -1);
- a.AppendMenuSeparator();
- a.AppendMenuItem(0, 10001, "Manual");
- ret = 0;
- ret = a.TrackPopupMenu(x, y);
- switch (true) {
- case (ret >= 1 && ret < 201):
- d1.ExecuteByID(ret - 1);
- break;
- case (ret >= 201 && ret < 401):
- d2.ExecuteByID(ret - 201);
- break;
- case (ret >= 401 && ret < 601):
- d3.ExecuteByID(ret - 401);
- break;
- case (ret >= 601 && ret < 901):
- d4.ExecuteByID(ret - 601);
- break;
- case (ret >= 901 && ret < 1201):
- d5.ExecuteByID(ret - 901);
- break;
- case (ret >= 1201 && ret < 1301):
- d6.ExecuteByID(ret - 1201);
- break;
- case (ret >= 1301 && ret < 10001):
- b.ExecuteByID(ret - 1301);
- break;
- case (ret == 10001):
- var axo = new ActiveXObject("Shell.Application");
- axo.Open(configPath + "Manual.pdf");
- break;
- }
- a.Dispose();
- b.Dispose();
- d1.Dispose();
- d2.Dispose();
- d3.Dispose();
- d4.Dispose();
- d5.Dispose();
- d6.Dispose();
- }
- // ----- PANEL -----------------------------------------------------------------------------------------------------------
- // -----------------------------------------------------------------------------------------------------------------------
- // -----------------------------------------------------------------------------------------------------------------------
- var appPreset = window.GetProperty("Buttons appearance preset", 1);
- var depthPreset = window.GetProperty("Buttons depth preset", 0);
- var btn1Opt = {}, btn2Opt = {}, btnsCol = {}, btn1Siz = {}, btn2Siz = {};
- var presetCount;
- var b_btns = [];
- var a_name = ["", "", "CONSOLE", "", "", "TIME"];
- 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()}];
- var b_name = ["Button 01", "Button 02", "Button 03", "Button 04", "Button 05", "Button 06", "Button 07", "Button 08"];
- 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"));
- for (var k_ in b_name) window.GetProperty(b_name[k_] + " X========================", "=========================");
- var p_backcol = RGBA(31, 31, 31, 255);
- var bxf, bby, bbw, bbh, rbx = 0;
- presetCount = 3;
- // ----- CREATE BUTTONS -----
- function buttonsOptions() {
- btn1Opt.btn_style = appPreset;
- btn2Opt.btn_style = appPreset == 1 || appPreset == 3 ? 1 : appPreset;
- btn1Opt.font_name = "Arial Black";
- btn1Opt.line_width = btn2Opt.line_width = btn1Opt.text_align_h = 1;
- btn1Opt.btn_depth = btn2Opt.btn_depth = Math.floor(utils.GetSystemMetrics(0) / 1280 * depthPreset);
- }
- function buttonsColours() {
- btnsCol.text_normal = ui_btntxtcol;
- btnsCol.line_normal = RGBA(0, 0, 0, 255);
- btnsCol.back_hover = RGBA(255, 255, 255, 16);
- btnsCol.back_down = RGBA(255, 255, 255, 8);
- }
- function buttonsSizes() {
- bxf = ww / 16;
- bby = Math.floor(ww / 80 * 7) - 1;
- bbw = Math.floor(ww / 8);
- bbh = Math.floor(bbw / 25 * 12);
- rbx = ww - ww / 8 - 1;
- btn1Siz.font_size = ww * 7 / 400;
- if (appPreset == 1) {
- btn1Siz.func_top_pad = Math.ceil(bbh / 3 * 2);
- btn1Siz.func_left_pad = btn2Siz.func_left_pad = btn1Siz.func_right_pad = btn2Siz.func_right_pad = 0;
- } else if (appPreset == 2) {
- btn1Siz.func_top_pad = Math.ceil(bbh / 2);
- btn1Siz.func_left_pad = btn2Siz.func_left_pad = btn1Siz.func_right_pad = btn2Siz.func_right_pad = ww / 200;
- } else if (appPreset == 3) {
- btn1Siz.func_top_pad = bbh / 2;
- btn1Siz.func_left_pad = btn1Siz.func_right_pad = bbw / 2 - bbh / 4;
- btn2Siz.func_left_pad = btn2Siz.func_right_pad = 0;
- } else btn1Siz.func_left_pad = btn2Siz.func_left_pad = btn1Siz.func_right_pad = btn2Siz.func_right_pad = btn1Siz.func_top_pad = 0;
- }
- function buttonsRefresh() {
- var qx = [0, rbx, 0, bxf * 3, bxf * 5, rbx];
- 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);
- 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]);
- }
- buttonsOptions();
- buttonsColours();
- // ----- CREATE TIMESWITCH OPTION -----
- function TimeOpt() {
- t_r = window.GetProperty("Remain Time", false);
- window.NotifyOthers("remTime", t_r);
- }
- TimeOpt();
- // ----- DRAW -----
- function on_paint(gr) {
- !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, p_backcol);
- gr.SetInterpolationMode(7);
- gr.SetSmoothingMode(4);
- g_signs && gr.DrawImage(g_signs, 0, 0, bbw, bbh, 1206, 396, 150, 72);
- g_signs && gr.DrawImage(g_signs, ww - ww / 8 - 1, 0, bbw, bbh, 1674, 396, 150, 72);
- 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);
- buttonsDraw(gr);
- }
- // ----- MOUSE ACTIONS -----
- function on_mouse_move(x, y) {
- buttonsMouseMove(x, y);
- }
- function on_mouse_lbtn_down(x, y) {
- buttonsMouseLbtnDown(x, y);
- }
- function on_mouse_lbtn_up(x, y) {
- buttonsMouseLbtnUp(x, y);
- }
- function on_mouse_rbtn_up(x, y) {
- var a = window.CreatePopupMenu();
- var b = window.CreatePopupMenu();
- var c = window.CreatePopupMenu();
- var d = window.CreatePopupMenu();
- var idx;
- 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]);
- for (var j = 1; j >= 1 && j <= presetCount; j++) c.AppendMenuItem(0, j + 200, "Preset " + j);
- c.CheckMenuRadioItem(201, 200 + presetCount, appPreset + 200);
- var tmp_arr = ["Flat", "Soft", "Medium", "Strong"];
- for (var k = 0; k >= 0 && k <= 3; k++) d.AppendMenuItem(0, k + 301, tmp_arr[k]);
- d.CheckMenuRadioItem(301, 304, depthPreset + 301);
- b.AppendTo(a, 0 | 16, "Optional buttons");
- a.AppendMenuSeparator();
- c.AppendTo(a, 0 | 16, "Button style");
- d.AppendTo(a, 0 | 16, "Button depth");
- idx = a.TrackPopupMenu(x, y);
- if (idx >= 101 && idx <= 100 + b_name.length) {
- window.SetProperty(b_name[idx - 101], b_btns[idx - 101].Exists ? false : true);
- if (b_btns[idx - 101].Exists) window.Reload();
- else {
- 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");
- window.ShowProperties();
- }
- }
- if (idx >= 201 && idx <= 200 + presetCount) {
- window.SetProperty("Buttons appearance preset", idx - 200);
- appPreset = window.GetProperty("Buttons appearance preset");
- window.NotifyOthers("ButtonPreset", appPreset);
- buttonsOptions();
- buttonsSizes();
- buttonsRefresh();
- window.Repaint();
- }
- if (idx >= 301 && idx <= 304) {
- window.SetProperty("Buttons depth preset", idx - 301);
- depthPreset = window.GetProperty("Buttons depth preset");
- window.NotifyOthers("DepthPreset", depthPreset);
- buttonsOptions();
- buttonsRefresh();
- window.Repaint();
- }
- a.Dispose();
- b.Dispose();
- c.Dispose();
- d.Dispose();
- return true;
- }
- function on_mouse_leave() {
- buttonsMouseLeave();
- }
- // ----- EVENTS -----
- function on_size() {
- ww = window.Width;
- wh = window.Height;
- buttonsSizes();
- buttonsRefresh();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement