Через меню ПКМ:
-выбор цвета фона
-выбор цвета шрифта
-выбор шрифта
-и др.
- Скриншот
- Код: Выделить всё
//----------------------------------------------------------------------------
//--- JScript
//----------------------------------------------------------------------------
//--- --- Preprocessor
// ==PREPROCESSOR==
//
// #### Script Info
// ##
// @name "Play Time Counter"
// @version "2017.04.22"
// @author "TomPro"
//
// ==/PREPROCESSOR==
//--- --- Properties
var CountDown = window.GetProperty("*USER.Direction.Countdown", false);
var Direction = window.GetProperty("*USER.Direction.Show", true);
var BackColor = Number(window.GetProperty("*USER.Background.Color", "0x2F4F4F"));
var FontColor1 = Number(window.GetProperty("*USER.Font.Color", "0xFFFFFF"));
var FontName = window.GetProperty("*USER.Font.Name", "Arial");
//--- --- Check font
if (utils.CheckFont(FontName) == false) {
FontName = "Arial";
window.SetProperty("*USER.Font.Name", FontName);
};
//--- --- Check colors
var FontColor2, DirColorBack, DirColorFront;
function checkColors() {
BackColor = BackColor | 0xFF000000;
FontColor1 = FontColor1 | 0x000000;
var r = 0xFF & (BackColor >> 16);
var g = 0xFF & (BackColor >> 8);
var b = 0xFF & BackColor;
if (((r << 16) | (g << 8) | (b)) < FontColor1) {
r = ((r + 0x30) > 0xFF) ? 0xFF : r + 0x30;
g = ((g + 0x30) > 0xFF) ? 0xFF : g + 0x30;
b = ((b + 0x30) > 0xFF) ? 0xFF : b + 0x30;
} else {
r = ((r - 0x30) < 0x00) ? 0x00 : r - 0x30;
g = ((g - 0x30) < 0x00) ? 0x00 : g - 0x30;
b = ((b - 0x30) < 0x00) ? 0x00 : b - 0x30;
};
FontColor2 = (r << 16) | (g << 8) | (b);
DirColorBack = FontColor2 | 0xFF000000;
DirColorFront = FontColor1 | 0xFF000000;
};
checkColors();
//--- --- Size
var ww, wh, fh, f_min, f_sec;
var hMin, hSec, hDir;
var yMin, ySec, yDir;
var wSep, wStd, wMin, wSec, wDir;
var xStd, xSep1, xMin, xSep2, xSec, xDir;
function on_size() {
ww = window.Width;
wh = window.Height;
xStd = 3;
// Create temporary graphic interface
temp_bmp = gdi.CreateImage(1, 1);
temp_gr = temp_bmp.GetGraphics();
// Get font
var tw, th;
fh = 16;
do {
fh++;
f_min = gdi.Font(FontName, fh, 0);
f_sec = gdi.Font(FontName, Math.round(fh * 0.75), 0);
tw = temp_gr.CalcTextWidth( "0:00:", f_min) + temp_gr.CalcTextWidth("00", f_sec) + 2 * xStd;
th = temp_gr.CalcTextHeight("0:00:", f_min);
};
while (tw < ww && th < wh);
fh--;
f_min = gdi.Font(FontName, fh, 0);
f_sec = gdi.Font(FontName, fh * 0.75, 0);
tw = temp_gr.CalcTextWidth( "0:00:", f_min) + temp_gr.CalcTextWidth("00", f_sec) + 2 * xStd;
th = temp_gr.CalcTextHeight("0:00:", f_min);
// Get heights
hMin = Math.round(th);
hSec = Math.round(th * 0.75);
hDir = Math.round(th * 0.10);
// Get y-positions
yMin = Math.floor((wh - hMin) / 2);
ySec = yMin + Math.round(th * 0.25);
yDir = yMin + hDir;
// Get widths
wSep = temp_gr.CalcTextWidth( ":", f_min);
wStd = temp_gr.CalcTextWidth( "0", f_min);
wMin = temp_gr.CalcTextWidth("00", f_min);
wSec = temp_gr.CalcTextWidth("00", f_sec);
wDir = Math.round(wSec / 2);
// Get x-positions
xStd = Math.round((ww - tw) / 2);
xSep1 = xStd + wStd;
xMin = xSep1 + wSep;
xSep2 = xMin + wMin;
xSec = xSep2 + wSep;
xDir = xSec + wDir;
// Dispose temporary graphic interface
temp_bmp.ReleaseGraphics(temp_gr);
delete temp_bmp;
delete temp_gr;
// Repaint
window.Repaint();
};
//--- --- Painting
function on_paint(gr){
// Background
gr.FillSolidRect( 0, 0, ww, wh, BackColor);
// Count direction
if (Direction == true) {
gr.FillSolidRect( xSec, yDir, wSec, hDir, DirColorBack);
if (CountDown == true) {
gr.FillSolidRect( xDir, yDir, wDir, hDir, DirColorFront);
} else {
gr.FillSolidRect( xSec, yDir, wDir, hDir, DirColorFront);
};
};
// Play time
if (tStd == 0) {
gr.GdiDrawText( tStd, f_min, FontColor2, xStd , yMin, wStd, hMin, 2);
gr.GdiDrawText( ":", f_min, FontColor2, xSep1, yMin, wSep, hMin, 1);
gr.GdiDrawText(tMin1, f_min, FontColor2, xMin , yMin, wMin, hMin, 0);
} else {
gr.GdiDrawText( tStd, f_min, FontColor1, xStd , yMin, wStd, hMin, 2);
gr.GdiDrawText( ":", f_min, FontColor1, xSep1, yMin, wSep, hMin, 1);
gr.GdiDrawText(tMin1, f_min, FontColor1, xMin , yMin, wMin, hMin, 0);
};
gr.GdiDrawText( tMin2, f_min, FontColor1, xMin , yMin, wMin, hMin, 2);
gr.GdiDrawText( ":", f_min, FontColor1, xSep2, yMin, wSep, hMin, 1);
gr.GdiDrawText( tSec, f_sec, FontColor1, xSec , ySec, wSec, hSec, 0);
};
//--- --- Playback
var Time = fb.PlaybackLength;
var tStd = 0;
var tMin1 = 0;
var tMin2 = 0;
var tSec = "00";
function on_playback_stop(reason) {
Time = 0;
tStd = 0;
tMin1 = 0;
tMin2 = 0;
tSec = "00";
// Repaint
window.Repaint();
};
function on_playback_new_track(metadb) {
Time = fb.PlaybackLength;
setTimes();
};
function on_playback_edited(metadb) {
setTimes();
};
function on_playback_seek(time) {
setTimes();
};
function on_playback_time(time) {
setTimes();
};
function setTimes() {
var tx = (CountDown == true) ? Math.abs(Math.round(Time - fb.PlaybackTime)) : Math.abs(Math.round(fb.PlaybackTime));
tStd = Math.floor(tx / (60 * 60));
tx -= tStd * 60 * 60;
tMin2 = Math.floor(tx / 60);
tMin1 = (tMin2 < 10) ? 0 : "";
tSec = tx % 60;
if (tSec < 10) tSec = "0" + tSec;
// Repaint
window.Repaint();
};
setTimes();
//--- --- Sub Menu
function on_mouse_lbtn_down(x, y, mask) {
var _Menu = window.CreatePopupMenu();
var _ColB = window.CreatePopupMenu();
var _ColF = window.CreatePopupMenu();
var _Font = window.CreatePopupMenu();
// Direction
_Menu.AppendMenuItem(0x00, 11, "Show Direction");
_Menu.AppendMenuItem(0x00, 12, "Countdown");
_Menu.CheckMenuItem(11, (Direction == true));
_Menu.CheckMenuItem(12, (CountDown == true));
_Menu.AppendMenuSeparator();
// Colors
var Split = Math.round(PreColorList.length / 6);
var cBackNo = 101;
var cFontNo = 301;
_ColB.AppendTo(_Menu, 0x00, "Background Color");
_ColF.AppendTo(_Menu, 0x00, "Font Color");
var ii;
for (var i in PreColorList) {
ii = Number(i);
// Fill popupmenu
if ((ii != 0) && (ii % Split == 0)) {
// New row
_ColB.AppendMenuItem(0x20, cBackNo + ii, PreColorList[i]);
_ColF.AppendMenuItem(0x20, cFontNo + ii, PreColorList[i]);
} else {
// Fill row
_ColB.AppendMenuItem(0x00, cBackNo + ii, PreColorList[i]);
_ColF.AppendMenuItem(0x00, cFontNo + ii, PreColorList[i]);
};
// Highlight used color
_ColB.CheckMenuItem((cBackNo + ii), ((BackColor & 0xFFFFFF) == (PreColor[PreColorList[i]] & 0xFFFFFF)));
_ColF.CheckMenuItem((cFontNo + ii), ((FontColor1 & 0xFFFFFF) == (PreColor[PreColorList[i]] & 0xFFFFFF)));
};
// Fonts
var Split = Math.round(FontList.length / 2);
var FontNo = 501;
_Font.AppendTo(_Menu, 0x00, "Fonts (\"" + FontName + "\")");
for (var i in FontList) {
ii = Number(i);
// Fill popupmenu
if ((ii != 0) && (ii % Split == 0)) {
// New row
_Font.AppendMenuItem(0x20, FontNo + ii, FontList[i]);
} else {
// Fill row
_Font.AppendMenuItem(0x00, FontNo + ii, FontList[i]);
};
// Highlight used color
_Font.CheckMenuItem((FontNo + ii), (FontName == FontList[i]));
};
// Execute
var ret = _Menu.TrackPopupMenu(x,y);
switch (true) {
// Show direction
case (ret == 11):;
// Toggle countdown flag
Direction = (Direction == true) ? false : true;
// Write hex string to properties
window.SetProperty("*USER.Direction.Show", Direction);
// Repaint
window.Repaint();
break;
// Countdown
case (ret == 12):;
// Toggle countdown flag
CountDown = (CountDown == true) ? false : true;
// Write hex string to properties
window.SetProperty("*USER.Direction.Countdown", CountDown);
// Repaint
window.Repaint();
break;
// Backgroundcolor
case (cBackNo <= ret && ret <= cBackNo + PreColorList.length):;
// Get color as hex string
BackColor = ((PreColor[PreColorList[ret - cBackNo]]) & 0x00FFFFFF).toString(16);
// Pad hex string up to 6 carachters plus leading "0x"
BackColor = "0x000000".substr(0, 8 - BackColor.length) + BackColor;
// Write hex string to properties
window.SetProperty("*USER.Background.Color", BackColor);
// Get color and repaint
BackColor = Number(BackColor);
checkColors();
window.Repaint();
break;
// Fontcolor
case (cFontNo <= ret && ret <= cFontNo + PreColorList.length):;
// Get color as hex string
FontColor1 = ((PreColor[PreColorList[ret - cFontNo]]) & 0x00FFFFFF).toString(16);
// Pad hex string up to 6 carachters plus leading "0x"
FontColor1 = "0x000000".substr(0, 8 - FontColor1.length) + FontColor1;
// Write hex string to properties
window.SetProperty("*USER.Font.Color", FontColor1);
// Get color and repaint
FontColor1 = Number(FontColor1);
checkColors();
window.Repaint();
break;
// Font
case (FontNo <= ret && ret <= FontNo + FontList.length):;
// Get fontname
FontName = FontList[ret - FontNo];
// Write fontname to properties
window.SetProperty("*USER.Font.Name", FontName);
// Resize window
on_size();
break;
// Nothing
default:;
break;
};
_ColB.Dispose();
_ColF.Dispose();
_Font.Dispose();
_Menu.Dispose();
};
//--- --- pre-calculated colors
PreColor = {
AliceBlue : 0xFFF0F8FF,
AntiqueWhite : 0xFFFAEBD7,
Aqua : 0xFF00FFFF,
Aquamarine : 0xFF7FFFD4,
Azure : 0xFFF0FFFF,
Beige : 0xFFF5F5DC,
Bisque : 0xFFFFE4C4,
Black : 0xFF000000,
BlanchedAlmond : 0xFFFFEBCD,
Blue : 0xFF0000FF,
BlueViolet : 0xFF8A2BE2,
Brown : 0xFFA52A2A,
BurlyWood : 0xFFDEB887,
CadetBlue : 0xFF5F9EA0,
Chartreuse : 0xFF7FFF00,
Chocolate : 0xFFD2691E,
Coral : 0xFFFF7F50,
CornflowerBlue : 0xFF6495ED,
Cornsilk : 0xFFFFF8DC,
Crimson : 0xFFDC143C,
Cyan : 0xFF00FFFF,
DarkBlue : 0xFF00008B,
DarkCyan : 0xFF008B8B,
DarkGoldenrod : 0xFFB8860B,
DarkGray : 0xFFA9A9A9,
DarkGreen : 0xFF006400,
DarkKhaki : 0xFFBDB76B,
DarkMagenta : 0xFF8B008B,
DarkOliveGreen : 0xFF556B2F,
DarkOrange : 0xFFFF8C00,
DarkOrchid : 0xFF9932CC,
DarkRed : 0xFF8B0000,
DarkSalmon : 0xFFE9967A,
DarkSeaGreen : 0xFF8FBC8B,
DarkSlateBlue : 0xFF483D8B,
DarkSlateGray : 0xFF2F4F4F,
DarkTurquoise : 0xFF00CED1,
DarkViolet : 0xFF9400D3,
DarkYellow : 0xFFA0A000,
DeepPink : 0xFFFF1493,
DeepSkyBlue : 0xFF00BFFF,
DimGray : 0xFF696969,
DodgerBlue : 0xFF1E90FF,
Firebrick : 0xFFB22222,
FloralWhite : 0xFFFFFAF0,
ForestGreen : 0xFF228B22,
Fuchsia : 0xFFFF00FF,
Gainsboro : 0xFFDCDCDC,
GhostWhite : 0xFFF8F8FF,
Gold : 0xFFFFD700,
Goldenrod : 0xFFDAA520,
Gray : 0xFF808080,
Green : 0xFF008000,
GreenYellow : 0xFFADFF2F,
Honeydew : 0xFFF0FFF0,
HotPink : 0xFFFF69B4,
IndianRed : 0xFFCD5C5C,
Indigo : 0xFF4B0082,
Ivory : 0xFFFFFFF0,
Khaki : 0xFFF0E68C,
Lavender : 0xFFE6E6FA,
LavenderBlush : 0xFFFFF0F5,
LawnGreen : 0xFF7CFC00,
LemonChiffon : 0xFFFFFACD,
LightBlue : 0xFFADD8E6,
LightCoral : 0xFFF08080,
LightCyan : 0xFFE0FFFF,
LightGoldenrodYellow : 0xFFFAFAD2,
LightGray : 0xFFD3D3D3,
LightGreen : 0xFF90EE90,
LightPink : 0xFFFFB6C1,
LightSalmon : 0xFFFFA07A,
LightSeaGreen : 0xFF20B2AA,
LightSkyBlue : 0xFF87CEFA,
LightSlateGray : 0xFF778899,
LightSteelBlue : 0xFFB0C4DE,
LightYellow : 0xFFFFFFE0,
Lime : 0xFF00FF00,
LimeGreen : 0xFF32CD32,
Linen : 0xFFFAF0E6,
Magenta : 0xFFFF00FF,
Maroon : 0xFF800000,
MediumAquamarine : 0xFF66CDAA,
MediumBlue : 0xFF0000CD,
MediumOrchid : 0xFFBA55D3,
MediumPurple : 0xFF9370DB,
MediumSeaGreen : 0xFF3CB371,
MediumSlateBlue : 0xFF7B68EE,
MediumSpringGreen : 0xFF00FA9A,
MediumTurquoise : 0xFF48D1CC,
MediumVioletRed : 0xFFC71585,
MidnightBlue : 0xFF191970,
MintCream : 0xFFF5FFFA,
MistyRose : 0xFFFFE4E1,
Moccasin : 0xFFFFE4B5,
NavajoWhite : 0xFFFFDEAD,
Navy : 0xFF000080,
OldLace : 0xFFFDF5E6,
Olive : 0xFF808000,
OliveDrab : 0xFF6B8E23,
Orange : 0xFFFFA500,
OrangeRed : 0xFFFF4500,
Orchid : 0xFFDA70D6,
PaleGoldenrod : 0xFFEEE8AA,
PaleGreen : 0xFF98FB98,
PaleTurquoise : 0xFFAFEEEE,
PaleVioletRed : 0xFFDB7093,
PapayaWhip : 0xFFFFEFD5,
PeachPuff : 0xFFFFDAB9,
Peru : 0xFFCD853F,
Pink : 0xFFFFC0CB,
Plum : 0xFFDDA0DD,
PowderBlue : 0xFFB0E0E6,
Purple : 0xFF800080,
Red : 0xFFFF0000,
RosyBrown : 0xFFBC8F8F,
RoyalBlue : 0xFF4169E1,
SaddleBrown : 0xFF8B4513,
Salmon : 0xFFFA8072,
SandyBrown : 0xFFF4A460,
SeaGreen : 0xFF2E8B57,
SeaShell : 0xFFFFF5EE,
Sienna : 0xFFA0522D,
Silver : 0xFFC0C0C0,
SkyBlue : 0xFF87CEEB,
SlateBlue : 0xFF6A5ACD,
SlateGray : 0xFF708090,
Snow : 0xFFFFFAFA,
SpringGreen : 0xFF00FF7F,
SteelBlue : 0xFF4682B4,
Tan : 0xFFD2B48C,
Teal : 0xFF008080,
Thistle : 0xFFD8BFD8,
Tomato : 0xFFFF6347,
Turquoise : 0xFF40E0D0,
Violet : 0xFFEE82EE,
Wheat : 0xFFF5DEB3,
White : 0xFFFFFFFF,
WhiteSmoke : 0xFFF5F5F5,
Yellow : 0xFFFFFF00,
YellowGreen : 0xFF9ACD32
};
PreColorList = new Array();
for (var i in PreColor) {
PreColorList.push(i);
};
//--- --- pre-selected fonts
PreFontList = new Array(
"Arial",
"Calibri",
"Cambria",
"Cambria Math",
"Candara",
"Comic Sans MS",
"Consolas",
"Constantia",
"Corbel",
"Courier New",
"Franklin Gothic Medium",
"Gabriola",
"Georgia",
"Impact",
"Lucida Console",
"Lucida Sans Unicode",
"Microsoft Sans Serif",
"Palatino Linotype",
"Script",
"Segoe Print",
"Segoe Script",
"Segoe UI",
"Segoe UI Symbol",
"Symbol",
"Tahoma",
"Times New Roman",
"Trebuchet MS",
"Verdana",
"Webdings",
"Wingdings"
);
FontList = new Array();
for (var i in PreFontList) {
if (utils.CheckFont(PreFontList[i]) == true) FontList.push(PreFontList[i]);
};
//EOF