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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//----------------------------------------------------------------------------------------
//
// customseek.m
//
//----------------------------------------------------------------------------------------
// Use like this :
// #define CUSTOM_SEEK_VAR MyVar
// #include "customseek.m"
//
//
// What you need :
// _MyVarInit(Layer seeksurface, Layer seekghost, Map seekmap);
// _MyVarShutdown();
//
Global Layer _##CUSTOM_SEEK_VAR##Surface;
Global Layer _##CUSTOM_SEEK_VAR##Ghost;
Global Map _##CUSTOM_SEEK_VAR##Map;
Global Int _##CUSTOM_SEEK_VAR##Clicked;
Global Timer _##CUSTOM_SEEK_VAR##Timer;
Global Int _##CUSTOM_SEEK_VAR##CurPos;
Function _##CUSTOM_SEEK_VAR##Init(Layer s, Layer g, Map m);
Function _##CUSTOM_SEEK_VAR##Update(int newpos);
Function _##CUSTOM_SEEK_VAR##UpdateXY(int x, int y);
Function _##CUSTOM_SEEK_VAR##SeekTo(int x, int y);
Function _##CUSTOM_SEEK_VAR##Shutdown();
_##CUSTOM_SEEK_VAR##Init(Layer s, Layer g, Map m) {
_##CUSTOM_SEEK_VAR##Surface = s;
_##CUSTOM_SEEK_VAR##Ghost = g;
_##CUSTOM_SEEK_VAR##Map = m;
_##CUSTOM_SEEK_VAR##Update(0);
_##CUSTOM_SEEK_VAR##Timer = new Timer;
_##CUSTOM_SEEK_VAR##Timer.setDelay(500);
_##CUSTOM_SEEK_VAR##Timer.start();
}
_##CUSTOM_SEEK_VAR##Shutdown() {
delete _##CUSTOM_SEEK_VAR##Timer;
}
_##CUSTOM_SEEK_VAR##Surface.onLeftButtonDown(int x, int y) {
if (getPlayItemLength() <= 0) return;
if (Strleft(getPlayItemString(), 4) == "http") return;
_##CUSTOM_SEEK_VAR##Clicked = 1;
_##CUSTOM_SEEK_VAR##UpdateXY(x, y);
}
_##CUSTOM_SEEK_VAR##Surface.onMouseMove(int x, int y) {
if (_##CUSTOM_SEEK_VAR##Clicked) {
if (getPlayItemLength() == 0) {
_##CUSTOM_SEEK_VAR##Clicked = 0;
return;
}
_##CUSTOM_SEEK_VAR##UpdateXY(x, y);
}
}
_##CUSTOM_SEEK_VAR##Surface.onLeftButtonUp(int x, int y) {
if (!_##CUSTOM_SEEK_VAR##Clicked) return;
_##CUSTOM_SEEK_VAR##Clicked = 0;
_##CUSTOM_SEEK_VAR##SeekTo(x, y);
}
_##CUSTOM_SEEK_VAR##SeekTo(int x, int y) {
int n = _##CUSTOM_SEEK_VAR##Map.getValue(x, y);
seekTo(getPlayItemLength() * (n / 255));
}
_##CUSTOM_SEEK_VAR##UpdateXY(int x, int y) {
int n = _##CUSTOM_SEEK_VAR##Map.getValue(x, y);
Region r = new Region;
r.loadFromMap(_##CUSTOM_SEEK_VAR##Map, n, 1);
r.offset(-_##CUSTOM_SEEK_VAR##Ghost.getLeft(), -_##CUSTOM_SEEK_VAR##Ghost.getTop());
_##CUSTOM_SEEK_VAR##Ghost.setRegion(r);
#ifdef CUSTOM_SEEK_CALLBACK
int n = _##CUSTOM_SEEK_VAR##Map.getValue(x, y);
_##CUSTOM_SEEK_VAR##OnUpdate(r, getPlayItemLength() * (n / 255));
#endif
delete r;
}
_##CUSTOM_SEEK_VAR##Update(int newpos) {
float p;
int l = getPlayItemLength();
if (l == 0) p = 0;
else p = newpos / l * 255;
Region r = new Region;
r.loadFromMap(_##CUSTOM_SEEK_VAR##Map, p, 1);
_##CUSTOM_SEEK_VAR##CurPos = p;
r.offset(-_##CUSTOM_SEEK_VAR##Ghost.getLeft(), -_##CUSTOM_SEEK_VAR##Ghost.getTop());
_##CUSTOM_SEEK_VAR##Ghost.setRegion(r);
#ifdef CUSTOM_SEEK_CALLBACK
_##CUSTOM_SEEK_VAR##OnUpdate(r, newpos);
#endif
delete r;
}
_##CUSTOM_SEEK_VAR##Timer.onTimer() {
if (_##CUSTOM_SEEK_VAR##Clicked) return;
int l = getPlayItemLength();
if (l > 0) {
int p = getPosition() / l * 255;
if (p != _##CUSTOM_SEEK_VAR##CurPos) {
_##CUSTOM_SEEK_VAR##Update(getPosition());
}
} else {
if (_##CUSTOM_SEEK_VAR##CurPos != 0)
_##CUSTOM_SEEK_VAR##Update(0);
_##CUSTOM_SEEK_VAR##CurPos = 0;
}
}
|