Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit ef98eda

Browse files
committed
Timer widget
1 parent 0758417 commit ef98eda

File tree

16 files changed

+833
-0
lines changed

16 files changed

+833
-0
lines changed

@Resources/Images/Icons/Timer.png

4.41 KB
Loading

@Resources/Images/Music/stop.png

862 Bytes
Loading

@Resources/Images/Timer/timer.png

1.92 KB
Loading

@Resources/Languages/de.inc

300 Bytes
Binary file not shown.

@Resources/Languages/en.inc

236 Bytes
Binary file not shown.

@Resources/Languages/ru.inc

292 Bytes
Binary file not shown.

@Resources/Languages/ua.inc

314 Bytes
Binary file not shown.

@Resources/Scripts/Timer.inc

2.96 KB
Binary file not shown.

@Resources/Scripts/Timer.lua

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
function start()
2+
local now = SKIN:GetMeasure('TrueNow'):GetValue()
3+
4+
setAndSave('StartTime', now)
5+
6+
local duration = SKIN:GetVariable('VisibleTime', 0)
7+
local endTime = now + duration
8+
9+
setAndSave('EndTime', endTime)
10+
11+
SKIN:Bang('!SetOption', 'Now', 'AverageSize', 10)
12+
13+
update()
14+
return 0
15+
end
16+
17+
function pause()
18+
local now = SKIN:GetMeasure('TrueNow'):GetValue()
19+
20+
setAndSave('PauseTime', now)
21+
22+
SKIN:Bang('!SetOption', 'Now', 'AverageSize', 1)
23+
24+
update()
25+
return 0
26+
end
27+
28+
function continue()
29+
local now = SKIN:GetMeasure('TrueNow'):GetValue()
30+
local pauseTime = SKIN:GetVariable('PauseTime', 0)
31+
local startTime = SKIN:GetVariable('StartTime', 0)
32+
local endTime = SKIN:GetVariable('EndTime', 0)
33+
34+
local newStartTime = now - pauseTime + startTime
35+
setAndSave('StartTime', newStartTime)
36+
37+
local newEndTime = now - pauseTime + endTime
38+
setAndSave('EndTime', newEndTime)
39+
setAndSave('PauseTime', -1)
40+
41+
SKIN:Bang('!SetOption', 'Now', 'AverageSize', 10)
42+
43+
update()
44+
return 0
45+
end
46+
47+
function stop()
48+
SKIN:Bang('PlayStop')
49+
setAndSave('StartTime', -1)
50+
setAndSave('EndTime', -1)
51+
setAndSave('PauseTime', -1)
52+
53+
SKIN:Bang('!Refresh')
54+
return 0
55+
end
56+
57+
function increase(type, value)
58+
if (type == 'h') then value = value * 60 * 60 end
59+
if (type == 'm') then value = value * 60 end
60+
61+
local time = SKIN:GetVariable('VisibleTime')
62+
SKIN:Bang('!SetVariable', 'VisibleTime', math.min(math.max(time + value, 0), 24 * 60 * 60 - 1))
63+
return 0
64+
end
65+
66+
function input(type, value)
67+
local time = SKIN:GetVariable('VisibleTime')
68+
local seconds = time % 60
69+
local minutes = ((time - seconds) / 60) % 60
70+
local hours = (time - seconds - minutes * 60) / (60 * 60)
71+
72+
if (type == 'h') then
73+
time = time + (value - hours) * 60 * 60
74+
end
75+
if (type == 'm') then
76+
time = time + (value - minutes) * 60
77+
end
78+
if (type == 's') then
79+
time = time + (value - seconds)
80+
end
81+
82+
SKIN:Bang('!SetVariable', 'VisibleTime', math.min(math.max(time, 0), 24 * 60 * 60 - 1))
83+
return 0
84+
end
85+
86+
87+
function setAndSave(variable, value)
88+
SKIN:Bang('!WriteKeyValue', 'Variables', variable, value, '#@#Variables/Timer.inc')
89+
SKIN:Bang('!SetVariable', variable, value)
90+
end
91+
92+
function update()
93+
SKIN:Bang('!UpdateMeasureGroup', 'Measures')
94+
SKIN:Bang('!UpdateMeterGroup', 'Meters')
95+
end

@Resources/Sounds/radar.wav

7.62 MB
Binary file not shown.

0 commit comments

Comments
 (0)