This repository has been archived by the owner on Feb 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
alt1overlay.pas
412 lines (356 loc) · 9.35 KB
/
alt1overlay.pas
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
(*
* Alt1 Toolkit Linux
*
* This Source Code Form is subject to the terms of the GNU General Public License v3.0.
*
* Author: dev.nandofw@gmail.com
* Repository: https://github.com/nandofw/Linux-Alt1-Toolkit
*
*
* Based on 'Alt1 Toolkit' by Skyllbert
* Site: https://runeapps.org
*
*)
unit alt1overlay;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
lcltype,liboverlay;
type
{ TOverlay }
TOverlay = class(TForm)
Timer1: TTimer;
Timer2: TTimer;
procedure FormClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormMouseEnter(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Image1MouseEnter(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
public
procedure overLaySetGroup(str:string);
procedure overLayrefreshGroup(str:string);
procedure overLayLine(c,w,x1,y1,x2,y2,time:integer) ;
procedure overLayClearGroup(str:string);
procedure overLayText(str:string;c,s,x1,y,time:integer);
procedure overLayRect(c,x1,y,w,h,time,lw:integer);
procedure overLayContinueGroup(str:string);
procedure overLayFreezeGroup(str:string);
protected
end;
Toverlaypoints = record
x,y : integer;
end;
{ Toverlaydata }
Toverlaydata = class
tipo : integer; //1 = line 2 = text 3 ??
text : string;
color : Integer;
width : integer;
points : array of Toverlaypoints;
time : integer; //time out?????
constructor Create;
destructor Destroy; override;
end;
{ Toverlaygroup }
Toverlaygroup = class{}
name : string; // group name
data : array of Toverlaydata;
frezzed : boolean;
draw : boolean;
constructor Create;
destructor Destroy; override;
procedure cleardata();
procedure timeout(id: integer);
end;
var
Overlay: TOverlay;
activeoverlay : integer;
count,clear:integer;
datagroup : array[0..11] of Toverlaygroup;
newdata:boolean;
useliboverlay:boolean;
implementation
{$R *.lfm}
{ Toverlaygroup }
constructor Toverlaygroup.Create;
begin
self.data := nil;
end;
destructor Toverlaygroup.Destroy;
begin
inherited Destroy;
end;
procedure Toverlaygroup.cleardata();
var
x:integer;
begin
for x:=0 to High(Self.data) do
self.data[x] := nil;
SetLength(self.data,0);
self.data := nil;
end;
procedure Toverlaygroup.timeout(id: integer);
var
x,z:integer;
begin
z:=High(Self.data);
for x:=id to z-1 do
self.data[x] := Self.data[x+1];
if z = 0 then
self.cleardata()
else
SetLength(Self.data,z);
end;
{ Toverlaydata }
constructor Toverlaydata.Create;
begin
end;
destructor Toverlaydata.Destroy;
begin
SetLength(self.points,0);
inherited Destroy;
end;
{ TOverlay }
procedure TOverlay.Timer1Timer(Sender: TObject);
var
x,z: integer;
begin
for x := Low(datagroup) to High(datagroup) do
begin
if (not (datagroup[x].data = nil)) and (not(datagroup[x].frezzed)) then
begin
for z := High(datagroup[x].data) downto Low(datagroup[x].data) do
begin
datagroup[x].data[z].time -= 49;
if datagroup[x].data[z].time <= 0 then
begin
datagroup[x].timeout(z);
newdata:=true;
end;
end;
end;
end;
if newdata then
begin
if useliboverlay then
begin
Timer2.Enabled:=False;
liboverlayclear();
for x := low(datagroup) to High(datagroup) do
begin
if (not (datagroup[x].data = nil)) and ((not(datagroup[x].frezzed)) or (datagroup[x].draw)) then
begin
datagroup[x].draw:= False;
for z := low(datagroup[x].data) to High(datagroup[x].data) do
begin
case datagroup[x].data[z].tipo of
1:
begin
liboverLayLine(datagroup[x].data[z].color,datagroup[x].data[z].points[0].x,datagroup[x].data[z].points[0].y,datagroup[x].data[z].points[1].x,datagroup[x].data[z].points[1].y,datagroup[x].data[z].width);
end;
2:
begin
liboverLayTextOut(datagroup[x].data[z].color,datagroup[x].data[z].points[0].x,datagroup[x].data[z].points[0].y,datagroup[x].data[z].width,datagroup[x].data[z].text);
end;
3:
begin
liboverLayrectangle(datagroup[x].data[z].color,datagroup[x].data[z].points[0].x,datagroup[x].data[z].points[0].y,datagroup[x].data[z].points[1].x,datagroup[x].data[z].points[1].y,datagroup[x].data[z].width);
end;
end
end
end
end ;
{$IFDEF DEBUG} WriteLn('Update overlay');{$ENDIF}
liboverlayupdate();
Timer2.Enabled:=True;
end ;
newdata:=false;
end;
end;
procedure TOverlay.Timer2Timer(Sender: TObject);
begin
liboverlayevent();
end;
procedure TOverlay.FormShow(Sender: TObject);
begin
Parent:= nil;
Visible:=false;
end;
procedure TOverlay.Image1MouseEnter(Sender: TObject);
begin
end;
procedure TOverlay.FormMouseEnter(Sender: TObject);
begin
end;
procedure TOverlay.FormClick(Sender: TObject);
begin
//WriteLn('test')
end;
procedure TOverlay.FormCreate(Sender: TObject);
var
x:integer;
begin
activeoverlay := 0;
count:=0;
useliboverlay:= libinitoverlay(Screen.Width,Screen.Height);
if useliboverlay then
begin
Visible:=false;
Timer2.Enabled:=true;
end else ShowMessage('Error: Cannot start Overlay. Overlay Disabled');
for x := Low(datagroup) to High(datagroup) do
begin
datagroup[x]:= Toverlaygroup.Create;
datagroup[x].frezzed:= false;
end;
end;
procedure TOverlay.FormDestroy(Sender: TObject);
begin
liboverlayfree();
end;
procedure TOverlay.FormPaint(Sender: TObject);
begin
end;
procedure TOverlay.overLaySetGroup(str: string);
var
x: integer;
found : boolean;
begin
//WriteLn('set '+str) ;
found := false;
for x := Low(datagroup) to High(datagroup) do
if datagroup[x].name = str then
begin
activeoverlay := x;
found := true;
end;
if not(found) then
begin
inc(count);
if (count >= 9) then count := 0;
datagroup[count].name:=str;
activeoverlay := count;
end;
end;
procedure TOverlay.overLayrefreshGroup(str: string);
var
x : integer;
begin
for x := Low(datagroup) to High(datagroup) do
begin
if (CompareStr(datagroup[x].name, str) = 0) then
begin
datagroup[x].draw:= true;
newdata:=true;
end
end
end;
procedure TOverlay.overLayLine(c,w,x1,y1,x2,y2,time:integer);
var
x : integer;
begin
//alt1.overLayLine(101101, 2, 10, 10, 100, 100, 1000);
x := High(datagroup[activeoverlay].data)+1;
SetLength(datagroup[activeoverlay].data,x+1);
datagroup[activeoverlay].data[x] := Toverlaydata.Create;
datagroup[activeoverlay].data[x].color:= c;
datagroup[activeoverlay].data[x].tipo:= 1;
datagroup[activeoverlay].data[x].width:=w;
SetLength(datagroup[activeoverlay].data[x].points , 2);
datagroup[activeoverlay].data[x].points[0].x:=x1;
datagroup[activeoverlay].data[x].points[0].y:=y1;
datagroup[activeoverlay].data[x].points[1].x:=x2;
datagroup[activeoverlay].data[x].points[1].y:=y2;
datagroup[activeoverlay].data[x].time:=time;
newdata:=true;
end;
procedure TOverlay.overLayClearGroup(str: string);
var
x : integer;
begin
for x := Low(datagroup) to High(datagroup) do
begin
// WriteLn('cp '+str+' '+datagroup[x].name);
if (CompareStr(datagroup[x].name, str) = 0) then
begin
datagroup[x].cleardata();
end
end ;
Timer1Timer(nil);
end;
// if not(clear = -1 ) then
//begin
//
//clear := -1;
//end;
procedure TOverlay.overLayText(str:string;c,s,x1,y,time:integer);
var
x : integer;
begin
// alt1.overLayText("" + n, a1lib.mixcolor(255, 255, 255), 20, knot.reader.pos.x + x + 6, knot.reader.pos.y + y, 7000);
x := High(datagroup[activeoverlay].data)+1;
SetLength(datagroup[activeoverlay].data,x+1);
datagroup[activeoverlay].data[x] := Toverlaydata.Create;
datagroup[activeoverlay].data[x].text:=str;
datagroup[activeoverlay].data[x].color:= c; //text color
datagroup[activeoverlay].data[x].tipo:= 2; // type text
datagroup[activeoverlay].data[x].width:=s; //text size
SetLength(datagroup[activeoverlay].data[x].points , 1);
datagroup[activeoverlay].data[x].points[0].x:=x1;
datagroup[activeoverlay].data[x].points[0].y:=y;
datagroup[activeoverlay].data[x].time:=time;
newdata:=true;
end;
procedure TOverlay.overLayRect(c,x1,y,w,h,time,lw:integer);
var
x : integer;
begin
// alt1.overLayRect('red', x, y, width, height, 2000, 1);
x := High(datagroup[activeoverlay].data)+1;
SetLength(datagroup[activeoverlay].data,x+1);
datagroup[activeoverlay].data[x] := Toverlaydata.Create;
datagroup[activeoverlay].data[x].color:= c;
datagroup[activeoverlay].data[x].tipo:= 3; //type rect
datagroup[activeoverlay].data[x].width:=lw;
SetLength(datagroup[activeoverlay].data[x].points , 2);
datagroup[activeoverlay].data[x].points[0].x:=x1;
datagroup[activeoverlay].data[x].points[0].y:=y;
datagroup[activeoverlay].data[x].points[1].x:=w; //width
datagroup[activeoverlay].data[x].points[1].y:=h; //heigth
datagroup[activeoverlay].data[x].time:=time;
newdata:=true;
end;
procedure TOverlay.overLayContinueGroup(str: string);
var
x : integer;
begin
for x := Low(datagroup) to High(datagroup) do
begin
if (CompareStr(datagroup[x].name, str) = 0) then
begin
datagroup[x].frezzed:= false;
newdata:=true;
end
end
end;
procedure TOverlay.overLayFreezeGroup(str: string);
var
x : integer;
begin
for x := Low(datagroup) to High(datagroup) do
begin
if (CompareStr(datagroup[x].name, str) = 0) then
begin
datagroup[x].frezzed:= true;
datagroup[x].draw:= False;
newdata:=true;
end
end
end;
end.