-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui_debug.bas
3078 lines (2805 loc) · 101 KB
/
gui_debug.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
GUI_FONT = 0
GUI_FONT_COLOR = RGB(20,20,20)
Dim GUI_FONT_W
Dim GUI_FONT_H
Dim GUI_SCROLLDOWN_IMAGE
Dim GUI_SCROLLUP_IMAGE
Dim GUI_PAGEDOWN_IMAGE
Dim GUI_PAGEUP_IMAGE
GUI_DRAW_COLOR = 0
GUI_TMP_CANVAS = 0
GUI_WIN_CANVAS = 1
GUI_SURFACE_CANVAS = 2
MAX_GUI_ELEMENTS = 800
MAX_WINDOWS = 8
MAX_PANELS = 100
MAX_PANEL_OBJECTS = 50
MAX_TAB_GROUPS = 50
MAX_TABS = 20
MAX_TAB_OBJECTS = 20
MAX_BUTTONS = 100
MAX_DROPDOWNS = 30
MAX_DROPDOWN_VALUES = 20
MAX_LISTBOXES =100
MAX_LISTBOX_VALUES = 1024
MAX_TEXTFIELDS = 100
MAX_CHECKBOXES = 100
MAX_LABELS = 200
MAX_IMAGECLIPS = 100
MAX_IMAGESLIDES = 100
MAX_IMAGESLIDE_CLIPS = 100
MAX_IMAGES = 1024
MAX_SURFACES = 50
'MOUSE STATE
MOUSE_STATE = 0
MOUSE_PRESSED = 1
MOUSE_HOLD = 2
MOUSE_RELEASED = 3
'EVENTS
EVENT_ID = 0
EVENT_TYPE = 0
BUTTON_PRESSED = 1
BUTTON_RELEASED = 2
TAB_SWITCH = 3
DROPDOWN_PRESSED = 4
DROPDOWN_RELEASED = 5
LISTBOX_SCROLLUP_PRESSED = 6
LISTBOX_SCROLLUP_RELEASED = 7
LISTBOX_SCROLLDOWN_PRESSED = 8
LISTBOX_SCROLLDOWN_RELEASED = 9
LISTBOX_PAGEUP_PRESSED = 10
LISTBOX_PAGEUP_RELEASED = 11
LISTBOX_PAGEDOWN_PRESSED = 12
LISTBOX_PAGEDOWN_RELEASED = 13
LISTBOX_ITEM_SELECT = 14
TEXTFIELD_PRESSED = 15
TEXTFIELD_RELEASED = 16
TEXTFIELD_RETURN = 17
CHECKBOX_PRESSED = 18
CHECKBOX_RELEASED = 19
IMAGECLIP_PRESSED = 20
IMAGECLIP_RELEASED = 21
IMAGESLIDE_PRESSED = 22
IMAGESLIDE_RELEASED = 23
SURFACE_PRESSED = 24
SURFACE_RELEASED = 25
'GUI STATE
GUI_STATE = 0
GUI_STATE_DROPDOWN_OPEN = 1
GUI_STATE_TEXTFIELD_EDIT = 2
'Gui
GUI_TYPE_PANEL = 1
GUI_TYPE_BUTTON = 2
GUI_TYPE_TAB = 3
GUI_TYPE_DROPDOWN = 4
GUI_TYPE_LISTBOX = 5
GUI_TYPE_TEXTFIELD = 6
GUI_TYPE_CHECKBOX = 7
GUI_TYPE_LABEL = 8
GUI_TYPE_IMAGECLIP = 9
GUI_TYPE_IMAGESLIDE = 10
GUI_TYPE_SURFACE = 11
Dim Gui_Element_Index[MAX_GUI_ELEMENTS]
Dim Gui_Element_Type[MAX_GUI_ELEMENTS]
Dim Gui_Element_Active[MAX_GUI_ELEMENTS]
Dim Gui_Element_Exists[MAX_GUI_ELEMENTS]
Dim Gui_Element_Parent[MAX_GUI_ELEMENTS]
Dim Gui_Element_Window[MAX_GUI_ELEMENTS]
'Window
CURRENT_WINDOW = 0
GUI_CLEAR_COLOR = rgb(140,140,140)
SetClearColor(GUI_CLEAR_COLOR)
Dim Gui_Window_Exists[MAX_WINDOWS]
Dim Gui_Window_Panel_ID[MAX_WINDOWS, MAX_PANELS]
Dim Gui_Window_Panel_Exists[MAX_WINDOWS, MAX_PANELS]
Dim Gui_Window_Panel_Type[MAX_WINDOWS, MAX_PANELS]
Dim Gui_Window_Width[MAX_WINDOWS]
Dim Gui_Window_Height[MAX_WINDOWS]
'Panel
PANEL_BKG_TYPE_COLOR = 0
PANEL_BKG_TYPE_IMAGE = 1
PANEL_BKG_TYPE = 0
PANEL_BKG_VALUE = RGB(110,110,110)
Dim Gui_Panel_Exists[MAX_PANELS]
Dim Gui_Panel_isActive[MAX_PANELS]
Dim Gui_Panel_X[MAX_PANELS]
Dim Gui_Panel_Y[MAX_PANELS]
Dim Gui_Panel_W[MAX_PANELS]
Dim Gui_Panel_H[MAX_PANELS]
Dim Gui_Panel_Image[MAX_PANELS]
Dim Gui_Panel_Object_ID[MAX_PANELS, MAX_PANEL_OBJECTS]
Dim Gui_Panel_Object_Type[MAX_PANELS, MAX_PANEL_OBJECTS]
Dim Gui_Panel_Object_Exists[MAX_PANELS, MAX_PANEL_OBJECTS]
'Tab Switcher
GUI_TAB_COLOR1 = RGB(128,128,128)
GUI_TAB_COLOR2 = RGB(96,96,96)
GUI_TAB_BORDER_COLOR = RGB(160,160,160)
Dim Gui_TabGroup_Parent[MAX_TAB_GROUPS]
Dim Gui_TabGroup_Exists[MAX_TAB_GROUPS]
Dim Gui_TabGroup_X[MAX_TAB_GROUPS]
Dim Gui_TabGroup_Y[MAX_TAB_GROUPS]
Dim Gui_TabGroup_W[MAX_TAB_GROUPS]
Dim Gui_TabGroup_H[MAX_TAB_GROUPS]
Dim Gui_TabGroup_ActiveTab[MAX_TAB_GROUPS]
Dim Gui_TabGroup_Tab_Object_ID[MAX_TAB_GROUPS, MAX_TABS, MAX_TAB_OBJECTS]
Dim Gui_TabGroup_Tab_Object_Type[MAX_TAB_GROUPS, MAX_TABS, MAX_TAB_OBJECTS]
Dim Gui_TabGroup_Tab_Object_Exists[MAX_TAB_GROUPS, MAX_TABS, MAX_TAB_OBJECTS]
Dim Gui_TabGroup_Tab_Exists[MAX_TAB_GROUPS, MAX_TABS]
Dim Gui_TabGroup_Tab_Image[MAX_TAB_GROUPS, MAX_TABS, 2]
Dim Gui_TabGroup_Tab_Title$[MAX_TAB_GROUPS, MAX_TABS]
Dim Gui_TabGroup_TabCount[MAX_TAB_GROUPS]
'Button
GUI_BUTTON_COLOR1 = RGB(120, 120, 120)
GUI_BUTTON_COLOR2 = RGB(84, 84, 84)
Dim Gui_Button_Panel[MAX_BUTTONS]
Dim Gui_Button_Exists[MAX_BUTTONS]
Dim Gui_Button_X[MAX_BUTTONS]
Dim Gui_Button_Y[MAX_BUTTONS]
Dim Gui_Button_W[MAX_BUTTONS]
Dim Gui_Button_H[MAX_BUTTONS]
Dim Gui_Button_Image[MAX_BUTTONS,2]
Dim Gui_Button_Current_Image[MAX_BUTTONS]
'DropDown
GUI_DROPDOWN_COLOR1 = RGB(120, 120, 120)
GUI_DROPDOWN_COLOR2 = RGB(80, 80, 80)
GUI_DROPDOWN_BORDER_COLOR = RGB(100,100,100)
GUI_DROPDOWN_HIGHLIGHT_COLOR = RGBA(0,180,228,20)
Dim GUI_DROPDOWN_MIN_W
Dim GUI_DROPDOWN_MIN_H
Dim Gui_DropDown_Panel[MAX_DROPDOWNS]
Dim Gui_DropDown_Exists[MAX_DROPDOWNS]
Dim Gui_DropDown_X[MAX_DROPDOWNS]
Dim Gui_DropDown_Y[MAX_DROPDOWNS]
Dim Gui_DropDown_W[MAX_DROPDOWNS]
Dim Gui_DropDown_H[MAX_DROPDOWNS]
Dim Gui_DropDown_Image[MAX_DROPDOWNS, 3]
Dim Gui_DropDown_Current_Image[MAX_DROPDOWNS]
Dim Gui_DropDown_Value$[MAX_DROPDOWNS, MAX_DROPDOWN_VALUES]
Dim Gui_DropDown_Count[MAX_DROPDOWNS]
Dim Gui_DropDown_Selected_Item[MAX_DROPDOWNS]
Dim Gui_DropDown_Highlighted_X
Dim Gui_DropDown_Highlighted_Y
Dim Gui_DropDown_Highlighted_Index
'ListBox
GUI_LISTBOX_COLOR1 = RGB(160, 160, 160)
GUI_LISTBOX_COLOR2 = RGB(90, 90, 90)
GUI_LISTBOX_COLOR3 = RGB(64, 64, 64)
GUI_LISTBOX_BORDER_COLOR = RGB(100,100,100)
GUI_LISTBOX_HIGHLIGHT_COLOR = RGB(0,0,160)
Dim GUI_LISTBOX_MIN_W
Dim GUI_LISTBOX_MIN_H
Dim Gui_ListBox_Panel[MAX_LISTBOXES]
Dim Gui_ListBox_Exists[MAX_LISTBOXES]
Dim Gui_ListBox_X[MAX_LISTBOXES]
Dim Gui_ListBox_Y[MAX_LISTBOXES]
Dim Gui_ListBox_W[MAX_LISTBOXES]
Dim Gui_ListBox_H[MAX_LISTBOXES]
Dim Gui_ListBox_Image[MAX_LISTBOXES]
Dim Gui_ListBox_Value$[MAX_LISTBOXES, MAX_LISTBOX_VALUES]
Dim Gui_ListBox_Count[MAX_LISTBOXES]
Dim Gui_ListBox_Selected_Item[MAX_LISTBOXES]
Dim Gui_ListBox_Offset[MAX_LISTBOXES]
Dim Gui_ListBox_ScrollBar_Image[MAX_LISTBOXES, 8]
Dim Gui_ListBox_ScrollBar_Action[4]
Dim Gui_ListBox_ScrollBar_Pressed[4]
Dim Gui_ListBox_ScrollBar_Hover[4]
Dim Gui_ListBox_Highlighted_X
Dim Gui_ListBox_Highlighted_Y
Dim Gui_ListBox_Highlighted_Index
'TextField
GUI_TEXTFIELD_COLOR1 = RGB(180, 180, 180)
GUI_TEXTFIELD_BORDER_COLOR = RGB(64, 64, 64)
Dim GUI_TEXTFIELD_MIN_W
Dim GUI_TEXTFIELD_MIN_H
Dim Gui_TextField_Panel[MAX_TEXTFIELDS]
Dim Gui_TextField_Exists[MAX_TEXTFIELDS]
Dim Gui_TextField_X[MAX_TEXTFIELDS]
Dim Gui_TextField_Y[MAX_TEXTFIELDS]
Dim Gui_TextField_W[MAX_TEXTFIELDS]
Dim Gui_TextField_H[MAX_TEXTFIELDS]
Dim Gui_TextField_Image[MAX_TEXTFIELDS]
Dim Gui_TextField_Value$[MAX_TEXTFIELDS]
Dim Gui_TextField_Offset[MAX_TEXTFIELDS]
'CheckBox
GUI_CHECKBOX_COLOR1 = RGB(140, 140, 140)
GUI_CHECKBOX_COLOR2 = RGB(100, 100, 100)
GUI_CHECKBOX_CHECK_COLOR = RGB(0, 150, 0)
GUI_CHECKBOX_BORDER_COLOR = RGB(64, 64, 64)
Dim Gui_CheckBox_Panel[MAX_CHECKBOXES]
Dim Gui_CheckBox_Exists[MAX_CHECKBOXES]
Dim Gui_CheckBox_X[MAX_CHECKBOXES]
Dim Gui_CheckBox_Y[MAX_CHECKBOXES]
Dim Gui_CheckBox_W[MAX_CHECKBOXES]
Dim Gui_CheckBox_H[MAX_CHECKBOXES]
Dim Gui_CheckBox_Image[MAX_CHECKBOXES,3]
Dim Gui_CheckBox_Current_Image[MAX_CHECKBOXES]
Dim Gui_CheckBox_Value[MAX_CHECKBOXES]
'Label
Dim Gui_Label_Panel[MAX_LABELS]
Dim Gui_Label_Exists[MAX_LABELS]
Dim Gui_Label_X[MAX_LABELS]
Dim Gui_Label_Y[MAX_LABELS]
Dim Gui_Label_W[MAX_LABELS]
Dim Gui_Label_H[MAX_LABELS]
Dim Gui_Label_Image[MAX_LABELS]
'ImageClip
Dim Gui_ImageClip_Panel[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Exists[MAX_IMAGECLIPS]
Dim Gui_ImageClip_X[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Y[MAX_IMAGECLIPS]
Dim Gui_ImageClip_W[MAX_IMAGECLIPS]
Dim Gui_ImageClip_H[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Image[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Source_Image[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Source_X[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Source_Y[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Source_W[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Source_H[MAX_IMAGECLIPS]
Dim Gui_ImageClip_Stretched[MAX_IMAGECLIPS]
'ImageSlide
GUI_IMAGESLIDE_BORDER_COLOR = RGB(80, 80, 80)
GUI_IMAGESLIDE_COLOR = RGB( 128, 128, 128)
GUI_IMAGESLIDE_HIGHLIGHT_COLOR = RGB(255, 0, 0)
Dim Gui_ImageSlide_Panel[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Exists[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_X[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Y[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_W[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_H[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_ImageClip[MAX_IMAGESLIDES, MAX_IMAGESLIDE_CLIPS]
Dim Gui_ImageSlide_SelectedClip[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Count[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Image[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_ImageClip_W[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_ImageClip_H[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Offset_X[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Offset_Y[MAX_IMAGESLIDES]
Dim Gui_ImageSlide_Hover
'Surface
Dim GUI_ACTIVE_SURFACE
GUI_SURFACE_CMD_DRAWIMAGE = 1
GUI_SURFACE_CMD_DRAWIMAGE_EX = 2
GUI_SURFACE_CMD_DRAWIMAGE_ROTATE = 3
GUI_SURFACE_CMD_DRAWIMAGE_ROTATE_EX = 4
GUI_SURFACE_CMD_DRAWIMAGE_ZOOM = 5
GUI_SURFACE_CMD_DRAWIMAGE_ZOOM_EX = 6
GUI_SURFACE_CMD_DRAWIMAGE_BLIT = 7
GUI_SURFACE_CMD_DRAWIMAGE_BLIT_EX = 8
GUI_SURFACE_CMD_DRAWIMAGE_FLIP = 9
GUI_SURFACE_CMD_DRAWIMAGE_FLIP_EX = 10
GUI_SURFACE_CMD_DRAWIMAGE_ROTOZOOM = 11
GUI_SURFACE_CMD_DRAWIMAGE_ROTOZOOM_EX = 12
GUI_SURFACE_CMD_PSET = 13
GUI_SURFACE_CMD_LINE = 14
GUI_SURFACE_CMD_BOX = 15
GUI_SURFACE_CMD_BOXFILL = 16
GUI_SURFACE_CMD_RECT = 17
GUI_SURFACE_CMD_RECTFILL = 18
GUI_SURFACE_CMD_CIRCLE = 19
GUI_SURFACE_CMD_CIRCLEFILL = 20
GUI_SURFACE_CMD_ELLIPSE = 21
GUI_SURFACE_CMD_ELLIPSEFILL = 22
GUI_SURFACE_CMD_CLEAR = 23
GUI_SURFACE_CMD_FLOODFILL = 24
GUI_SURFACE_CMD_SETCLEARCOLOR = 25
GUI_SURFACE_CMD_SETCOLOR = 26
GUI_SURFACE_CLEAR_COLOR = RGB(0, 0, 0)
GUI_SURFACE_BORDER_COLOR = RGB(80, 80, 80)
Dim Gui_Surface_Panel[MAX_SURFACES]
Dim Gui_Surface_Exists[MAX_SURFACES]
Dim Gui_Surface_X[MAX_SURFACES]
Dim Gui_Surface_Y[MAX_SURFACES]
Dim Gui_Surface_W[MAX_SURFACES]
Dim Gui_Surface_H[MAX_SURFACES]
Dim Gui_Surface_Image[MAX_SURFACES]
Dim Gui_Surface_MouseX[MAX_SURFACES]
Dim Gui_Surface_MouseY[MAX_SURFACES]
Dim Gui_Surface_DrawCommand[MAX_SURFACES, 2048, 16]
Dim Gui_Surface_NumCommands[MAX_SURFACES]
Sub Gui_Init()
'Initialization Code For Gui System
For i = 0 to MAX_GUI_ELEMENTS-1
Gui_Element_Exists[i] = False
Gui_Element_Parent[i] = i
Gui_Element_Window[i] = 0
Gui_Element_Active[i] = False
Gui_Element_Index[i] = 0
Gui_Element_Type[i] = 0
Next
For i = 0 to MAX_WINDOWS-1
For j = 0 to MAX_PANELS-1
Gui_Window_Panel_Exists[i,J] = False
Next
Next
For i = 0 to MAX_PANELS-1
Gui_Panel_Exists[i] = False
Gui_Panel_isActive[i] = False
For j = 0 to MAX_PANEL_OBJECTS-1
Gui_Panel_Object_Exists[i, j] = False
Next
Next
Gui_Button_Exists[0] = True 'This is a simple fix to a bug with the first button created
For i = 1 to MAX_BUTTONS-1
Gui_Button_Exists[i] = False
Gui_Button_Current_Image[i] = 0
Next
For i = 0 to MAX_DROPDOWNS-1
Gui_DropDown_Exists[i] = False
Next
For i = 0 to MAX_LISTBOXES-1
Gui_ListBox_Exists[i] = False
Next
For i = 0 to MAX_TEXTFIELDS-1
Gui_TextField_Exists[i] = False
Next
If OS = "WINDOWS" Then
LoadFont(GUI_FONT, Dir+"\\font\\FreeMono.TTF", 12)
Else
LoadFont(GUI_FONT, Dir+"/font/FreeMono.ttf", 12)
End If
GetTextSize(GUI_FONT, "A", GUI_FONT_W, GUI_FONT_H)
GUI_DROPDOWN_MIN_W = GUI_FONT_W + 4
GUI_DROPDOWN_MIN_H = GUI_FONT_H + 4
GUI_LISTBOX_MIN_W = GUI_FONT_W + 4
GUI_LISTBOX_MIN_H = GUI_FONT_H + 4
GUI_TEXTFIELD_MIN_W = GUI_FONT_W + 4
GUI_TEXTFIELD_MIN_H = GUI_FONT_H + 4
GUI_PAGEUP_IMAGE = 0
GUI_SCROLLUP_IMAGE = 1
GUI_SCROLLDOWN_IMAGE = 2
GUI_PAGEDOWN_IMAGE = 3
End Sub
Function Gui_GetFreeID()
For i = 0 to MAX_GUI_ELEMENTS-1
If Not Gui_Element_Exists[i] Then
Return i
End If
Next
Return -1
End Function
Function Gui_WindowOpen(title$, x, y, w, h)
For i = 0 to MAX_WINDOWS-1
If Not WindowExists(i) Then
current_win = ActiveWindow
WindowOpen(i, title$, x, y, w, h, 0)
Window(i)
Cls
CanvasOpen(GUI_TMP_CANVAS, w, h, 0, 0, w, h, 0)
CanvasOpen(GUI_WIN_CANVAS, w, h, 0, 0, w, h, 1)
SetCanvasVisible(GUI_TMP_CANVAS, False)
If current_win >= 0 And current_win < MAX_WINDOWS Then
Window(current_win)
End If
EVENT_TYPE = 0
EVENT_ID = 0
Return i
End If
Next
Return -1
End Function
Sub Gui_WindowClose(win_id)
If ActiveWindow = win_id Then
For i = 0 to MAX_WINDOWS-1
If WindowExists(i) And i <> win_id Then
Window(i)
Exit For
End If
Next
End If
WindowClose(win_id)
End Sub
Function Gui_GetFreeImage()
For i = 20 to MAX_IMAGES-1
If Not ImageExists(i) Then
Return i
End If
Next
Return -1
End Function
Function Gui_LoadImage(img_file$)
img = Gui_GetFreeImage
If img >= 0 Then
LoadImage(img, img_file$)
If ImageExists(img) Then
Return img
End If
End If
Return -1
End Function
Function Gui_CreateEmptyImage(w, h)
Dim buf[w*h]
img = Gui_GetFreeImage
ImageFromBuffer(img, w, h, buf)
Return img
End Function
Sub Gui_SetPanelActive(panel, flag)
panel_index = Gui_Element_Index[panel]
Gui_Element_Active[panel] = flag
For i = 0 to MAX_PANEL_OBJECTS-1
If Gui_Panel_Object_Exists[panel_index, i] Then
Gui_Element_Active[ Gui_Panel_Object_ID[panel_index, i] ] = flag
End If
Next
End Sub
Sub Gui_SetTabGroupActive(id, flag)
tab_index = Gui_Element_Index[id]
Gui_Element_Active[id] = flag
If flag = False Then
For tab = 0 to Gui_TabGroup_TabCount[tab_index]-1
For i = 0 to MAX_TAB_OBJECTS-1
If Gui_TabGroup_Tab_Object_Exists[tab_index, tab, i] Then
Gui_Element_Active[ Gui_TabGroup_Tab_Object_ID[tab_index, tab, i] ] = False
End If
Next
Next
Else
tab = Gui_TabGroup_ActiveTab[tab_index]
For i = 0 to MAX_TAB_OBJECTS-1
If Gui_TabGroup_Tab_Object_Exists[tab_index, tab, i] Then
Gui_Element_Active[ Gui_TabGroup_Tab_Object_ID[tab_index, tab, i] ] = True
End If
Next
End If
End Sub
Function Gui_Window_AddTabGroup(win, tab_group, x, y)
tab_index = Gui_Element_Index[tab_group]
For i = 0 to MAX_PANELS-1
If Not Gui_Window_Panel_Exists[win, i] Then
Gui_Window_Panel_Exists[win, i] = True
Gui_Window_Panel_Type[win, i] = GUI_TYPE_TAB
Gui_Window_Panel_ID[win, i] = tab_group
Gui_TabGroup_X[tab_index] = x
Gui_TabGroup_Y[tab_index] = y
Gui_Element_Window[tab_group] = win
Return True
End If
Next
Return False
End Function
Function Gui_CreateTabGroup(w, h)
id = Gui_GetFreeID
If id < 0 Then
Return -1
End If
For i = 0 to MAX_TAB_GROUPS-1
If Not Gui_TabGroup_Exists[i] Then
Gui_TabGroup_Exists[i] = True
Gui_TabGroup_W[i] = w
Gui_TabGroup_H[i] = h
Gui_TabGroup_TabCount[i] = 0
Gui_Element_Type[id] = GUI_TYPE_TAB
Gui_Element_Index[id] = i
Gui_Element_Exists[id] = True
Gui_Element_Active[id] = True
Gui_Element_Parent[id] = id
Return id
End If
Next
Return -1
End Function
Function Gui_TabGroup_Tab_AddObject(tab_group, tab_num, obj_id)
tab_index = Gui_Element_Index[tab_group]
obj_type = Gui_Element_Type[obj_id]
obj_index = Gui_Element_Index[obj_id]
For i = 0 to MAX_TAB_OBJECTS-1
If Not Gui_TabGroup_Tab_Object_Exists[tab_index, tab_num, i] Then
Gui_TabGroup_Tab_Object_Exists[tab_index, tab_num, i] = True
Gui_TabGroup_Tab_Object_ID[tab_index, tab_num, i] = obj_id
Gui_TabGroup_Tab_Object_Type[tab_index, tab_num, i] = obj_type
Gui_Element_Parent[obj_id] = tab_group
If tab_num = Gui_TabGroup_ActiveTab[tab_index] Then
Gui_Element_Active[obj_id] = True
Else
Gui_Element_Active[obj_id] = False
End If
Return i
End If
Next
Return -1
End Function
Function Gui_TabGroup_AddTab(tab_id, txt$)
tab_group = Gui_Element_Index[tab_id]
current_tab = Gui_TabGroup_TabCount[tab_group]
Canvas(GUI_TMP_CANVAS)
ClearCanvas
If Gui_TabGroup_TabCount[tab_group]+1 < MAX_TABS Then
i = Gui_TabGroup_TabCount[tab_group]
Gui_TabGroup_TabCount[tab_group] = Gui_TabGroup_TabCount[tab_group] + 1
Gui_TabGroup_Tab_Exists[tab_group, i] = True
Gui_TabGroup_Tab_Title$[tab_group, i] = txt$
dim buf[4]
Gui_TabGroup_Tab_Image[tab_group, i, 0] = Gui_GetFreeImage
ImageFromBuffer(Gui_TabGroup_Tab_Image[tab_group, i, 0], 2, 2, buf)
Gui_TabGroup_Tab_Image[tab_group, i, 1] = Gui_GetFreeImage
ImageFromBuffer(Gui_TabGroup_Tab_Image[tab_group, i, 1], 2, 2, buf)
Else
Return -1
End If
tab_w = Int(Gui_TabGroup_W[tab_group] / Gui_TabGroup_TabCount[tab_group])
tab_h = Gui_TabGroup_H[tab_group]
margin_w = tab_w/10
margin_h = tab_h/10
txt_w = 0
txt_h = 0
For tab_num = 0 to Gui_TabGroup_TabCount[tab_group]-1
GetTextSize(GUI_FONT, Gui_TabGroup_Tab_Title$[tab_group, tab_num], txt_w, txt_h)
SetColor(GUI_TAB_COLOR1)
RectFill(0, 0, tab_w, tab_h)
SetColor(GUI_FONT_COLOR)
Font(GUI_FONT)
DrawText(Gui_TabGroup_Tab_Title$[tab_group, tab_num], margin_w/2, margin_h/2)
SetColor(GUI_TAB_BORDER_COLOR)
Rect(0, 0, tab_w, tab_h)
tab_image = Gui_TabGroup_Tab_Image[tab_group, tab_num, 0]
If ImageExists(tab_image) Then
DeleteImage(tab_image)
End If
CanvasClip(tab_image, 0, 0, tab_w, tab_h, 1)
SetColor(GUI_TAB_COLOR2)
RectFill(0, 0, tab_w, tab_h)
SetColor(GUI_FONT_COLOR)
Font(GUI_FONT)
DrawText(Gui_TabGroup_Tab_Title$[tab_group, tab_num], margin_w/2, margin_h/2)
SetColor(GUI_TAB_BORDER_COLOR)
Rect(0, 0, tab_w, tab_h)
tab_image = Gui_TabGroup_Tab_Image[tab_group, tab_num, 1]
If ImageExists(tab_image) Then
DeleteImage(tab_image)
End If
CanvasClip(tab_image, 0, 0, tab_w, tab_h, 1)
Next
Return current_tab
End Function
Function Gui_Window_AddPanel(win, panel, x, y)
panel_index = Gui_Element_Index[panel]
For i = 0 to MAX_PANELS-1
If Not Gui_Window_Panel_Exists[win, i] Then
Gui_Window_Panel_Exists[win, i] = True
Gui_Window_Panel_Type[win, i] = GUI_TYPE_PANEL
Gui_Window_Panel_ID[win, i] = panel
Gui_Panel_X[panel_index] = x
Gui_Panel_Y[panel_index] = y
Gui_Element_Window[panel] = win
Return True
End If
Next
Return False
End Function
Function Gui_CreatePanel(w, h)
id = Gui_GetFreeID
If id < 0 Then
Return -1
End If
For i = 0 to MAX_PANELS-1
If Not Gui_Panel_Exists[i] Then
Gui_Panel_Exists[i] = True
Gui_Panel_W[i] = w
Gui_Panel_H[i] = h
Gui_Panel_Image[i] = Gui_GetFreeImage
'Dim buf[w*h]
'For b = 0 to (w*h)-1
' buf[b] = RGB(128,128,128)
'Next
'ImageFromBuffer(Gui_Panel_Image[i], w, h, buf)
Canvas(GUI_TMP_CANVAS)
SetColor(RGB(128,128,128))
RectFill(0, 0, w, h)
CanvasClip(Gui_Panel_Image[i], 0, 0, w, h, 1)
Gui_Element_Type[id] = GUI_TYPE_PANEL
Gui_Element_Index[id] = i
Gui_Element_Exists[id] = True
Gui_Element_Active[id] = True
Gui_Element_Parent[id] = id
Return id
End If
Next
Return -1
End Function
Function Gui_Panel_AddObject(panel, obj, x, y)
panel_index = Gui_Element_Index[panel]
obj_index = Gui_Element_Index[obj]
obj_type = Gui_Element_Type[obj]
For i = 0 to MAX_PANEL_OBJECTS-1
If Not Gui_Panel_Object_Exists[panel_index, i] Then
Gui_Panel_Object_Exists[panel_index, i] = True
Gui_Panel_Object_Type[panel_index, i] = obj_type
Gui_Panel_Object_ID[panel_index, i] = obj
Gui_Element_Parent[obj] = panel
Select Case obj_type
Case GUI_TYPE_BUTTON
Gui_Button_X[obj_index] = x
Gui_Button_Y[obj_index] = y
Gui_Button_Panel[obj_index] = panel
Case GUI_TYPE_DROPDOWN
Gui_DropDown_X[obj_index] = x
Gui_DropDown_Y[obj_index] = y
Gui_DropDown_Panel[obj_index] = panel
Case GUI_TYPE_LISTBOX
Gui_ListBox_X[obj_index] = x
Gui_ListBox_Y[obj_index] = y
Gui_ListBox_Panel[obj_index] = panel
Case GUI_TYPE_TEXTFIELD
Gui_TextField_X[obj_index] = x
Gui_TextField_Y[obj_index] = y
Gui_TextField_Panel[obj_index] = panel
Case GUI_TYPE_CHECKBOX
Gui_CheckBox_X[obj_index] = x
Gui_CheckBox_Y[obj_index] = y
Gui_CheckBox_Panel[obj_index] = panel
Case GUI_TYPE_LABEL
Gui_Label_X[obj_index] = x
Gui_Label_Y[obj_index] = y
Gui_Label_Panel[obj_index] = panel
Case GUI_TYPE_IMAGECLIP
Gui_ImageClip_X[obj_index] = x
Gui_ImageClip_Y[obj_index] = y
Gui_ImageClip_Panel[obj_index] = panel
Case GUI_TYPE_IMAGESLIDE
Gui_ImageSlide_X[obj_index] = x
Gui_ImageSlide_Y[obj_index] = y
Gui_ImageSlide_Panel[obj_index] = panel
Case GUI_TYPE_SURFACE
Gui_Surface_X[obj_index] = x
Gui_Surface_Y[obj_index] = y
Gui_Surface_Panel[obj_index] = panel
End Select
Return True
End If
Next
Return False
End Function
Function Gui_CreateDropDown(w, h)
id = Gui_GetFreeID
If id < 0 Then
Return -1
End If
If w < GUI_DROPDOWN_MIN_W Then
w = GUI_DROPDOWN_MIN_W
End If
If h < GUI_DROPDOWN_MIN_H Then
h = GUI_DROPDOWN_MIN_H
End If
For i = 0 to MAX_DROPDOWNS-1
If Not Gui_DropDown_Exists[i] Then
Gui_DropDown_Exists[i] = True
Gui_DropDown_W[i] = w
Gui_DropDown_H[i] = h
Gui_DropDown_Count[i] = 0
Canvas(GUI_TMP_CANVAS)
ClearCanvas
Gui_DropDown_Image[i,0] = Gui_GetFreeImage
SetColor(GUI_DROPDOWN_COLOR1)
RectFill(0, 0, w, h)
SetColor(GUI_DROPDOWN_BORDER_COLOR)
Rect(0, 0, w, h)
arrow_x = w - GUI_DROPDOWN_MIN_W
arrow_y = 0
arrow_w = GUI_DROPDOWN_MIN_W
arrow_h = h
Rect(arrow_x, arrow_y, arrow_w, arrow_h)
SetColor(RGB(0,0,0))
DrawText("V", arrow_x + arrow_w/2 - GUI_FONT_W/2, arrow_y + arrow_h/2 - GUI_FONT_H/2)
CanvasClip(Gui_DropDown_Image[i,0], 0, 0, w, h, 1)
ClearCanvas
Gui_DropDown_Image[i,1] = Gui_GetFreeImage
SetColor(GUI_DROPDOWN_COLOR2)
RectFill(0, 0, w, h)
SetColor(GUI_DROPDOWN_BORDER_COLOR)
Rect(0, 0, w, h)
arrow_x = w - GUI_DROPDOWN_MIN_W
arrow_y = 0
arrow_w = GUI_DROPDOWN_MIN_W
arrow_h = h
Rect(arrow_x, arrow_y, arrow_w, arrow_h)
SetColor(RGB(0,0,0))
DrawText("V", arrow_x + arrow_w/2 - GUI_FONT_W/2, arrow_y + arrow_h/2 - GUI_FONT_H/2)
CanvasClip(Gui_DropDown_Image[i,1], 0, 0, w, h, 1)
Dim buf[w*h]
Gui_DropDown_Image[i,2] = Gui_GetFreeImage
ImageFromBuffer(Gui_DropDown_Image[i,2], w, h, buf)
Gui_Element_Type[id] = GUI_TYPE_DROPDOWN
Gui_Element_Index[id] = i
Gui_Element_Exists[id] = True
Gui_Element_Active[id] = True
Return id
End If
Next
Return -1
End Function
Sub RedrawDropDownSelected(d_index)
Canvas(GUI_TMP_CANVAS)
ClearCanvas
dim txt_w
dim txt_h
txt$ = Gui_DropDown_Value$[d_index, Gui_DropDown_Selected_Item[d_index]]
If txt$ = "" Then
txt$ = " "
End If
GetTextSize(GUI_FONT, txt, txt_w, txt_h)
selection_w = Gui_DropDown_W[d_index] - GUI_DROPDOWN_MIN_W
selection_h = Gui_DropDown_H[d_index]
margin_w = selection_w/10
margin_h = selection_h/10
If txt_w > (selection_w - (margin_w*2) ) Then
txt_w = selection_w - (margin_w*2)
End If
If txt_h > (selection_h - (margin_h*2) ) Then
txt_h = selection_h - (margin_h*2)
End If
txt_img = Gui_GetFreeImage
SetColor(GUI_DROPDOWN_COLOR1)
RectFill(0, 0, selection_w, selection_h)
SetColor(GUI_FONT_COLOR)
DrawText(txt$, 0, 0)
CanvasClip(txt_img, 0, 0, txt_w, txt_h, 1)
'SetColor(GUI_BUTTON_COLOR1)
'RectFill(0, 0, w, h)
'DrawImage(txt_img, margin_w, margin_h)
ClearCanvas
w = Gui_DropDown_W[d_index]
h = Gui_DropDown_H[d_index]
SetColor(GUI_DROPDOWN_COLOR1)
RectFill(0, 0, w, h)
SetColor(GUI_DROPDOWN_BORDER_COLOR)
Rect(0, 0, w, h)
arrow_x = w - GUI_DROPDOWN_MIN_W
arrow_y = 0
arrow_w = GUI_DROPDOWN_MIN_W
arrow_h = h
Rect(arrow_x, arrow_y, arrow_w, arrow_h)
SetColor(RGB(0,0,0))
DrawImage(txt_img, margin_w, margin_h)
DrawText("V", arrow_x + arrow_w/2 - GUI_FONT_W/2, arrow_y + arrow_h/2 - GUI_FONT_H/2)
If ImageExists(Gui_DropDown_Image[d_index, 0]) Then
DeleteImage(Gui_DropDown_Image[d_index, 0])
End If
CanvasClip(Gui_DropDown_Image[d_index,0], 0, 0, w, h, 1)
ClearCanvas
SetColor(GUI_DROPDOWN_COLOR2)
RectFill(0, 0, w, h)
SetColor(GUI_DROPDOWN_BORDER_COLOR)
Rect(0, 0, w, h)
arrow_x = w - GUI_DROPDOWN_MIN_W
arrow_y = 0
arrow_w = GUI_DROPDOWN_MIN_W
arrow_h = h
Rect(arrow_x, arrow_y, arrow_w, arrow_h)
SetColor(RGB(0,0,0))
DrawImage(txt_img, margin_w, margin_h)
DrawText("V", arrow_x + arrow_w/2 - GUI_FONT_W/2, arrow_y + arrow_h/2 - GUI_FONT_H/2)
If ImageExists(Gui_DropDown_Image[d_index, 1]) Then
DeleteImage(Gui_DropDown_Image[d_index, 1])
End If
CanvasClip(Gui_DropDown_Image[d_index,1], 0, 0, w, h, 1)
DeleteImage(txt_img)
End Sub
Function Gui_DropDown_AddItem(d_id, value$)
d_index = Gui_Element_Index[d_id]
If Gui_DropDown_Count[d_index]+1 < MAX_DROPDOWN_VALUES Then
num = Gui_DropDown_Count[d_index]
Gui_DropDown_Value$[d_index, num] = value$
Gui_DropDown_Count[d_index] = Gui_DropDown_Count[d_index] + 1
'Need to draw dropdown image here
Canvas(GUI_TMP_CANVAS)
ClearCanvas
SetColor(GUI_DROPDOWN_COLOR1)
RectFill(0, 0, Gui_DropDown_W[d_index], Gui_DropDown_Count[d_index] * GUI_FONT_H)
SetColor(GUI_FONT_COLOR)
For i = 0 to Gui_DropDown_Count[d_index]-1
DrawText(Gui_DropDown_Value$[d_index, i], 0, i * GUI_FONT_H)
Next
If ImageExists(Gui_DropDown_Image[d_index, 2]) Then
DeleteImage(Gui_DropDown_Image[d_index, 2])
End If
CanvasClip(Gui_DropDown_Image[d_index, 2], 0, 0, Gui_DropDown_W[d_index], Gui_DropDown_Count[d_index] * GUI_FONT_H, 1)
If Gui_DropDown_Count[d_index] = 1 Then
Gui_DropDown_Selected_Item[d_index] = 0
RedrawDropDownSelected(d_index)
End If
Return num
End If
Return -1
End Function
Sub RedrawDropDown(d_index)
num = Gui_DropDown_Count[d_index]
'Need to draw dropdown image here
Canvas(GUI_TMP_CANVAS)
ClearCanvas
SetColor(GUI_DROPDOWN_COLOR1)
RectFill(0, 0, Gui_DropDown_W[d_index], Gui_DropDown_Count[d_index] * GUI_FONT_H)
SetColor(GUI_FONT_COLOR)
If Gui_DropDown_Count[d_index] > 0 Then
For i = 0 to Gui_DropDown_Count[d_index]-1
DrawText(Gui_DropDown_Value$[d_index, i], 0, i * GUI_FONT_H)
Next
End If
If ImageExists(Gui_DropDown_Image[d_index, 2]) Then
DeleteImage(Gui_DropDown_Image[d_index, 2])
End If
CanvasClip(Gui_DropDown_Image[d_index, 2], 0, 0, Gui_DropDown_W[d_index], Gui_DropDown_Count[d_index] * GUI_FONT_H, 1)
If Gui_DropDown_Count[d_index] <= 1 Then
Gui_DropDown_Selected_Item[d_index] = 0
RedrawDropDownSelected(d_index)
End If
End Sub
Function Gui_DropDown_RemoveItem(d_id, item_num)
d_index = Gui_Element_Index[d_id]
If item_num < Gui_DropDown_Count[d_index] Then
For i = item_num to Gui_DropDown_Count[d_index]-1
Gui_DropDown_Value$[d_index, i] = Gui_DropDown_Value$[d_index, i+1]
Next
Gui_DropDown_Count[d_index] = Gui_DropDown_Count[d_index] - 1
End If
End Function
Function Gui_DropDown_Clear(d_id)
d_index = Gui_Element_Index[d_id]
Gui_DropDown_Count[d_index] = 0
Gui_DropDown_Selected_Item[d_index] = 0
RedrawDropDown(d_index)
End Function
Function Gui_DropDown_Update(d_id)
d_index = Gui_Element_Index[d_id]
RedrawDropDown(d_index)
End Function
Function Gui_CreateButton(txt$, w, h)
id = Gui_GetFreeID
If id < 0 Then
Return -1
End If
For i = 0 to MAX_BUTTONS-1
If Not Gui_Button_Exists[i] Then
Gui_Button_Exists[i] = True
Gui_Button_W[i] = w
Gui_Button_H[i] = h
current_canvas = ActiveCanvas
Canvas(GUI_TMP_CANVAS)
ClearCanvas
dim txt_w
dim txt_h
GetTextSize(GUI_FONT, txt, txt_w, txt_h)
margin_w = w/10
margin_h = h/10
If txt_w > (w - (margin_w*2) ) Then
txt_w = w - (margin_w*2)
End If
If txt_h > (h - (margin_h*2) ) Then
txt_h = h - (margin_h*2)
End If
img = Gui_GetFreeImage
SetColor(GUI_BUTTON_COLOR1)
RectFill(0, 0, w, h)
SetColor(GUI_FONT_COLOR)
DrawText(txt$, 0, 0)
CanvasClip(img, 0, 0, txt_w, txt_h, 1)
SetColor(GUI_BUTTON_COLOR1)
RectFill(0, 0, w, h)
DrawImage(img, margin_w, margin_h)
DeleteImage(img)
CanvasClip(img, 0, 0, w, h, 1)
Gui_Button_Image[i, 0] = img
img = Gui_GetFreeImage
SetColor(GUI_BUTTON_COLOR2)
RectFill(0, 0, w, h)
SetColor(GUI_FONT_COLOR)
DrawText(txt$, 0, 0)
CanvasClip(img, 0, 0, txt_w, txt_h, 1)
SetColor(GUI_BUTTON_COLOR2)
RectFill(0, 0, w, h)
DrawImage(img, margin_w, margin_h)
DeleteImage(img)
CanvasClip(img, 0, 0, w, h, 1)
Gui_Button_Image[i, 1] = img
Gui_Element_Type[id] = GUI_TYPE_BUTTON
Gui_Element_Index[id] = i
Gui_Element_Exists[id] = True
Gui_Element_Active[id] = True
Return id
End If
Next
Return -1
End Function