-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCARSeffects.bas
1232 lines (1044 loc) · 53.5 KB
/
LCARSeffects.bas
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
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=6.77
@EndOfDesignText@
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Prompt stuff
Dim PromptID As Int,Prompt2Btns As Boolean, PromptQID As Int, PromptGroup As Int, BarHeight As Int, BarWidth As Int,IsMultiline As Boolean ,QuestionAsked As Boolean
Dim PromptHeight As Int, PromptWidth As Int, was2buttons As Boolean ',Width2 As Int :
PromptHeight=200 : BarHeight=32: BarWidth=BarHeight*3: PromptWidth= BarWidth+ LCAR.LCARCornerElbow2.width
'Frame stuff
Dim FrameGroup1 As Int, FrameGroup2 As Int ,FrameElement As Int ,FrameLeftBar As Int ,NeedsRedrawFrame As Boolean ,NeedsLeftBar As Boolean , FrameOffset As Int,FrameBitsVisible As Boolean
'Dpad stuff
Dim DpadCenter As Float : DpadCenter=0.125
'Condition status alert stuff
Dim OkudaStages As Int,CachedRadius As Int,CachedAngles As List :OkudaStages=25
'SensorSweep and ShieldStatus Stuff
Dim Enterprise As Bitmap, MaxShieldStages As Int:MaxShieldStages=16
'GradientStuff
Type GradientCache(ColorID As Int, State As Boolean, Stages(16) As Int )
Dim Gradients As List :Gradients.Initialize :CachedAngles.Initialize
End Sub
Sub CacheGradient(ColorID As Int, State As Boolean) As Int
Dim temp As Int , tempcache As GradientCache,tempcolor As LCARColor,R As Int, G As Int, B As Int ,temp2 As Double
For temp = 0 To Gradients.Size-1
tempcache=Gradients.Get(temp)
If tempcache.ColorID=ColorID And tempcache.State=State Then Return temp
Next
tempcache.Initialize
tempcache.ColorID=ColorID
tempcache.State=State
tempcolor=LCAR.LCARcolors.get(ColorID)
If State Then
R=tempcolor.sR
G=tempcolor.sG
B=tempcolor.sB
Else
R=tempcolor.nR
G=tempcolor.nG
B=tempcolor.nB
End If
For temp = 0 To 15
temp2=temp/15
tempcache.stages(temp) = Colors.RGB( R * temp2, G*temp2, B*temp2)
Next
Gradients.Add(tempcache)
Return Gradients.Size-1
End Sub
Sub GetTextHeight(BG As Canvas, DesiredHeight As Int, Text As String, tTypeFace As Typeface, IsHeight As Boolean ) As Int
Dim temp As Int,CurrentHeight As Int
Do Until temp >= DesiredHeight
CurrentHeight=CurrentHeight+1
If IsHeight Then
temp = BG.MeasureStringHeight(Text,tTypeFace, CurrentHeight)
Else
temp = BG.MeasureStringWidth(Text,tTypeFace, CurrentHeight)
End If
Loop
If temp>DesiredHeight Then CurrentHeight=CurrentHeight-1
Return CurrentHeight
End Sub
Sub SmallScreenMode
BarHeight=LCAR.ItemHeight
BarWidth=33 'Barheight*3
PromptWidth= BarWidth+ LCAR.LCARCornerElbow2.width
If FrameElement>0 Then 'resize frame
LCAR.ResizeElbowDimensions(FrameElement+1, 50, 10)
LCAR.ResizeElbowDimensions(FrameElement+6, 50, 10)
End If
If PromptID>0 Then'resize prompt
LCAR.ResizeElbowDimensions(PromptID,BarWidth,BarHeight)
LCAR.ResizeElbowDimensions(PromptID+1,BarWidth,BarHeight)
LCAR.ResizeElbowDimensions(PromptID+2,BarWidth,BarHeight)
LCAR.ResizeElbowDimensions(PromptID+3,BarWidth,BarHeight)
End If
End Sub
Sub ResizeLeftBar(Index As Int, Index2 As Int)
Dim Y As Int =256,Width As Int=100
If LCAR.SmallScreen Then
Y= 132
Width=50
Else If LCAR.CrazyRez>0 Then
Y= LCAR.GetScaledPosition(4,False)' Y*LCAR.CrazyRez
Width=Width*LCAR.CrazyRez
End If
If Index = -1 Then 'hidekb, enlarge element 17
LCAR.ForceElementData(FrameElement+11, 0 , Y , 0,0, Width,-1,0,-Index2, 255,255, True,True)
Else'showkb, shrink element 17
LCAR.ForceElementData(FrameElement+11, 0 , Y , 0,0, Width, Index2 ,0,Abs(Index2)-4, 255,255, True,True)
End If
End Sub
'Sub ResizeLeftBar(Index As Int, Index2 As Int)
' Dim Y As Int ,Width As Int
' If LCAR.SmallScreen Then
' Y= 132
' Width=50
' Else
' Y=256
' Width=100
' End If
' If Index = -1 Then 'hidekb, enlarge element 17
' LCAR.ForceElementData(FrameElement+11, 0 , Y , 0,0, Width,-1,0,-Index2, 255,255, True,True)
' Else'showkb, shrink element 17
' LCAR.ForceElementData(FrameElement+11, 0 , Y , 0,0, Width, Index2 ,0,Abs(Index2)-4, 255,255, True,True)
' End If
'End Sub
Sub NextStage(Element1 As Int, Element2 As Int, LastStage As Int)
LCAR.Stage=LCAR.Stage+1
LCAR.LCAR_HideElement(Null, Element1, False,True,False)
LCAR.LCAR_HideElement(Null, Element2,False,True,False)
If NeedsLeftBar AND LCAR.Stage=LastStage Then LCAR.LCAR_HideElement(Null, FrameElement+11,False,True,False)'stage was 7
End Sub
Sub IsFrameVisible As Boolean
Return (LCAR.GroupVisible(FrameGroup1) AND FrameGroup1>0 ) OR (LCAR.GroupVisible(FrameGroup2) AND FrameGroup2>0 )
End Sub
'Sub ShowFrame(BG As Canvas, DoAnimation As Boolean, LeftBar As Boolean,Stage As Int )
' Dim Element As LCARelement, OneThird As Int,X As Int,X2 As Int 'ForceElementData
'
' OneThird= LCAR.ScaleWidth/3
' NeedsLeftBar=LeftBar
' 'elements 6-17, (group 3 and 5)
' DoAnimation=False
'
' 'If LCAR.GroupVisible(FrameGroup1) AND LCAR.GroupVisible(FrameGroup2) AND Not(NeedsRedrawFrame) Then Return False
' 'If DoAnimation Then LCAR.LCAR_HideAll(BG,False)
'
' LCAR.Stage=Stage
' LCAR.HideGroup(FrameGroup1,True,True)
' LCAR.HideGroup(FrameGroup2,True,True)
'
' If LCAR.SmallScreen Then
' LCAR.ForceElementData(FrameElement, 0,0,0,35,50,35,0,-35,0,255,True,DoAnimation)'top left square
'
' X=LCAR.ForceElementData(FrameElement+1,0, 38, 0,0, OneThird, 44, -OneThird+ 50, 0, 0,255,True,DoAnimation)+3'7 and 12 elbows
' LCAR.ForceElementData(FrameElement+6,0,85, 0,0, OneThird, 44, -OneThird+ 50 , 0, 0,255,True,DoAnimation)
'
' X2=LCAR.ForceElementData(FrameElement+2, X, 72, 0,0, 12, 10,0, 0, 0,255,Not(DoAnimation),DoAnimation)+3'8 and 13 small squares
' LCAR.ForceElementData(FrameElement+7, X, 85, 0,0, 12, 10, 0, 0, 0,255,Not(DoAnimation),DoAnimation)
'
' X=LCAR.ForceElementData(FrameElement+3, X2, 72, 0, 0, OneThird-15, 10, -(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)+3'9 and 14 long rectangles
' LCAR.ForceElementData(FrameElement+8, X2, 85, 0, 0, OneThird-15, 5, -(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)
'
' X2=LCAR.ForceElementData(FrameElement+4, X,72,0,0, OneThird-15, 10,-(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)+3'10 and 15 long rectangles
' LCAR.ForceElementData(FrameElement+9, X,85,0,0, OneThird-15, 10,-(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)
'
' LCAR.ForceElementData(FrameElement+5, X2,72,0,0, 12,10,0,0,0,255,Not(DoAnimation),DoAnimation) '11 and 16 small squares
' LCAR.ForceElementData(FrameElement+10, X2,85,0,0, 12,10,0,0,0,255,Not(DoAnimation),DoAnimation)
'
' LCAR.ForceElementData(FrameElement+11, 0,132+FrameOffset, 0,0, 50,LCAR.ScaleHeight-132-FrameOffset,0,-(LCAR.ScaleHeight-132-FrameOffset),0,255,Not(DoAnimation),DoAnimation)
' Else
' 'top left square width=100, height=71
' LCAR.ForceElementData(FrameElement, 0,0,0,71,100,71,0,-71,0,255,True,DoAnimation)
'
' '7 and 12 elbows 0,75,358,88,100,17,
' X=LCAR.ForceElementData(FrameElement+1,0, 74, 0,0, OneThird, 88, -OneThird+ 100, 0, 0,255,True,DoAnimation)+3
' LCAR.ForceElementData(FrameElement+6,0,165, 0,0, OneThird, 88, -OneThird+ 100 , 0, 0,255,True,DoAnimation)
'
' '8 and 13 small squares 361,146,23,17,
' X2=LCAR.ForceElementData(FrameElement+2, X, 145, 0,0, 23, 17,0, 0, 0,255,Not(DoAnimation),DoAnimation)+3
' LCAR.ForceElementData(FrameElement+7, X, 165, 0,0, 23, 17, 0, 0, 0,255,Not(DoAnimation),DoAnimation)
'
' '9 and 14 long rectangles 388,146,118,17
' X=LCAR.ForceElementData(FrameElement+3, X2, 145, 0, 0, OneThird-26, 17, -(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)+3
' LCAR.ForceElementData(FrameElement+8, X2, 165, 0, 0, OneThird-26, 6, -(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)
'
' '10 and 15 long rectangles 509,146,-27,17
' X2=LCAR.ForceElementData(FrameElement+4, X,145,0,0, OneThird-26, 17,-(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)+3
' LCAR.ForceElementData(FrameElement+9, X,165,0,0, OneThird-26, 17,-(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)
'
' '11 and 16 small squares -24,146,24,17
' LCAR.ForceElementData(FrameElement+5, X2,145,0,0, 23,17,0,0,0,255,Not(DoAnimation),DoAnimation)
' LCAR.ForceElementData(FrameElement+10, X2,165,0,0, 23,17,0,0,0,255,Not(DoAnimation),DoAnimation)
'
' 'If leftbar Then '0,256,100,-1,0,0, lcar.ScaleHeight-256
' LCAR.ForceElementData(FrameElement+11, 0,256+FrameOffset, 0,0, 100,LCAR.ScaleHeight-256-FrameOffset,0,-(LCAR.ScaleHeight-256-FrameOffset),0,255,Not(DoAnimation),DoAnimation)
' End If
' If Not(NeedsLeftBar) Then 'LCAR.ForceHide(FrameElement+11)
' LCAR.LCAR_HideElement(BG, FrameElement+11, False, False,True)
' End If
'
' NeedsRedrawFrame= False
' FrameBitsVisible=True
'End Sub
Sub ShowFrame(BG As Canvas, DoAnimation As Boolean, LeftBar As Boolean,Stage As Int )
Dim Element As LCARelement, OneThird As Int,X As Int,X2 As Int, Factor As Float = 1, temp As Int, Whitespace As Int = LCAR.ListitemWhiteSpace 'ForceElementData
Dim Top As Int = 145, Bottom As Int = 165
OneThird= LCAR.ScaleWidth/3
NeedsLeftBar=LeftBar
'elements 6-17, (group 3 and 5)
If LCAR.GroupVisible(FrameGroup1) AND LCAR.GroupVisible(FrameGroup2) AND Not(NeedsRedrawFrame) Then Return False
DoAnimation=False
'If DoAnimation Then LCAR.LCAR_HideAll(BG,False)
LCAR.Stage=Stage
LCAR.HideGroup(FrameGroup1,True,True)
LCAR.HideGroup(FrameGroup2,True,True)
If LCAR.SmallScreen Then
LCAR.ForceElementData(FrameElement, 0,0,0,35,50,35,0,-35,0,255,True,DoAnimation)'top left square
X=LCAR.ForceElementData(FrameElement+1,0, 38, 0,0, OneThird, 44, -OneThird+ 50, 0, 0,255,True,DoAnimation)+3'7 and 12 elbows
LCAR.ForceElementData(FrameElement+6,0,85, 0,0, OneThird, 44, -OneThird+ 50 , 0, 0,255,True,DoAnimation)
X2=LCAR.ForceElementData(FrameElement+2, X, 72, 0,0, 12, 10,0, 0, 0,255,Not(DoAnimation),DoAnimation)+3'8 and 13 small squares
LCAR.ForceElementData(FrameElement+7, X, 85, 0,0, 12, 10, 0, 0, 0,255,Not(DoAnimation),DoAnimation)
X=LCAR.ForceElementData(FrameElement+3, X2, 72, 0, 0, OneThird-15, 10, -(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)+3'9 and 14 long rectangles
LCAR.ForceElementData(FrameElement+8, X2, 85, 0, 0, OneThird-15, 5, -(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)
X2=LCAR.ForceElementData(FrameElement+4, X,72,0,0, OneThird-15, 10,-(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)+3'10 and 15 long rectangles
LCAR.ForceElementData(FrameElement+9, X,85,0,0, OneThird-15, 10,-(OneThird-26), 0,0,255,Not(DoAnimation),DoAnimation)
LCAR.ForceElementData(FrameElement+5, X2,72,0,0, 12,10,0,0,0,255,Not(DoAnimation),DoAnimation) '11 and 16 small squares
LCAR.ForceElementData(FrameElement+10, X2,85,0,0, 12,10,0,0,0,255,Not(DoAnimation),DoAnimation)
LCAR.ForceElementData(FrameElement+11, 0,132+FrameOffset, 0,0, 50,LCAR.ScaleHeight-132-FrameOffset,0,-(LCAR.ScaleHeight-132-FrameOffset),0,255,Not(DoAnimation),DoAnimation)
Else
If LCAR.CrazyRez>0 Then
Factor=LCAR.CrazyRez
Bottom = Bottom*Factor - (Whitespace*2)
Top=Bottom - ((17*Factor)+Whitespace)
End If
LCAR.ForceElementData(FrameElement, 0,0,0,71*Factor,100*Factor,71*Factor,0,-71*Factor,0,255,True,DoAnimation)'top left square width=100, height=71
'7 and 12 elbows 0,75,358,88,100,17,
'If Factor > 2 Then X = Factor * 2 + ((Factor-3)*2)
temp=(100*Factor)
X2=temp*1.33
If Factor <3 Then X=88*Factor Else X = Bottom - (71*Factor) - Whitespace*2
X=LCAR.ForceElementData(FrameElement+1, 0, 71*Factor + Whitespace, 0,0, X2, X , -X2+temp, 0, 0,255,True,DoAnimation)+3
LCAR.ForceElementData(FrameElement+6, 0, Bottom, 0,0, X2 , 88*Factor, -X2+temp , 0, 0,255,True,DoAnimation)
OneThird = (LCAR.ScaleWidth - X+2) / 2
Element=LCAR.LCARelements.Get(FrameElement+1)
Element.LWidth=100*Factor
Element.rWidth=17*Factor
Select Case Factor
Case 1.5: Element.Size.currY = Element.Size.currY - 4
Case 2.5: Element.Size.currY = Element.Size.currY + 2
End Select
Element=LCAR.LCARelements.Get(FrameElement+6)
Element.LWidth=100*Factor
Element.rWidth=17*Factor
'8 and 13 small squares 361,146,23,17,
X2=LCAR.ForceElementData(FrameElement+2, X, Top, 0,0, 23*Factor, 17*Factor,0, 0, 0,255,Not(DoAnimation),DoAnimation)+3
LCAR.ForceElementData(FrameElement+7, X, Bottom, 0,0, 23*Factor, 17*Factor, 0, 0, 0,255,Not(DoAnimation),DoAnimation)
'9 and 14 long rectangles 388,146,118,17
temp=OneThird - (23*Factor) - Whitespace' OneThird-26
X=LCAR.ForceElementData(FrameElement+3, X2, Top, 0, 0, temp, 17*Factor, -temp, 0,0,255,Not(DoAnimation),DoAnimation)+3
LCAR.ForceElementData(FrameElement+8, X2, Bottom, 0, 0, temp, 6*Factor, -temp, 0,0,255,Not(DoAnimation),DoAnimation)
'10 and 15 long rectangles 509,146,-27,17
X2=LCAR.ForceElementData(FrameElement+4, X,Top,0,0, temp, 17*Factor,-temp, 0,0,255,Not(DoAnimation),DoAnimation)+3
LCAR.ForceElementData(FrameElement+9, X,Bottom,0,0, temp, 17*Factor,-temp, 0,0,255,Not(DoAnimation),DoAnimation)
'11 and 16 small squares -24,146,24,17
LCAR.ForceElementData(FrameElement+5, X2,Top,0,0, 23*Factor,17*Factor,0,0,0,255,Not(DoAnimation),DoAnimation)
LCAR.ForceElementData(FrameElement+10, X2,Bottom,0,0, 23*Factor,17*Factor,0,0,0,255,Not(DoAnimation),DoAnimation)
'If leftbar Then '0,256,100,-1,0,0, lcar.ScaleHeight-256
X=Bottom + (88*Factor) + Whitespace '250*Factor + Whitespace*2' API.iif(LCAR.crazyrez, 503,256)
LCAR.ForceElementData(FrameElement+11, 0,X+FrameOffset, 0,0, 100*Factor,LCAR.ScaleHeight-X-FrameOffset,0,-(LCAR.ScaleHeight-X-FrameOffset),0,255,Not(DoAnimation),DoAnimation)
End If
If Not(NeedsLeftBar) Then 'LCAR.ForceHide(FrameElement+11)
LCAR.LCAR_HideElement(BG, FrameElement+11, False, False,True)
End If
NeedsRedrawFrame= False
FrameBitsVisible=True
End Sub
Sub MoveListY(ListID As Int)As Boolean
Dim Element As LCARelement ,AvailableSpace As Int ,tList As LCARlist ,Y As Int = LCAR.GetScaledPosition(4,False)'= api.IIF(lcar.SmallScreen,12,17 * lcar.GetScalemode)
If FrameElement>0 AND FrameElement+6 < LCAR.LCARelements.size AND ListID < LCAR.LCARlists.Size Then
Element = LCAR.LCARelements.Get(FrameElement+6)
tList= LCAR.LCARlists.Get(ListID)
AvailableSpace = Max(0,Floor((Element.Size.currY + Element.Size.offY - Element.RWidth) / LCAR.ListItemsHeight(1)))'(Element.Size.currY + Element.Size.offY)
tList.LOC.currY = Y - (AvailableSpace*LCAR.ListItemsHeight(1))
tList.LOC.offY=0
If ListID<>4 Then
tList.LOC.currX = LCAR.GetScaledPosition(3,True) 'API.IIF(LCAR.SmallScreen, 50,100) + LCAR.ChartSpace
tList.LOC.offX=0
End If
tList.IsClean=False
Return True
End If
End Sub
'Sub MoveListY(ListID As Int)As Boolean
' Dim Element As LCARelement ,AvailableSpace As Int ,tList As LCARlist ,Y As Int
' If FrameElement>0 AND FrameElement+6 < LCAR.LCARelements.size AND ListID < LCAR.LCARlists.Size Then
' Element = LCAR.LCARelements.Get(FrameElement+6)
' tList= LCAR.LCARlists.Get(ListID)
' AvailableSpace = (Element.Size.currY + Element.Size.offY) - Element.RWidth - LCAR.ListitemWhiteSpace
' Y=Element.LOC.currY + Element.LOC.offY + Element.Size.currY + Element.Size.offY
' If LCAR.ItemHeight <= AvailableSpace Then
' Y = Y - LCAR.ItemHeight
' Else
' Y=Y + LCAR.ListitemWhiteSpace
' End If
' 'debug("Moving list " & ListID & " from " & tList.LOC.currY & " to " & Y & " to fit in " & AvailableSpace)
' tList.LOC.currY = Y
' tList.LOC.offY=0
'
' If ListID<>4 Then
' tList.LOC.currX = API.IIF(LCAR.SmallScreen, 50,100) + LCAR.ChartSpace
' tList.LOC.offX=0
' End If
'
' tList.IsClean=False
' Return True
' End If
'End Sub
Sub HideFrame
NeedsRedrawFrame =False
LCAR.HideGroup(FrameGroup1,False,False)
LCAR.HideGroup(FrameGroup2,False,False)
End Sub
Sub MakeFrame(Group1 As Int, Group2 As Int)
'frame top half (group 3)
FrameGroup1=Group1
FrameElement = LCAR.LCAR_AddLCAR("TopLeft", 0, 0,0,100,71,0,0, LCAR.LCAR_LightPurple, LCAR.LCAR_Button, "", "", "" , Group1, False, 2,True,0,0)'element 0 button
LCAR.LCAR_AddLCAR("TopElbo", 0, 0,75,358,88,100,17, LCAR.LCAR_DarkPurple, LCAR.LCAR_Elbow ,"","","", Group1, False, 0, True, 2,0)'element 1 elbow
LCAR.LCAR_AddLCAR("MidLef1", 0, 361,146,23,17,0,0, LCAR.LCAR_Orange, LCAR.LCAR_Button, "", "", "" , Group1, False, 0,False,0,0)'element 2 short -
LCAR.LCAR_AddLCAR("MidLef2", 0, 388,146,118,17,0,0, LCAR.LCAR_LightPurple, LCAR.LCAR_Button, "", "", "" , Group1, False, 0,False,0,0)'element 3 100x -
LCAR.LCAR_AddLCAR("MidLef3", 0, 509,146,-27,17,0,0, LCAR.LCAR_LightPurple, LCAR.LCAR_Button, "", "", "" , Group1, False, 0,False,0,0)'element 4 variable -
LCAR.LCAR_AddLCAR("MidLef4", 0, -24,146,24,17,0,0, LCAR.LCAR_Red, LCAR.LCAR_Button, "", "", "" , Group1, False, 0,False,0,0)'element 5 last -
'frame bottom half (group 5)
FrameGroup2=Group2
LCAR.LCAR_AddLCAR("Mi2Left", 0, 0,167,358,71,100,17, LCAR.LCAR_Red, LCAR.LCAR_Elbow, "", "", "" , Group2, False, 0,True,0,0)'element 6 elbow
LCAR.LCAR_AddLCAR("Mi2Lef1", 0, 361,167,23,17,0,0, LCAR.LCAR_LightOrange, LCAR.LCAR_Button, "", "", "" , Group2, False, 0,False,0,0)'element 7 short -
LCAR.LCAR_AddLCAR("Mi2Lef2", 0, 388,167,118,6,0,0, LCAR.LCAR_LightOrange, LCAR.LCAR_Button, "", "", "" , Group2, False, 0,False,0,0)'element 8 100x -
LCAR.LCAR_AddLCAR("Mi2Lef3", 0, 509,167,-27,17,0,0, LCAR.LCAR_LightPurple, LCAR.LCAR_Button, "", "", "" , Group2, False, 0,False,0,0)'element 9 variable -
LCAR.LCAR_AddLCAR("Mi2Lef4", 0, -24,167,24,17,0,0, LCAR.LCAR_LightOrange, LCAR.LCAR_Button, "", "", "" , Group2, False, 0,False,0,0)'element 10 last -
FrameLeftBar= LCAR.LCAR_AddLCAR("LeftBar", 0, 0,256,100, -1,0,0, LCAR.LCAR_Orange, LCAR.LCAR_Button, "", "", "", Group2, False,8,True,0,0)'element 11'left bar if needed
LCAR.SetAsync(FrameLeftBar, False)
LCAR.ReorderGroup(FrameLeftBar,0)
LCAR.HideGroup(Group1,False,False)
LCAR.HideGroup(Group2,False,False)
End Sub
Sub HideAllFrameBits(BG As Canvas, Fade As Boolean, Visible As Boolean)
HideFrameBits(BG,True, Fade,Visible)
HideFrameBits(BG,False, Fade,Visible)
End Sub
Sub HideFrameBits(BG As Canvas, isTop As Boolean, Fade As Boolean, Visible As Boolean )
Dim temp As Int, Start As Int
Start=FrameElement + API.IIF(isTop, 2, 7)
For temp = Start To Start + 3
If Visible Then
LCAR.ForceShow(temp, True)
Else
LCAR.LCAR_HideElement(BG, temp, False, Visible, Not(Fade) )
End If
Next
FrameBitsVisible=Visible
End Sub
'Sub ResizeFrame(Offset As Int)
' Dim Y As Int
' If LCAR.SmallScreen Then Y=132 Else Y= 256
' If Offset<0 Then
' FrameOffset=LCAR.ListItemsHeight(Abs(Offset))
' Else
' FrameOffset=Offset
' End If
' LCAR.ForceElementData(FrameElement+11, 0,Y+FrameOffset, 0,0,API.IIF(LCAR.SmallScreen ,50, 100),LCAR.ScaleHeight-Y-FrameOffset,0,-(LCAR.ScaleHeight-Y-FrameOffset),0,255, True,False)
'End Sub
Sub ResizeFrame(Offset As Int)
Dim Y As Int = LCAR.GetScaledPosition(4,False)
'If LCAR.SmallScreen Then Y=132 Else Y= 256
If Offset<0 Then
FrameOffset=LCAR.ListItemsHeight(Abs(Offset))
Else
FrameOffset=Offset
End If
LCAR.ForceElementData(FrameElement+11, 0,Y+FrameOffset, 0,0,100*LCAR.GetScalemode ,LCAR.ScaleHeight-Y-FrameOffset,0,-(LCAR.ScaleHeight-Y-FrameOffset),0,255, True,False)
End Sub
Sub IsEven(Number As Int) As Boolean
Return (Number Mod 2) = 0
End Sub
Sub HidePrompt
LCAR.HideGroup(PromptGroup,False,False)
End Sub
Sub MakePrompt(SurfaceID As Int, Group As Int)As Int
Dim Width2 As Int
PromptGroup=Group
'lcar.LCAR_AddLCAR("TopElbo", 0, 0,75,358,88,100,17, lcar.LCAR_DarkPurple, lcar.LCAR_Elbow ,"","","", 3, False, 0, True, 2,0)'element 7 elbow
PromptID= LCAR.LCAR_AddLCAR("PromptTopRight", SurfaceID, -PromptWidth,0,0,PromptHeight+1, BarWidth,BarHeight, LCAR.LCAR_Orange, LCAR.LCAR_Elbow , "", "", "", Group, False, 0,False,1,0)
LCAR.LCAR_AddLCAR("PromptTopLeft", SurfaceID, 0,0, -PromptWidth+1,PromptHeight, BarWidth,BarHeight, LCAR.LCAR_Orange, LCAR.LCAR_Elbow , "PROMPT", "", "", Group, False, 10,False,0,0)'+1
LCAR.LCAR_AddLCAR("PromptBotLeft", SurfaceID, 0,PromptHeight-1, PromptWidth ,PromptHeight, BarWidth,BarHeight*2, LCAR.LCAR_Orange, LCAR.LCAR_Elbow , "", "", "", Group, False, 0,False,2,0)'+2
LCAR.LCAR_AddLCAR("PromptBotRight", SurfaceID, -PromptWidth,PromptHeight-1, PromptWidth ,PromptHeight, BarWidth,BarHeight*2, LCAR.LCAR_Orange, LCAR.LCAR_Elbow , "", "", "", Group, False, 0,False,3,0)'+3
LCAR.LCAR_AddLCAR("PromptText", SurfaceID, PromptWidth, BarHeight+LCAR.LCARCornerElbow2.Height,-PromptWidth, 18,-1,0, LCAR.LCAR_Orange, LCAR.LCAR_Textbox ,"","","", Group, False,1,False,0,0)'+4
Width2=(LCAR.ScaleWidth/2) - PromptWidth-5
Y=PromptHeight*2-BarHeight*2-1
LCAR.LCAR_AddLCAR("PromptYes",SurfaceID, PromptWidth+3,Y, Width2, BarHeight*2, 0,0, LCAR.LCAR_Orange, LCAR.LCAR_Button, "YES", "", "", Group, False, 5,True,0,0)'+5 left
LCAR.LCAR_AddLCAR("PromptNo",SurfaceID, PromptWidth+Width2+6,Y, -PromptWidth-3, BarHeight*2, 0,0, LCAR.LCAR_Orange, LCAR.LCAR_Button, "NO", "", "", Group, False, 5,True,0,0)'+6 right
Return PromptID
End Sub
Sub IsPromptVisible(BG As Canvas) As Boolean
If LCAR.GroupVisible(PromptGroup) Then
If Not(BG=Null)Then ShowPrompt(BG,-1, "", "", 0, "", "")
Return True
End If
End Sub
'negative number animation stage=keyboard mode
'Sub ShowPrompt(BG As Canvas, AnimationStage As Int, Prompt As String, Text As String, QuestionID As Int, RightBtn As String, LeftBtnOPTIONAL As String )
' Dim Y As Int,DoAnimation As Boolean ,Y2 As Int,Width2 As Int,KBmode As Boolean , Height As Int, Y3 As Int
' LCAR.LCAR_HideAll(BG,False)
' If AnimationStage<0 Then
' AnimationStage=Abs(AnimationStage)
' LCAR.ShowKeyboard(BG,AnimationStage)
' KBmode=True
' End If
'
' DoAnimation= AnimationStage>0
' LCAR.SetRedAlert(False)
' If PromptHeight*2> LCAR.ScaleHeight Then PromptHeight=LCAR.ScaleHeight/2
' If LCAR.IsKeyboardVisible(Null,0,False) Then
' KBmode=True
' Else
' Y= (LCAR.ScaleHeight/2)-PromptHeight
' End If
' Y2=Y+PromptHeight*2-BarHeight*2-1
' If AnimationStage>0 Then Prompt2Btns= LeftBtnOPTIONAL.Length>0 Else Prompt2Btns= was2buttons
' If LCAR.ElbowTextHeight=0 Then LCAR.ElbowTextHeight = LCAR.GetTextHeight(BG, BarHeight, "PROMPT")'BarHeight
'
'
' LCAR.ForceElementData(PromptID, -PromptWidth,Y,0, PromptHeight-BarHeight, 0, PromptHeight+1, 0,-PromptHeight+BarHeight, 0,255,True, DoAnimation)'top right
' LCAR.ForceElementData(PromptID+1, 0,Y,0,PromptHeight-BarHeight, -PromptWidth+1, PromptHeight,0,-PromptHeight+BarHeight,0,255,True,DoAnimation)'top left+caption
' LCAR.ForceElementData(PromptID+2,0,Y+PromptHeight-1,0,0, API.IIF(Prompt2Btns, PromptWidth,LCAR.ScaleWidth/2-2) ,PromptHeight,0,-PromptHeight+BarHeight,0,255,True,DoAnimation)'bottom left
' LCAR.ForceElementData(PromptID+3, -PromptWidth,Y+PromptHeight-1,0,0,0,PromptHeight,0,-PromptHeight+BarHeight,0,255,True,DoAnimation)'bottom right
'
' Width2=(LCAR.ScaleWidth/2) - PromptWidth-5
' Height = API.IIF(LCAR.SmallScreen, BarHeight, BarHeight*2)
' Y3 = API.IIF(LCAR.SmallScreen, Y2+BarHeight, Y2)
' LCAR.ForceElementData(PromptID+6, PromptWidth+Width2+6,Y3,0,-PromptHeight+BarHeight,-PromptWidth-3,Height,0,0,0,255,True, DoAnimation)' NO (right button)
' LCAR.ForceElementData(PromptID+5, PromptWidth+3,Y3,0,-PromptHeight+BarHeight,Width2, Height,0,0,0,255,True, DoAnimation)' OK (left button)
'
' LCAR.ForceElementData(PromptID+4, PromptWidth, Y+BarHeight+LCAR.LCARCornerElbow2.Height, 0, PromptHeight-BarHeight, -PromptWidth,18,0,0,0,255,True,DoAnimation)'Text
' If KBmode Then
' LCAR.ToggleMultiLine(False)
' Y3= Y2-50 + API.IIF(LCAR.SmallScreen, BarHeight,0)
' LCAR.ForceElementData(LCAR.KBCancelID+5, PromptWidth, Y3, 0,-PromptHeight+BarHeight, Width2*2, 40,0,0,0 ,255,True,AnimationStage>0)'KBText
' End If
' LCAR.HideGroup(PromptGroup, True,False)
'
' If DoAnimation Then
' PromptQID=QuestionID
' Text= API.TextWrap(BG, LCAR.LCARfont, 18, Text.ToUpperCase, Min(LCAR.ScaleWidth,LCAR.ScaleHeight)-PromptWidth*2 )
' LCAR.LCAR_SetElementText(PromptID+1,Prompt.ToUpperCase, "")
' LCAR.LCAR_SetElementText(PromptID+4,"", Text.ToUpperCase & " ")
' LCAR.LCAR_SetElementText(PromptID+6, RightBtn.ToUpperCase, "")
'
' was2buttons=Prompt2Btns
' If Prompt2Btns Then
' LCAR.LCAR_SetElementText(PromptID+5, LeftBtnOPTIONAL.ToUpperCase , "")
' 'Else
' ' LCAR.LCAR_HideElement(BG,PromptID+5, False,False,True)
' End If
' LCAR.Stage=AnimationStage
' End If
' If Not (was2buttons) Then LCAR.LCAR_HideElement(BG,PromptID+5, False,False,True)
'End Sub
'negative number animation stage=keyboard mode
Sub ReshowPrompt(BG As Canvas)
ShowPrompt(BG,API.IIF(LCAR.IsMultiline,-999, 0), "", "", API.IIF(LCAR.IsMultiline, -PromptQID, PromptQID), "", "")
End Sub
'negative number animation stage=keyboard mode
Sub ShowPrompt(BG As Canvas, AnimationStage As Int, Prompt As String, Text As String, QuestionID As Int, RightBtn As String, LeftBtnOPTIONAL As String )
Dim Y As Int,DoAnimation As Boolean ,Y2 As Int,Width2 As Int,KBmode As Boolean , Height As Int, Y3 As Int', Width As Int
LCAR.LCAR_HideAll(BG,False)
QuestionAsked=False
'Element= LCARelements.Get(KBCancelID+5) Element.ElementType = API.IIF(Enabled, LCAR_MultiLine, LCAR_Textbox)
If AnimationStage<0 Then
If AnimationStage=-999 Then AnimationStage=0 Else AnimationStage=Abs(AnimationStage)
LCAR.ShowKeyboard(BG,AnimationStage)
KBmode=True
End If
DoAnimation= AnimationStage>0
If Not(DoAnimation) Then
If QuestionID>0 AND IsMultiline Then QuestionID = -QuestionID
LCAR.RemoveAnimation(LCAR.KBListID,True)
End If
LCAR.SetRedAlert(False)
If PromptHeight*2> LCAR.ScaleHeight Then PromptHeight=LCAR.ScaleHeight/2
'Width=PromptHeight
If LCAR.IsKeyboardVisible(Null,0,False) OR KBmode Then
KBmode=True
QuestionAsked=True
Y2=(LCAR.ScaleHeight - LCAR.KeyboardHeight ) / 2
'debug("SH: " & LCAR.ScaleHeight & " PH: " & PromptHeight & " Y2: " & Y2 & " KBH: " & LCAR.KeyboardHeight)
'If PromptHeight>Y2 Then PromptHeight=Y2
PromptHeight=Y2
IsMultiline = QuestionID<0
Else
Y= (LCAR.ScaleHeight/2)-PromptHeight
IsMultiline=False
End If
Y2=Y+PromptHeight*2-BarHeight*2-1
If AnimationStage>0 Then Prompt2Btns= LeftBtnOPTIONAL.Length>0 Else Prompt2Btns= was2buttons
If LCAR.ElbowTextHeight=0 Then LCAR.ElbowTextHeight = LCAR.GetTextHeight(BG, BarHeight, "PROMPT")'BarHeight
'If QuestionID>=0 Then'replace x/width with Width
If KBmode Then
LCAR.ForceElementData(PromptID, -PromptWidth,Y, 0, PromptHeight*2-BarHeight, 0, PromptHeight*2+1, 0,-PromptHeight*2+BarHeight, 0,255,True, DoAnimation)'top right
LCAR.ForceElementData(PromptID+1, 0,Y, 0, PromptHeight*2-BarHeight, -PromptWidth+1, PromptHeight*2, 0,-PromptHeight*2+BarHeight, 0,255,True,DoAnimation)'top left+caption
Else
LCAR.ForceElementData(PromptID, -PromptWidth,Y, 0, PromptHeight-BarHeight, 0, PromptHeight+1, 0,-PromptHeight+BarHeight, 0,255,True, DoAnimation)'top right
LCAR.ForceElementData(PromptID+1, 0,Y, 0,PromptHeight-BarHeight, -PromptWidth+1, PromptHeight, 0,-PromptHeight+BarHeight, 0,255,True,DoAnimation)'top left+caption
LCAR.ForceElementData(PromptID+2, 0,Y+PromptHeight-1, 0,0, API.IIF(Prompt2Btns, PromptWidth,LCAR.ScaleWidth/2-2),PromptHeight, 0,-PromptHeight+BarHeight, 0,255,True,DoAnimation)'bottom left
LCAR.ForceElementData(PromptID+3, -PromptWidth,Y+PromptHeight-1, 0,0, 0,PromptHeight, 0,-PromptHeight+BarHeight, 0,255,True,DoAnimation)'bottom right
End If
Width2=(LCAR.ScaleWidth/2) - PromptWidth-5
Height = LCAR.ItemHeight ' API.IIF(LCAR.SmallScreen, BarHeight, BarHeight*2)
Y3 = API.IIF(LCAR.SmallScreen, Y2+BarHeight, Y2)
If Not(IsMultiline) Then LCAR.ForceElementData(PromptID+4, PromptWidth, Y+BarHeight+ API.IIF(LCAR.SmallScreen,0, LCAR.LCARCornerElbow2.Height), 0, PromptHeight-BarHeight, Width2,18,0,0,0,255,True,DoAnimation)'Text
'If Not(IsMultiline) Then LCAR.ForceElementData(PromptID+4, PromptWidth, Y+BarHeight+LCAR.LCARCornerElbow2.Height, 0, PromptHeight-BarHeight, -PromptWidth,18,0,0,0,255,True,DoAnimation)'Text
If KBmode Then
LCAR.ToggleMultiLine(IsMultiline)
If IsMultiline Then
QuestionID=Abs(QuestionID)
'LCAR.ForceElementData(LCAR.KBCancelID+5, 0,0, 0,0, -1,PromptHeight, 0,0, 0 ,255,True,AnimationStage>0)'KBText
Y3=Y2-Y-BarHeight-LCAR.LCARCornerElbow2.Height
Y2=Y+BarHeight+LCAR.LCARCornerElbow2.Height
'Y3=PromptHeight*2'-BarHeight*2
LCAR.LCAR_HideElement(BG,PromptID+4,False,False,True)
LCAR.ForceElementData(LCAR.KBCancelID+5, PromptWidth, Y2, 0, PromptHeight*2, -PromptWidth,Y3,0,0,0,255,True,DoAnimation)'Text
Else
LCAR.ForceElementData(PromptID+4, PromptWidth, Y+BarHeight+LCAR.LCARCornerElbow2.Height, 0, PromptHeight*2, -PromptWidth,18,0,0,0,255,True,DoAnimation)'Text
Y3=Y2+10'-lcar.KeyboardHeight -API.TextHeightAtHeight(BG, LCAR.LCARfont, "ABCDEFyqpjg", LCAR.BigTextboxHeight) '-50 + API.IIF(LCAR.SmallScreen, BarHeight,0) - 5
LCAR.ForceElementData(LCAR.KBCancelID+5, PromptWidth-LCAR.LCARCornerElbow2.Width+10, Y3, 0,-PromptHeight+BarHeight, Width2*2+LCAR.LCARCornerElbow2.Width*2-20, 40,0,0,0 ,255,True,AnimationStage>0)'KBText
End If
Else
Y3 = Y3 + Height
LCAR.ForceElementData(PromptID+6, PromptWidth+Width2+6,Y3, 0,-PromptHeight+BarHeight, -PromptWidth-3,Height, 0,0, 0,255,True, DoAnimation)' NO (right button)
LCAR.ForceElementData(PromptID+5, PromptWidth+3,Y3, 0,-PromptHeight+BarHeight, Width2, Height, 0,0, 0,255,True, DoAnimation)' OK (left button)
End If
LCAR.HideGroup(PromptGroup, True,False)
If DoAnimation Then
PromptQID=QuestionID
Text= API.TextWrap(BG, LCAR.LCARfont, 18, Text.ToUpperCase, Min(LCAR.ScaleWidth,LCAR.ScaleHeight)-PromptWidth*2 )
LCAR.LCAR_SetElementText(PromptID+1,Prompt.ToUpperCase, "")
If IsMultiline Then LCAR.LCAR_SetElementText(PromptID+4,"","") Else LCAR.LCAR_SetElementText(PromptID+4,"", Text.ToUpperCase & " ")
LCAR.LCAR_SetElementText(PromptID+6, RightBtn.ToUpperCase, "")
was2buttons=Prompt2Btns
If Prompt2Btns Then
LCAR.LCAR_SetElementText(PromptID+5, LeftBtnOPTIONAL.ToUpperCase , "")
'Else
' LCAR.LCAR_HideElement(BG,PromptID+5, False,False,True)
End If
LCAR.Stage=AnimationStage
End If
If Not (was2buttons) Then LCAR.LCAR_HideElement(BG,PromptID+5, False,False,True)
End Sub
Sub DrawBitmap(BG As Canvas, BMP As Bitmap, X As Int, Y As Int)
BG.DrawBitmap(BMP, Null, LCAR.SetRect( X - BMP.Width/2, Y - BMP.Height/2, BMP.Width, BMP.Height))
End Sub
Sub UniqueFilename(Dir As String, Filename As String, Append As String ) As String
Dim temp As Int ,Lindex As Int, Lpart As String , Rpart As String ,DT As Boolean
If Append.Length=0 Then
Append=" (#)"
Else If Append = "DATETIME" Then
DT = True
'1 space, 10 date, 1 space, 8 time, 20 total
Append = " " & DateTime.Date(DateTime.now).Replace("/", "-").Replace("\", "-") & " " & DateTime.Time(DateTime.now).Replace(":", "-")
End If
If File.Exists(Dir, Filename) OR DT Then
Lindex= Filename.LastIndexOf(".")
If Lindex=-1 Then
Lpart=Filename
Else
Lpart = Filename.SubString2(0,Lindex)
Rpart = Filename.SubString(Lindex)
End If
If DT Then
Return Lpart & Append & Rpart
Else
temp=1
Do Until Not( File.Exists(Dir, Lpart & Append.Replace("#", temp) & Rpart))
temp=temp+1
Loop
Return Lpart & Append.Replace("#", temp) & Rpart
End If
Else
Return Filename
End If
End Sub
Sub SaveScreenshot(BMP As Bitmap, Dir As String, FilenamePNG As String )As String
Dim Out As OutputStream
Try
FilenamePNG=UniqueFilename(Dir, FilenamePNG, "DATETIME")
Out = File.OpenOutput(Dir, FilenamePNG, False)
BMP.WriteToStream(Out, 100, "PNG")
Out.Close
Return Dir & "/" & FilenamePNG
Catch
Return ""
End Try
End Sub
Sub DrawBrackets(BG As Canvas, Left As Int, Top As Int, Width As Int, Height As Int, Color As Int, DoTop As Boolean)As Int
Dim LineThickness As Int,Left2 As Int
LineThickness=10
LCAR.ActivateAA(BG,True)
Left2=Left+Width-LineThickness
If DoTop Then
DrawPartOfCircle(BG, Left,Top,LineThickness,0, Color, 0,0)'left top corner
BG.DrawRect( LCAR.setrect(Left+LineThickness-1,Top,LineThickness*2,LineThickness), Color,True,0)'left top edge -
BG.DrawRect( LCAR.setrect(Left,Top+LineThickness-1,LineThickness,Height-LineThickness*2+2), Color,True,0)'left |
DrawPartOfCircle(BG, Left2,Top,LineThickness,1, Color, 0,0)'right top corner
BG.DrawRect( LCAR.setrect(Left2-LineThickness*2+1,Top,LineThickness*2,LineThickness), Color,True,0)'right top edge -
BG.DrawRect( LCAR.setrect(Left2,Top+LineThickness-1,LineThickness,Height-LineThickness*2+2), Color,True,0)'right |
Else
BG.DrawRect( LCAR.setrect(Left,Top,LineThickness,Height-LineThickness+1), Color,True,0)'left |
BG.DrawRect( LCAR.setrect(Left2,Top,LineThickness,Height-LineThickness+1), Color,True,0)'right |
End If
BG.DrawRect( LCAR.setrect(Left+LineThickness-1,Top+Height-LineThickness,LineThickness*2,LineThickness), Color,True,0)'left bottom edge
BG.DrawRect( LCAR.setrect(Left2-LineThickness*2+1,Top+Height-LineThickness,LineThickness*2,LineThickness), Color,True,0)'right bottom edge -
DrawPartOfCircle(BG, Left,Top+Height-LineThickness,LineThickness,2, Color, 0,0)'left bottom corner
DrawPartOfCircle(BG, Left2,Top+Height-LineThickness,LineThickness,3, Color, 0,0)'right bottom corner
LCAR.ActivateAA(BG,False)
Return LineThickness
End Sub
Sub DrawPartOfCircle(BG As Canvas , X As Int, Y As Int, Radius As Int, Section As Int, Color As Int , Left As Int, Top As Int)
Dim P As Path
P.Initialize(X,Y)
P.LineTo(X+Radius-1,Y)
P.LineTo(X+Radius-1,Y+Radius-1)
P.LineTo(X, Y+Radius-1)
P.LineTo(X,Y)
BG.ClipPath(P)
Select Case Section
Case 0:BG.DrawCircle(X+Radius,Y+Radius, Radius,Color,True,0) 'top left
Case 1:BG.DrawCircle(X,Y+Radius, Radius,Color,True,0) 'top right
Case 2:BG.DrawCircle(X+Radius,Y, Radius,Color,True,0) 'bottom left
Case 3:BG.DrawCircle(X,Y, Radius,Color,True,0) 'bottom right
Case 4: Radius=Radius*0.5:BG.DrawCircle(X+Radius, Y+Radius, Radius, Color,True,0)'left
Case 5: Radius=Radius*0.5:BG.DrawCircle(X, Y+Radius, Radius, Color,True,0) 'right
Case 6'top
Case 7'bottom
End Select
BG.RemoveClip
End Sub
Sub DrawArc(cnvs As Canvas, x As Float, y As Float, radius As Float, startAngle As Float, endAngle As Float, Color As Int)
Dim s As Float
s = startAngle
startAngle = 180 - endAngle
endAngle = 180 - s
If startAngle >= endAngle Then endAngle = endAngle + 360
Dim p As Path
p.Initialize(x, y)
For i = startAngle To endAngle Step 10
p.LineTo(x + 2 * radius * SinD(i), y + 2 * radius * CosD(i))
Next
p.LineTo(x + 2 * radius * SinD(endAngle), y + 2 * radius * CosD(endAngle))
p.LineTo(x, y)
cnvs.ClipPath(p) 'We are limiting the drawings to the required slice
cnvs.DrawCircle(x, y, radius, Color, True, 0)
cnvs.RemoveClip
End Sub
Sub SetPoint(X As Int, Y As Int) As Point
Dim temp As Point
temp.Initialize
temp.X=X
temp.Y=Y
Return temp
End Sub
Sub CacheAngles(RadiusTimes2 As Int, Angle As Int)As Point
Dim temp As Int ,res As Point
If RadiusTimes2>0 Then
If Not(CachedAngles.IsInitialized) OR (CachedRadius < RadiusTimes2) Then
CachedAngles.Initialize
For temp =0 To 359
CachedAngles.Add( Trig.FindAnglePoint(0,0,RadiusTimes2,temp) )
Next
CachedRadius=RadiusTimes2
'For temp =0 To 359
' res=CachedAngles.Get(temp)
' Log("CHECKING: " & temp & " X: " & res.X & " Y: " & res.Y)
'Next
End If
End If
If Angle>-1 Then
Angle=Trig.CorrectAngle( Angle)
res= CachedAngles.Get(Angle)
'res.X= X + res.x 'NOT WORKING
'res.y= Y + res.y 'NOT WORKING
Return res
End If
End Sub
Sub DrawDpad(BG As Canvas, X As Int, Y As Int, Radius As Int, ColorID As Int, InnerRadius As Int, InnerColorID As Int, Border As Int, Alpha As Int,BlinkState As Boolean, Direction As Int)
Dim P As Path , Left As Int , MiddleLeft As Int,MiddleRight As Int, Right As Int , Top As Int , Bottom As Int , MiddleTop As Int, MiddleBottom As Int, Color As Int,temp As Int
Left= X-Radius
MiddleLeft=X-InnerRadius+1
MiddleRight=X+InnerRadius-1
Right= X+Radius
Top=Y-Radius
MiddleTop=Y-InnerRadius+1
MiddleBottom=Y+InnerRadius-1
Bottom=Y+Radius
LCAR.ActivateAA(BG, True)
Color=LCAR.GetColor (ColorID, False, Alpha)
BG.DrawCircle(X,Y, Radius, Color, True, 0)
LCAR.ActivateAA(BG, False)
'bg.DrawRect( lcar.SetRect(x-radius,y-InnerRadius-Border, radius*2, (Border+InnerRadius)*2), Colors.Black, True, 0)'internal + black -
'bg.DrawRect( lcar.SetRect(x-InnerRadius-Border,y-radius, (Border+InnerRadius)*2, radius*2), Colors.Black, True, 0)'internal + black |
P.Initialize(Left, MiddleTop)'top left corner along left edge
P.LineTo(MiddleLeft,MiddleTop)'top left corner inside
P.LineTo(MiddleLeft,Top)'top left corner along top edge
P.LineTo(MiddleRight, Top)'top right corner along top edge
P.LineTo(MiddleRight,MiddleTop)'top right corner inside
P.LineTo(Right, MiddleTop)'top right corner along right edge
P.LineTo(Right, MiddleBottom)'bottom right corner along right edge
P.LineTo(MiddleRight,MiddleBottom)'bottom right corner inside
P.LineTo(MiddleRight, Bottom)'bottom right corner along bottom edge
P.LineTo(MiddleLeft,Bottom)'bottom left corner along bottom edge
P.LineTo(MiddleLeft,MiddleBottom)'bottom left corner inside
P.LineTo(Left,MiddleBottom)'bottom left corner along left edge
P.LineTo(Left, MiddleTop)'top left corner along left edge (start)
BG.ClipPath(P)
BG.DrawCircle(X,Y,Radius, LCAR.GetColor (InnerColorID, False, Alpha), True,0)
BG.RemoveClip
BG.DrawLine(Left, MiddleTop, Right, MiddleTop, Colors.Black ,Border)
BG.DrawLine(Left, MiddleBottom, Right, MiddleBottom, Colors.Black ,Border)
BG.DrawLine(MiddleLeft, Top, MiddleLeft, Bottom, Colors.Black ,Border)
BG.DrawLine(MiddleRight, Top, MiddleRight, Bottom, Colors.Black ,Border)
BG.DrawRect( LCAR.SetRect(X - Radius*0.5 - InnerRadius, MiddleTop, InnerRadius, InnerRadius*2), Colors.Black, True,0)'left
temp=X - Radius*0.5 - InnerRadius+Border
DrawTriangle(BG, temp+Border, MiddleTop+Border*2, InnerRadius - Border*4, InnerRadius*2 - Border*4, 2, Color)
BG.DrawLine(temp+Border, MiddleBottom+Border*2 , temp+ InnerRadius - Border*4 , MiddleBottom+Border*2 , Colors.black,Border)'-
BG.DrawRect( LCAR.SetRect(X + Radius*0.5+1 , MiddleTop, InnerRadius, InnerRadius*2), Colors.Black, True,0)'right
temp=X + Radius*0.5 +Border+1
DrawTriangle(BG, temp+Border, MiddleTop+Border*2, InnerRadius - Border*4, InnerRadius*2 - Border*4, 3, Color)
BG.DrawLine(temp+Border, MiddleTop-Border*2 , temp+ InnerRadius - Border*4 , MiddleTop-Border*2 , Colors.black,Border)'-
BG.DrawRect( LCAR.SetRect(MiddleLeft , Y - Radius*0.5 - InnerRadius , InnerRadius*2, InnerRadius), Colors.Black, True,0)'top
temp=Y-InnerRadius*1.5
BG.DrawLine(MiddleLeft,temp, MiddleRight, temp, Colors.black,Border)'|
DrawTriangle(BG,MiddleLeft+Border*2, Y - Radius*0.5 - InnerRadius+Border*2, InnerRadius*2 - Border*4,InnerRadius - Border*4, 1, Color)
BG.DrawRect( LCAR.SetRect(MiddleLeft , Y + Radius*0.5+1 , InnerRadius*2, InnerRadius), Colors.Black, True,0)'bottom
DrawTriangle(BG,MiddleLeft+Border*2, Y + Radius*0.5 +Border*2 +1, InnerRadius*2 - Border*4,InnerRadius - Border*4, 4, Color)
End Sub
Sub DrawTriangle(BG As Canvas, X As Int, Y As Int, Width As Int, Height As Int, Alignment As Int, Color As Int)
Dim P As Path, Right As Int, Bottom As Int, MiddleX As Int, MiddleY As Int
Select Case Alignment
Case 1,4'horizontal, width=height*2
MiddleX=Height*2
X=X+ (Width-MiddleX)/2
Width= MiddleX
Case Else'vertical, height=width*2
MiddleX=Width*2
Y=Y+ (Height-MiddleX)/2
Height= MiddleX
End Select
Right=X+Width-1
Bottom=Y+Height-1
MiddleX=X+(Width*0.5)-1
MiddleY=Y+(Height*0.5)
Select Case Alignment
Case 1'North
P.Initialize(X, Bottom)
P.LineTo(Right,Bottom)
P.LineTo(MiddleX, Y)
P.LineTo(X, Bottom)
Case 2'west
P.Initialize(Right,Y)
P.Initialize(Right,Bottom)
P.LineTo(X, MiddleY)
P.LineTo(Right,Y)
Case 3'east
P.Initialize(X,Y)
P.LineTo(X,Bottom)
P.LineTo(Right, MiddleY)
P.LineTo(X,Y)
Case 4'south
P.Initialize(X,Y)
P.LineTo(MiddleX,Bottom)
P.LineTo(Right,Y)
P.LineTo(X,Y)
End Select
BG.clippath(P)
If Color <> LCAR.LCAR_Clear Then
BG.drawrect(LCAR.SetRect(X,Y,Width,Height), Color,True,0)
BG.RemoveClip
End If
End Sub
Sub DrawCircleSegment(BG As Canvas, X As Int, Y As Int,StartRadius As Int, EndRadius As Int, StartAngle As Int, Degrees As Int, Color As Int, Stroke As Int, EndType As Int, RoundEndAngle As Int )
Dim X1 As Int, X2 As Int, Y1 As Int, Y2 As Int, X3 As Int, Y3 As Int, P As Path,temp As Int,EndAngle As Int, RadiusDelta As Int,RadiusDelta2 As Int,temp2 As Point
EndAngle=Trig.CorrectAngle(StartAngle+Degrees-RoundEndAngle)
StartAngle = Trig.CorrectAngle( StartAngle+RoundEndAngle)
temp2=CacheAngles(0,StartAngle)
X1=temp2.X + X
Y1=temp2.Y + Y
temp2=CacheAngles(0,EndAngle)
X2=temp2.X + X
Y2=temp2.Y + Y
'X1= Trig.findXYAngle(X,Y, EndRadius*2, StartAngle , True)
'Y1= Trig.findXYAngle(X,Y, EndRadius*2, StartAngle, False)
'X2= Trig.findXYAngle(X,Y, EndRadius*2, EndAngle, True)
'Y2= Trig.findXYAngle(X,Y, EndRadius*2, EndAngle, False)
If Degrees<360 Then
P.Initialize(X, Y)'center/origin
P.LineTo(X1,Y1)'start angle @ radius
'P.Initialize(X1,Y1)'start angle @ radius
'If StartRadius=0 Then
' P.LineTo(X,Y)'center/origin
'Else
'For temp = StartAngle To EndAngle' Step 10
' P.LineTo( Trig.findXYAngle(X,Y,StartRadius, temp, True), Trig.findXYAngle(X,Y,StartRadius, temp, False) )
'Next
'End If
P.LineTo(X2,Y2)'end angle @ radius
'P.LineTo(X1,Y1)'start angle @ radius
P.LineTo(X,Y)'center/origin
BG.ClipPath(P)
End If
temp=(EndRadius-StartRadius)
'BG.DrawCircle(0,0, StartRadius + temp *0.5, Color, False, temp)
BG.DrawCircle(X,Y, StartRadius + temp *0.5, Color, False, temp)
'BG.DrawCircle(X,Y,EndRadius, Color, Stroke=0, Stroke)
If Degrees<360 Then BG.RemoveClip
Select Case EndType
Case 1'curved
RadiusDelta2= ( (EndRadius-StartRadius) /2 )
RadiusDelta=StartRadius + RadiusDelta2
BG.DrawCircle( Trig.findXYAngle(X,Y,RadiusDelta,StartAngle, True), Trig.findXYAngle(X,Y,RadiusDelta,StartAngle, False),RadiusDelta2, Color, True, 0)
BG.DrawCircle( Trig.findXYAngle(X,Y,RadiusDelta,EndAngle, True), Trig.findXYAngle(X,Y,RadiusDelta,EndAngle, False),RadiusDelta2, Color, True, 0)
Case 2'lines
DrawLine(BG, X,Y, StartAngle, StartRadius, EndRadius, Color, Stroke)
DrawLine(BG, X,Y, EndAngle, StartRadius, EndRadius, Color, Stroke)
End Select
End Sub
Sub DrawLine(BG As Canvas, X As Int, Y As Int, Angle As Int, StartRadius As Int, EndRadius As Int, Color As Int, Stroke As Int)As Rect
Dim X1 As Int, Y1 As Int,X2 As Int, Y2 As Int,temp As Rect
If StartRadius=0 Then
X1=X
Y1=Y
Else
X1=Trig.findXYAngle(X,Y,StartRadius,Angle, True)
Y1=Trig.findXYAngle(X,Y,StartRadius,Angle, False)
End If
X2=Trig.findXYAngle(X,Y,EndRadius,Angle, True)
Y2=Trig.findXYAngle(X,Y,EndRadius,Angle, False)
BG.DrawLine(X1, Y1, X2,Y2, Color, Stroke)
temp.Initialize(X1,Y1,X2,Y2)
Return temp
End Sub
Sub DrawAlert(BG As Canvas, X As Int, Y As Int, Radius As Int, StatusMode As Int, Stage As Int, Alpha As Int, TextSize As Int, Text As String, Status As String )As Int
Dim Color As Int , P As Path, OneThird As Double, Points(11) As Int, CLR As LCARColor , temp As Int,Alpha2 As Int, Y2 As Int, Y3 As Int,X2 As Int,Angle As Int
Dim Width As Int,textsize2 As Int, CLR2 As ColorDrawable
OneThird=1/3
If Not(LCARSeffects2.StarshipFont.IsInitialized ) Then LCARSeffects2.StarshipFont=Typeface.LoadFromAssets("federation.ttf")
'If Not(StarshipFont.IsInitialized ) Then StarshipFont= LCAR.LCARfont
If Stage<0 Then
Stage=Stage+Stage
Else
BG.drawrect(LCAR.SetRect(X-Radius,Y-Radius,Radius*2,Radius*2), Colors.Black, True,0)