1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*---------------------------------------------------
-----------------------------------------------------
Filename: timecontrol.m
Version: 1.0
Type: maki
Date: 29. Jun. 2007 - 00:13
Author: Martin Poehlmann aka Deimos
E-Mail: martin@skinconsortium.com
Internet: www.skinconsortium.com
www.martin.deimos.de.vu
-----------------------------------------------------
---------------------------------------------------*/
#include <lib/std.mi>
#include <lib/config.mi>
#include <lib/com/AutoRepeatButton.m>
Function updateAttrib (int val);
Global ConfigAttribute timeAttrib;
Global text Display;
Global AutoRepeatButton Increase, Decrease;
Global float multiplier;
Global int maxvalue, step;
Global string suffix;
Global boolean myChange;
System.onScriptLoaded ()
{
AutoRepeat_Load();
string param = getParam();
string objects = getToken(param, "|", 0);
group scriptGroup = getScriptGroup();
Display = scriptGroup.findObject(getToken(objects, ";", 0));
Decrease = scriptGroup.findObject(getToken(objects, ";", 1));
Increase = scriptGroup.findObject(getToken(objects, ";", 2));
objects = getToken(param, "|", 1);
timeAttrib = config.getItemByGuid(getToken(objects, ";", 0)).getattribute(getToken(objects, ";", 1));
step = stringToInteger(getToken(param, "|", 2));
maxvalue = stringToInteger(getToken(param, "|", 3));
multiplier = stringToFloat(getToken(param, "|", 4));
suffix = getToken(param, "|", 5);
AutoRepeat_SetInitalDelay(250);
AutoRepeat_SetRepeatDelay(125);
updateAttrib (0);
}
System.onScriptUnloading ()
{
AutoRepeat_Unload();
}
Increase.onLeftClick ()
{
if (!AutoRepeat_ClickType) return;
updateAttrib (step);
}
Decrease.onLeftClick ()
{
if (!AutoRepeat_ClickType) return;
updateAttrib (-step);
}
timeAttrib.onDataChanged ()
{
if (myChange) return;
updateAttrib (0);
}
updateAttrib (int val)
{
float i = stringToInteger(timeAttrib.getData());
i += val;
if (i < 0 || i > maxvalue) return;
myChange = 1;
string s = integerToString(i);
if (timeAttrib) timeAttrib.setData(s);
i *= multiplier;
s = floatToString(i,1);
Display.setText(s + suffix);
myChange = 0;
}
|