/
GLXCore.simba
1033 lines (911 loc) · 29.4 KB
/
GLXCore.simba
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{*
This file contains all functions relating to communication with the GLX/OpenGL plugin.
This file will only contain function for retrieval of information from the plugin such as
but not limited to:
- Models
- Textures
- Font Spacing
- Font Characters
- Text Recognition
- Debugging All Of The Above
*}
{$loadlib GLX}
{$include_once Internals.Simba}
//OffsetOf - PtrUInt(@(CStruct(nil + 1)^.Y)) - 1;
type
GL_DEBUG_MODE = (GL_MODE_NONE, GL_MODE_TEXTURES, GL_MODE_MODELS, GL_MODE_FONTS, GL_MODE_DISPLAY);
type glTexture = record
ID: Integer;
ColourID: Integer;
FullColourID: Integer;
X, Y: Integer;
Bounds: TBox;
end;
type glModel = record
ID: Cardinal;
TID: Integer;
X, Y: Integer;
end;
type glChar = record
TextureID: Cardinal;
Colour: Cardinal;
X, Y: Integer;
Letter: Char;
Shadow: Boolean;
Translate: Array[0..2] of Single;
Bounds: TBox;
end;
type glText = record
Text: String;
Bounds: TBox;
end;
type glTextEx = record
Text: Array Of String;
Areas: Array Of TBox;
Colours: Array Of Integer;
end;
type
glCharArray = array of glChar;
glTextArray = array of glText;
glTextExArray = array of glTextEx;
glModelArray = array of glModel;
glTextureArray = array of glTexture;
Function glTexture.StableBounds: TBox;
Begin
if ((Self.Bounds.X2 < Self.Bounds.X1) or (Self.Bounds.Y2 < Self.Bounds.Y1)) then
begin
swap(Self.Bounds.X1, Self.Bounds.X2);
swap(Self.Bounds.Y1, Self.Bounds.Y2);
end;
result := Self.Bounds;
End;
{*
Returns the width of a specified texture.
Usage Info:
writeln(SomeTexture.Width());
*}
Function glTexture.Width: Integer;
Begin
Result := Self.Bounds.X2 - Self.Bounds.X1;
End;
{*
Returns the height of a specified texture.
Usage Info:
writeln(SomeTexture.Height());
*}
Function glTexture.Height: Integer;
Begin
Result := Self.Bounds.Y2 - Self.Bounds.Y1;
End;
{*
Returns the unsafe-bounding box of two textures.
Usage Info:
writeln(glTextureBounds(UpperLeftTexture, LowerRightTexture));
*}
Function glTextureBounds(var A, B: glTexture): TBox;
Begin
Result := IntToBox(A.Bounds.X1, A.Bounds.Y1, B.Bounds.X2, B.Bounds.Y2);
If (Result.X1 > Result.X2) Then
Begin
Result.X1 := B.Bounds.X1;
Result.X2 := A.Bounds.X2;
End;
If (Result.Y1 > Result.Y2) Then
Begin
Result.Y1 := B.Bounds.Y1;
Result.Y2 := B.Bounds.Y2;
End;
End;
{*
Enabled Debugging of any OpenGL type.
Usage Info:
GL_MODE_NONE = Disable All Debugging on screen. Other parameters have no effect.
GL_MODE_TEXTURES = Debug Textures on screen. X1, Y1, X2, Y2 specifies the clipping
area in which the textures must lie.
GL_MODE_MODELS = Debug Models on screen. X1, Y1, X2, Y2 specifies the clipping
area in which the Models must lie.
GL_MODE_FONTS = Debug Fonts on screen. X1, Y1, X2, Y2 specifies the clipping
area in which the fonts must lie.
GL_MODE_DISPLAY = Debug as well as draw on screen any texture with the ID specified by
TextureID. Other parameters have no effect.
*}
Procedure glDebug(Mode: GL_DEBUG_MODE; TextureID, ColourID, FullColourID: Cardinal = 0; Tolerance, X1, Y1, X2, Y2: Integer = 0);
Begin
GLXDebug(Ord(Mode), TextureID, ColourID, FullColourID, Tolerance, X1, Y1, X2, Y2);
End;
{*
Enabled Debugging of any OpenGL type. A convenience overload.
Usage Info:
Same as glDebug(Mode: GL_DEBUG_MODE; TextureID, ColourID: Cardinal; Tolerance, X1, Y1, X2, Y2: Integer);
but instead takes a TBox instead of X1, Y1, X2, Y2.
*}
Procedure glDebug(Mode: GL_DEBUG_MODE; TextureID, ColourID, FullColourID: Cardinal; Tolerance: Integer; Area: TBox); overload;
Begin
GLXDebug(Ord(Mode), TextureID, ColourID, FullColourID, Tolerance, Area.X1, Area.Y1, Area.X2, Area.Y2);
End;
{*
Returns an array of ALL textures rendered on the screen.
Usage Info:
writeln(glGetTextures);
*}
Function glGetTextures: glTextureArray;
var
Size, I: Cardinal;
Ptr: Pointer;
Begin
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
Result[I] := glTexture(Ptr^);
Ptr.Inc(sizeof(glTexture));
End;
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureID.
Usage Info:
writeln(glGetTextures(1024));
*}
Function glGetTextures(ID: Integer): glTextureArray; overload;
var
Size, I, J: Cardinal;
Ptr: Pointer;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
if (Integer(Ptr^) = ID) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureIDs. Used for finding multiple textures at once.
Usage Info:
1 - glGetTextures(Array_Of_Texture_IDs);
2 - glGetTextures([1024, 2048, 3072, 4096]);
*}
Function glGetTextures(IDs: TIntegerArray): glTextureArray; overload;
var
Size, I, J: Cardinal;
Ptr: Pointer;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
if (IDs.Contains(Integer(Ptr^))) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that are within
the specified area.
Usage Info:
1 - glGetTextures(Box_Containing_Textures_To_Find);
2 - glGetTextures(IntToBox(X1, Y1, X2, Y2));
3 - glGetTextures(InventoryBounds);
4 - etc..
*}
Function glGetTextures(Area: TBox): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area)) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that have the specified
ID and is within the specified area.
Usage Info:
1 - glGetTextures(1024, InventoryBounds);
2 - glGetTextures(2048, IntToBox(X1, Y1, X2, Y2));
3 - etc..
*}
Function glGetTextures(ID: Integer; Area: TBox): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if ((Integer(Ptr^) = ID) and (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area))) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureIDs and is within the specified area. Used for finding multiple textures
at once in a specific area on screen.
Usage Info:
1 - glGetTextures(Array_Of_Texture_IDs, InventoryBounds);
2 - glGetTextures([1024, 2048, 3072, 4096], InventoryBounds);
3 - glGetTextures([1024, 2048, 3072, 4096], IntToBox(X1, Y1, X2, Y2));
4 - etc..
*}
Function glGetTextures(IDs: TIntegerArray; Area: TBox): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if (IDs.Contains(Integer(Ptr^)) and (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area))) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureID and a Similar ColourID within a specified tolerance/threshold.
Tolerance specifies how strict the search will be. The lower, the more accurate.
Usage Info:
1 - glGetTextures(1024, 21442352, 5);
2 - glGetTextures(LobsterID, LobsterColourID, 5);
3 - etc..
*}
Function glGetTextures(ID, ColourID, Tolerance: Integer; FullColourID: Boolean = False): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
ColourIDOffset: Cardinal;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
If (Not FullColourID) Then
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.ColourID)) - 1)
Else
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.FullColourID)) - 1)
For I := 0 To Size - 1 Do
Begin
if ((Integer(Ptr^) = ID) and (SimilarColors(Integer((Ptr + ColourIDOffset)^), ColourID, Tolerance))) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureIDs and a Similar ColourIDs within the specified tolerances/thresholds.
Tolerances specifies how strict the search will be. The lower, the more accurate.
Used for finding multiple textures at once.
Usage Info:
1 - glGetTextures([1, 2], [1_ColourID, 2_ColourID], [1_Tolerance, 2_Tolerance]);
2 - glGetTextures([LobsterID, SharkID], [LobsterColourID, SharkColourID], [LobsterTolerance, SharkTolerance]);
3 - glGetTextures(ArrayOfIDs, ArrayOfColourIDs, ArrayOfTolerances);
4 - etc..
*}
Function glGetTextures(IDs, ColourIDs, Tolerances: TIntegerArray; FullColourID: Boolean = False): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J, K: Cardinal;
ColourIDOffset: Cardinal;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
If (Not FullColourID) Then
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.ColourID)) - 1)
Else
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.FullColourID)) - 1)
For I := 0 To Size - 1 Do
Begin
For J := 0 To High(IDs) Do
If ((IDs[J] = Integer(Ptr^)) and (SimilarColors(Integer((Ptr + ColourIDOffset)^), ColourIDs[J], Tolerances[J]))) then
begin
Result[K] := glTexture(Ptr^);
Inc(K);
Break;
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, K);
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureID, a Similar ColourID within a specified tolerance/threshold and is within
a specified area on screen.
Tolerance specifies how strict the search will be. The lower, the more accurate.
Usage Info:
1 - glGetTextures(1024, 21442352, 5, InventoryBounds);
2 - glGetTextures(LobsterID, LobsterColourID, 5, BankBounds);
3 - etc..
*}
Function glGetTextures(ID, ColourID, Tolerance: Integer; Area: TBox; FullColourID: Boolean = False): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
ColourIDOffset: Cardinal;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.Y)) - 1);
If (Not FullColourID) Then
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.ColourID)) - 1)
Else
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.FullColourID)) - 1)
For I := 0 To Size - 1 Do
Begin
if ((Integer(Ptr^) = ID) and (SimilarColors(Integer((Ptr + ColourIDOffset)^), ColourID, Tolerance)) and (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area))) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
{*
Returns an array of textures rendered on the screen that have the specified
TextureIDs, a Similar ColourIDs within a specified tolerances/thresholds and is within
a specified area.
Tolerance specifies how strict the search will be. The lower, the more accurate.
Used for finding multiple textures within an area.
Usage Info:
1 - glGetTextures([1, 2], [1_ColourID, 2_ColourID], [1_Tolerance, 2_Tolerance], InventoryBounds);
2 - glGetTextures([LobsterID, SharkID], [LobsterColourID, SharkColourID], [LobsterTolerance, SharkTolerance], BankBounds);
3 - glGetTextures(ArrayOfIDs, ArrayOfColourIDs, ArrayOfTolerances, AreaToSearch);
4 - etc..
*}
Function glGetTextures(IDs, ColourIDs, Tolerances: TIntegerArray; Area: TBox; FullColourID: Boolean = False): glTextureArray; overload;
var
Ptr: Pointer;
Size, I, J, K: Cardinal;
XOffset, YOffset: Integer;
ColourIDOffset: Cardinal;
type ptr_glTexture = ^glTexture;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.Y)) - 1);
If (Not FullColourID) Then
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.ColourID)) - 1)
Else
ColourIDOffset := (PtrUInt(@(ptr_glTexture(nil + 1)^.FullColourID)) - 1)
For I := 0 To Size - 1 Do
Begin
For J := 0 To High(IDs) Do
If ((IDs[J] = Integer(Ptr^)) and (SimilarColors(Integer((Ptr + ColourIDOffset)^), ColourIDs[J], Tolerances[J])) and (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area))) then
begin
Result[K] := glTexture(Ptr^);
Inc(K);
Break;
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, K);
End;
{*
Returns an array of ALL Models rendered on screen.
Usage Info:
writeln(glGetModels);
*}
Function glGetModels: glModelArray;
var
Size, I: Cardinal;
Ptr: Pointer;
Begin
Result := [];
Ptr := GLXModels(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
Result[I] := glModel(Ptr^);
Ptr.Inc(sizeof(glModel));
End;
End;
{*
Returns an array of Models rendered on screen with the specified ID.
Usage Info:
glGetModels(1024);
*}
Function glGetModels(ID: Cardinal): glModelArray; overload;
var
Size, I, J: Cardinal;
Ptr: Pointer;
Begin
Result := [];
Ptr := GLXModels(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
if (Cardinal(Ptr^) = ID) then
begin
Result[J] := glModel(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glModel));
End;
SetLength(Result, J);
End;
{*
Returns an array of Models rendered on screen that have the specified IDs.
Used for finding multiple models at once.
Usage Info:
1 - glGetModels([1024, 2048, 3072, 4096]);
2 - glGetModels(Array_Of_Models_To_Find);
3 - glGetModels(TCardinalArray[1024, 2048, 3072, 4096]);
4 - etc..
*}
Function glGetModels(IDs: TCardinalArray): glModelArray; overload;
var
Size, I, J: Cardinal;
Ptr: Pointer;
Begin
Result := [];
Ptr := GLXModels(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
if (IDs.Contains(Cardinal(Ptr^))) then
begin
Result[J] := glModel(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glModel));
End;
SetLength(Result, J);
End;
{*
Returns an array of Models rendered on screen that are within the specified area.
Usage Info:
1 - glGetModels(IntToBox(X1, Y1, X2, Y2));
2 - glGetModels(Main_Screen_Bounds);
3 - glGetModels(Area_To_Search);
4 - etc..
*}
Function glGetModels(Area: TBox): glModelArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glModel = ^glModel;
Begin
Result := [];
Ptr := GLXModels(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glModel(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glModel(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area)) then
begin
Result[J] := glModel(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glModel));
End;
SetLength(Result, J);
End;
{*
Returns an array of Models rendered on screen that have the specified ID and
is within the specified area.
Usage Info:
1 - glGetModels(1024, Main_Screen);
2 - glGetModels(2048, IntToBox(X1, Y1, X2, Y2));
3 - glGetModels(My_Player_ID, Some_Area_To_Search);
4 - etc..
*}
Function glGetModels(ID: Cardinal; Area: TBox): glModelArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glModel = ^glModel;
Begin
Result := [];
Ptr := GLXModels(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glModel(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glModel(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if ((Cardinal(Ptr^) = ID) and (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area))) then
begin
Result[J] := glModel(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glModel));
End;
SetLength(Result, J);
End;
{*
Returns an array of Models rendered on screen that have the specified IDs and
is within the specified Area. Used for finding multiple models at once.
Usage Info:
1 - glGetModels([1024, 2048, 3072, 4096], Main_Screen);
2 - glGetModels(Array_Of_Models_To_Find, Area_To_Search);
3 - glGetModels(TCardinalArray[1024, 2048, 3072, 4096], IntToBox(X1, Y1, X2, Y2));
4 - etc..
*}
Function glGetModels(IDs: TCardinalArray; Area: TBox): glModelArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glModel = ^glModel;
Begin
Result := [];
Ptr := GLXModels(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glModel(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glModel(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if (IDs.Contains(Cardinal(Ptr^)) and (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area))) then
begin
Result[J] := glModel(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glModel));
End;
SetLength(Result, J);
End;
{*
Returns an array of all font/text characters rendered to the screen.
Note:
Fonts/Chars/Text may contain shadows. Ex: 'LLooggiinn Ppllaayyeerr'
instead of 'Login Player'.
Usage Info:
writeln(glGetChars);
*}
Function glGetChars: glCharArray;
var
Size, I: Cardinal;
Ptr: Pointer;
Begin
Result := [];
Ptr := GLXFonts(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
Result[I] := glChar(Ptr^);
Ptr.Inc(sizeof(glChar));
End;
End;
{*
Returns an array of all font/text characters rendered to the screen within
a specified area.
Note:
Fonts/Chars/Text may contain shadows. Ex: 'LLooggiinn Ppllaayyeerr'
instead of 'Login Player'.
Usage Info:
1 - glGetChars(IntToBox(X1, Y1, X2, Y2));
2 - glGetChars(ChatBox);
3 - glGetChars(Some_Area_To_Search);
*}
Function glGetChars(Area: TBox): glCharArray; overload;
var
Ptr: Pointer;
Size, I, J: Cardinal;
XOffset, YOffset: Integer;
type ptr_glChar = ^glChar;
Begin
J := 0;
Result := [];
Ptr := GLXFonts(Size);
SetLength(Result, Size);
XOffset := (PtrUInt(@(ptr_glChar(nil + 1)^.X)) - 1);
YOffset := (PtrUInt(@(ptr_glChar(nil + 1)^.Y)) - 1);
For I := 0 To Size - 1 Do
Begin
if (PointInBox(Point(Integer((Ptr + XOffset)^), Integer((Ptr + YOffset)^)), Area)) then
begin
Result[J] := glChar(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glChar));
End;
SetLength(Result, J);
End;
{*
Removes all shadow fonts/text/characters from the specified array of glChar.
Example:
'LLooggiinn Ppllaayyeerr' ----> 'Login Player'.
Usage Info:
1 - glRemoveTextShadows(glGetChars);
2 - glRemoveTextShadows(glGetChars(SomeArea));
3 - glRemoveTextShadows(glGetChars(IntToBox(X1, Y1, X2, Y2)));
4 - etc..
*}
Function glRemoveTextShadows(var Chars: glCharArray): glCharArray;
var
I, J: Integer;
begin
J := 0;
SetLength(Result, length(chars));
For I := 0 To High(chars) do
begin
if ((I <= High(Chars) - 1) and (Chars[I].X - Chars[I + 1].X = 1)) then
Inc(I);
Result[J] := Chars[I];
Inc(J);
end;
SetLength(Result, J);
end;
{*
Returns the amount of space between fonts/texts/characters on screen
(In Logical Units).
Usage Info:
1 - glGetCharSpacing(glGetChars);
2 - glGetCharSpacing(glGetChars(SomeArea));
3 - glGetCharSpacing(glGetChars(IntToBox(X1, Y1, X2, Y2)));
4 - etc..
*}
Function glGetCharSpacing(var glChars: glCharArray): Integer;
var
I, W, S: Integer = 0;
Begin
Result := 0;
glChars := glRemoveTextShadows(glChars);
For I := 0 To High(glChars) do
begin
W := abs(glChars[I].Bounds.X2 - glChars[I].Bounds.X1);
S := round(abs(glChars[I + 1].Translate[0] - (glChars[I].Translate[0] + W)));
if ((I < High(glChars)) and (S >= Result)) then
Result := S;
end;
End;
{*
Turns an array of characters/fonts into legible text.
Automatically removes all font/text shadows. Each Index in the array represents a new line.
Usage Info:
StringArray := glCharsToText(glGetChars(ChatBox), 5, 5));
writeln(StringArray[0]); //Prints Line 1.
writeln(StringArray[1]); //Prints Line 2.
etc..
Developer Info:
glChars = List Of Fonts rendered on screen.
MinHSpacing = Minimum amount of space you think is between each character in the text (Horizontal spacing).
MinVSpacing = Minimum amount of space you think is between each new line in the text (Vertical spacing).
*}
Function glCharsToText(var glChars: glCharArray; MinHSpacing, MinVSpacing: Integer = 5): TStringArray;
var
I, W: Integer;
Str: String;
begin
glChars := glRemoveTextShadows(glChars);
For I := 0 To High(glChars) do
begin
Str := Str + glChars[I].Letter;
W := abs(glChars[I].Bounds.X2 - glChars[I].Bounds.X1);
if (I < High(glChars)) then
if (abs(round(glChars[I + 1].Translate[0] - (glChars[I].Translate[0] + W))) >= MinHSpacing) then
Str := Str + ' ';
if ((I < High(glChars)) and abs(glChars[I + 1].Y - glChars[I].Y) >= MinVSpacing) then
Str := Str + '\r\n';
end;
ExplodeWrap('\r\n', Trim(Str), Result);
end;
{*
Turns an array of characters/fonts into a structure containing the legible text as well as
the bounding-box around the text.
Automatically removes all font/text shadows. Each Index in the array represents a new line.
Usage Info:
glTextArray := glCharsToText(glGetChars(ChatBox), 5, 5));
writeln(glTextArray[0].Text); //Prints Line 1.
writeln(glTextArray[0].Bounds); //Prints the area in which Line 1 was found.
etc..
Developer Info:
glChars = List Of Fonts rendered on screen.
MinHSpacing = Minimum amount of space you think is between each character in the text (Horizontal spacing).
MinVSpacing = Minimum amount of space you think is between each new line in the text (Vertical spacing).
*}
Function glCharsToTexts(var glChars: glCharArray; MinHSpacing, MinVSpacing: Integer = 5): glTextArray;
var
I, J, W, H, K: Integer;
Even: Boolean;
NewLine: Boolean = True;
begin
glChars := glRemoveTextShadows(glChars);
Even := (Length(glChars) mod 2) = 0;
For I := 0 To High(glChars) do
begin
If (NewLine) then
begin
SetLength(Result, J + 1);
Result[J].Bounds.X1 := round(glChars[I].Translate[0] + glChars[I].Bounds.X1);
Result[J].Bounds.Y1 := round(glChars[I].Translate[1] + glChars[I].Bounds.Y1);
NewLine := False;
end;
Result[J].Text := Result[J].Text + glChars[I].Letter;
W := abs(glChars[I].Bounds.X2 - glChars[I].Bounds.X1);
H := abs(glChars[I].Bounds.Y2 - glChars[I].Bounds.Y1);
if (I < High(glChars)) then
if (abs(round(glChars[I + 1].Translate[0] - (glChars[I].Translate[0] + W))) >= MinHSpacing) then
Result[J].Text := Result[J].Text + ' ';
if ((I <= High(glChars)) and abs(glChars[I + 1].Y - glChars[I].Y) >= MinVSpacing) then
begin
Result[J].Bounds.X2 := round(glChars[I].Translate[0] + glChars[I].Bounds.X2);
Result[J].Bounds.Y2 := round(glChars[I].Translate[1] + glChars[I].Bounds.Y2);
NewLine := True;
Inc(J);
end;
end;
end;
{*
Turns an array of characters/fonts into a structure containing the legible text as well as
the bounding-box around each word.
Automatically removes all font/text shadows. Each Index in the array represents a new line.
Usage Info:
glTextArray := glCharsToText(glGetChars(ChatBox), 5, 5));
writeln(glTextArray[0].Text[0]); //Prints a word in Line 1.
writeln(glTextArray[0].Bounds[0]); //Prints the area in which a word in Line 1 was found.
etc..
Developer Info:
glChars = List Of Fonts rendered on screen.
MinHSpacing = Minimum amount of space you think is between each character in the text (Horizontal spacing).
MinVSpacing = Minimum amount of space you think is between each new line in the text (Vertical spacing).
*}
Function glCharsToTextEx(var glChars: glCharArray; MinHSpacing, MinVSpacing: Integer = 5): glTextExArray;
var
I, J, K, W, H: Integer = 0;
NewIndex, NewLine: Boolean = True;
begin
glChars := glRemoveTextShadows(glChars);
For I := 0 To High(glChars) do
begin
W := abs(glChars[I].Bounds.X2 - glChars[I].Bounds.X1);
H := abs(glChars[I].Bounds.Y2 - glChars[I].Bounds.Y1);
if (NewLine) then
begin
SetLength(Result, J + 1);
SetLength(Result[J].Text, 1);
SetLength(Result[J].Areas, 1);
Result[J].Areas[0].X1 := round(glChars[I].Translate[0] + glChars[I].Bounds.X1);
Result[J].Areas[0].Y1 := round(glChars[I].Translate[1] + glChars[I].Bounds.Y1);
NewLine := False;
end;
Result[J].Text[0] := Result[J].Text[0] + glChars[I].Letter;
if (I < High(glChars)) then
if (abs(round(glChars[I + 1].Translate[0] - (glChars[I].Translate[0] + W))) >= MinHSpacing) then
Result[J].Text[0] := Result[J].Text[0] + ' ';
if ((I <= High(glChars)) and abs(glChars[I + 1].Y - glChars[I].Y) >= MinVSpacing) then
begin
Result[J].Areas[0].X2 := round(glChars[I].Translate[0] + glChars[I].Bounds.X1 + W);
Result[J].Areas[0].Y2 := round(glChars[I].Translate[1] + glChars[I].Bounds.Y1 + H);
NewLine := True;
Inc(J);
K := 0;
end;
end;
end;
{*
Turns an array of characters/fonts into a structure containing the legible text as well as
the bounding-box around each word and the colour of that word.
Automatically removes all font/text shadows. Each Index in the array represents a new line.
Usage Info:
glTextArray := glCharsToText(glGetChars(ChatBox), 5, 5));
writeln(glTextArray[0].Text[0]); //Prints a word in Line 1.
writeln(glTextArray[0].Bounds[0]); //Prints the area in which the word in Line 1 was found.
writeln(glTextArray[0].Colours[0]); //Prints the colour of the word in Line 1.
etc..
Developer Info:
glChars = List Of Fonts rendered on screen.
MinHSpacing = Minimum amount of space you think is between each character in the text (Horizontal spacing).
MinVSpacing = Minimum amount of space you think is between each new line in the text (Vertical spacing).
*}
Function glCharsToTextAdv(var glChars: glCharArray; MinHSpacing, MinVSpacing: Integer = 5): glTextExArray;
var
I, J, K, L, W, H: Integer = 0;
NewIndex, NewLine: Boolean = True;
begin
glChars := glRemoveTextShadows(glChars);
For I := 0 To High(glChars) do
begin
W := abs(glChars[I].Bounds.X2 - glChars[I].Bounds.X1);
H := abs(glChars[I].Bounds.Y2 - glChars[I].Bounds.Y1);
if (NewLine) then
begin
SetLength(Result, J + 1);
SetLength(Result[J].Text, L + 1);
SetLength(Result[J].Areas, K + 1);
SetLength(Result[J].Colours, K + 1);
Result[J].Colours[K] := glChars[I].Colour;
Result[J].Areas[K].X1 := round(glChars[I].Translate[0] + glChars[I].Bounds.X1);
Result[J].Areas[K].Y1 := round(glChars[I].Translate[1] + glChars[I].Bounds.Y1);