forked from thisdp/dgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
3439 lines (3405 loc) · 126 KB
/
client.lua
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
------------Copyrights thisdp's DirectX Graphical User Interface System
sW,sH = guiGetScreenSize()
white = tocolor(255,255,255,255)
black = tocolor(0,0,0,255)
fontSize = {}
systemFont = "default"
fontDxHave = {
["default"]=true,
["default-bold"]=true,
["clear"]=true,
["arial"]=true,
["sans"]=true,
["pricedown"]=true,
["bankgothic"]=true,
["diploma"]=true,
["beckett"]=true,
}
dgsRenderSetting = {
postGUI = nil,
renderPriority = "normal",
}
function dgsSetSystemFont(font,size,bold,quality)
assert(type(font) == "string","Bad argument @dgsSetSystemFont at argument 1, expect a string got "..dgsGetType(font))
if fontDxHave[font] then
systemFont = font
return true
else
if sourceResource then
local path
if not string.find(font,":") then
local resname = getResourceName(sourceResource)
path = ":"..resname.."/"..font
else
path = font
end
assert(fileExists(path),"Bad argument @dgsSetSystemFont at argument 1,couldn't find such file '"..path.."'")
local filename = split(path,"/")
local pathindgs = ":"..getResourceName(getThisResource()).."/Third/"..filename[#filename]
if isElement(systemFont) then
destroyElement(systemFont)
end
fileCopy(path,pathindgs,true)
local font = dxCreateFont(pathindgs,size,bold,quality)
if isElement(font) then
systemFont = font
end
end
end
return false
end
function dgsGetSystemFont()
return systemFont
end
function dgsGetRenderSetting(name)
return dgsRenderSetting[name]
end
function dgsSetRenderSetting(name,value)
if name == "renderPriority" then
assert(type(value)=="string","Bad Argument @dgsSetRenderSetting at argument 2, expected a string got "..dgsGetType(value))
removeEventHandler("onClientRender",root,dgsCoreRender)
local success = addEventHandler("onClientRender",root,dgsCoreRender,false,value)
if not success then
addEventHandler("onClientRender",root,dgsCoreRender,false,dgsRenderSetting.renderPriority)
end
assert(success,"Bad Argument @dgsSetRenderSetting at argument 2, failed to set the priority")
end
dgsRenderSetting[name] = value
return true
end
-----------------------------dx-GUI
MouseData = {}
MouseData.enter = false
MouseData.lastEnter = false
MouseData.enterData = false
MouseData.scrollPane = false
MouseData.hit = false
MouseData.Timer = {}
MouseData.Timer2 = {}
MouseData.nowShow = false
MouseData.editCursor = false
MouseData.editCursorMoveOffset = false
MouseData.gridlistMultiSelection = false
MouseData.lastPos = {-1,-1}
MouseData.EditTimer = setTimer(function()
if isElement(MouseData.nowShow) then
if dgsGetType(MouseData.nowShow) == "dgs-dxedit" then
MouseData.editCursor = not MouseData.editCursor
end
end
end,500,0)
MouseData.MemoTimer = setTimer(function()
if isElement(MouseData.nowShow) then
if dgsGetType(MouseData.nowShow) == "dgs-dxmemo" then
MouseData.memoCursor = not MouseData.memoCursor
end
end
end,500,0)
function dgsCoreRender()
triggerEvent("onDgsPreRender",resourceRoot)
MouseData.hit = false
local bottomTableSize = #BottomFatherTable
local centerTableSize = #CenterFatherTable
local topTableSize = #TopFatherTable
local dx3DInterfaceTableSize = #dx3DInterfaceTable
local tk = getTickCount()
MouseData.hit = false
DGSShow = 0
wX,wY,wZ = nil,nil,nil
local mx,my = -1000,-1000
if isCursorShowing() then
mx,my = getCursorPosition()
mx,my = mx*sW,my*sH
wX,wY,wZ = getWorldFromScreenPosition(mx,my,1)
MouseX,MouseY = mx,my
else
MouseData.Move = false
MouseData.clickData = false
MouseData.clickl = false
MouseData.clickr = false
MouseData.clickm = false
MouseData.Scale = false
MouseData.scrollPane = false
end
if bottomTableSize+centerTableSize+topTableSize+dx3DInterfaceTableSize ~= 0 then
local dgsData = dgsElementData
dxSetRenderTarget()
for i=1,dx3DInterfaceTableSize do
local v = dx3DInterfaceTable[i]
local eleData = dgsData[v]
renderGUI(v,mx,my,{eleData.enabled,eleData.enabled},eleData.renderTarget_parent,0,0,1,eleData.visible)
end
dxSetRenderTarget()
for i=1,bottomTableSize do
local v = BottomFatherTable[i]
local eleData = dgsData[v]
renderGUI(v,mx,my,{eleData.enabled,eleData.enabled},eleData.renderTarget_parent,0,0,1,eleData.visible)
end
for i=1,centerTableSize do
local v = CenterFatherTable[i]
local eleData = dgsData[v]
renderGUI(v,mx,my,{eleData.enabled,eleData.enabled},eleData.renderTarget_parent,0,0,1,eleData.visible)
end
for i=1,topTableSize do
local v = TopFatherTable[i]
local eleData = dgsData[v]
renderGUI(v,mx,my,{eleData.enabled,eleData.enabled},eleData.renderTarget_parent,0,0,1,eleData.visible)
end
dxSetRenderTarget()
if not isCursorShowing() then
MouseData.hit = false
MouseData.Move = false
MouseData.clickData = false
MouseData.clickl = false
MouseData.clickr = false
MouseData.clickm = false
MouseData.Scale = false
MouseData.scrollPane = false
MouseX,MouseY = nil,nil
end
triggerEvent("onDgsRender",resourceRoot)
dgsCheckHit(MouseData.hit,MouseX,MouseY)
end
if DEBUG_MODE then
local ticks = getTickCount()-tk
local version = getElementData(resourceRoot,"Version")
dxDrawText("Thisdp's Dx Lib(DGS)",6,sH*0.4-114,sW,sH,black)
dxDrawText("Thisdp's Dx Lib(DGS)",5,sH*0.4-115)
dxDrawText("Version: "..version,6,sH*0.4-99,sW,sH,black)
dxDrawText("Version: "..version,5,sH*0.4-100)
dxDrawText("Render Time: "..ticks.." ms",11,sH*0.4-84,sW,sH,black)
dxDrawText("Render Time: "..ticks.." ms",10,sH*0.4-85)
local enterStr = MouseData.hit and dgsGetType(MouseData.hit).."("..tostring(MouseData.hit)..")" or "None"
dxDrawText("Enter: "..enterStr,11,sH*0.4-69,sW,sH,black)
dxDrawText("Enter: "..enterStr,10,sH*0.4-70)
dxDrawText("Click:",11,sH*0.4-54,sW,sH,black)
dxDrawText("Click:",10,sH*0.4-55)
local leftStr = MouseData.clickl and dgsGetType(MouseData.clickl).."("..tostring(MouseData.clickl)..")" or "None"
local rightStr = MouseData.clickr and dgsGetType(MouseData.clickr).."("..tostring(MouseData.clickr)..")" or "None"
dxDrawText(" Left: "..leftStr,11,sH*0.4-39,sW,sH,black)
dxDrawText(" Left: "..leftStr,10,sH*0.4-40)
dxDrawText(" Right: "..rightStr,11,sH*0.4-24,sW,sH,black)
dxDrawText(" Right: "..rightStr,10,sH*0.4-25)
DGSCount = 0
for k,v in ipairs(dgsType) do
DGSCount = DGSCount+#getElementsByType(v)
local x = 15
if v == "dgs-dxtab" or v == "dgs-dxcombobox-Box" then
x = 30
end
dxDrawText(v.." : "..#getElementsByType(v),x+1,sH*0.4+15*k+6,sW,sH,black)
dxDrawText(v.." : "..#getElementsByType(v),x,sH*0.4+15*k+5)
end
dxDrawText("Elements Shows: "..DGSShow,11,sH*0.4-9,sW,sH,black)
dxDrawText("Elements Shows: "..DGSShow,10,sH*0.4-10,sW,sH)
dxDrawText("Elements Counts: "..DGSCount,11,sH*0.4+6,sW,sH,black)
dxDrawText("Elements Counts: "..DGSCount,10,sH*0.4+5,sW,sH)
local anim = table.count(animGUIList)
local move = table.count(moveGUIList)
local size = table.count(sizeGUIList)
local alp = table.count(alphaGUIList)
local all = anim+move+size+alp
dxDrawText("Running Animation("..all.."):",301,sH*0.4-114,sW,sH,black)
dxDrawText("Running Animation("..all.."):",300,sH*0.4-115)
dxDrawText("Anim:"..anim,301,sH*0.4-99,sW,sH,black)
dxDrawText("Anim:"..anim,300,sH*0.4-100)
dxDrawText("Move:"..move,301,sH*0.4-84,sW,sH,black)
dxDrawText("Move:"..move,300,sH*0.4-85)
dxDrawText("Size:"..size,301,sH*0.4-69,sW,sH,black)
dxDrawText("Size:"..size,300,sH*0.4-70)
dxDrawText("Alpha:"..alp,301,sH*0.4-54,sW,sH,black)
dxDrawText("Alpha:"..alp,300,sH*0.4-55)
Resource = 0
ResCount = 0
for ka,va in pairs(resourceDxGUI) do
if type(ka) == "userdata" and va then
Resource = Resource+#va
ResCount = ResCount +1
dxDrawText(getResourceName(ka).." : "..#va,301,sH*0.4+15*(ResCount+1)+1,sW,sH,black)
dxDrawText(getResourceName(ka).." : "..#va,300,sH*0.4+15*(ResCount+1))
end
end
dxDrawText("Resource Elements("..ResCount.."):",301,sH*0.4+16,sW,sH,black)
dxDrawText("Resource Elements("..ResCount.."):",300,sH*0.4+15)
end
end
addEventHandler("onClientCursorMove",root,function(_,_,mx,my)
--dgsCheckHit(MouseData.hit,mx,my)
end)
function renderGUI(v,mx,my,enabled,rndtgt,OffsetX,OffsetY,galpha,visible)
if DEBUG_MODE then
DGSShow = DGSShow+1
end
local eleData = dgsElementData[v]
local enabled = {enabled[1] and eleData.enabled,eleData.enabled}
if eleData.visible and visible and isElement(v) then
visible = eleData.visible
local dxType = dgsGetType(v)
if dxType == "dgs-dxscrollbar" then
local pnt = eleData.parent_sp
if pnt and not dgsElementData[pnt].visible then
return
end
end
local parent,children,galpha = FatherTable[v] or false,ChildrenTable[v] or {},eleData.alpha*galpha
dxSetRenderTarget(rndtgt)
local x,y
if eleData.absPos then
x,y = dgsGetPosition(v,false,true)
end
local siz = eleData.absSize or {}
local w,h = siz[1],siz[2]
local isRenderTarget = (not rndtgt) and true or false
self = v
local rendSet = not DEBUG_MODE and isRenderTarget and (dgsRenderSetting.postGUI == nil and eleData.postGUI) or dgsRenderSetting.postGUI
if dxType == "dgs-dxwindow" then
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local img = eleData.image
local color = eleData.color
color = applyColorAlpha(color,galpha)
local titimg,titcolor,titsize = eleData.titimage,eleData.titcolor,eleData.titlesize
titcolor = applyColorAlpha(titcolor,galpha)
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if img then
dxDrawImage(x,y+titsize,w,h-titsize,img,0,0,0,color,rendSet)
else
dxDrawRectangle(x,y+titsize,w,h-titsize,color,rendSet)
end
if titimg then
dxDrawImage(x,y,w,titsize,titimg,0,0,0,titcolor,rendSet)
else
dxDrawRectangle(x,y,w,titsize,titcolor,rendSet)
end
local font = eleData.font or systemFont
local titnamecolor = eleData.titnamecolor
titnamecolor = applyColorAlpha(titnamecolor,galpha)
local txtSizX,txtSizY = eleData.textsize[1],eleData.textsize[2] or eleData.textsize[1]
dxDrawText(eleData.text,x,y,x+w,y+titsize,titnamecolor,txtSizX,txtSizY,systemFont,"center","center",true,false,rendSet,eleData.colorcoded)
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx and mx then
if mx >= x and mx<= x+w and my >= y and my <= y+h then
MouseData.hit = v
end
end
else
visible = false
end
elseif dxType == "dgs-dxbutton" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local colors,imgs = eleData.color,eleData.image
local colorimgid = 1
if MouseData.enter == v then
colorimgid = 2
if eleData.clickType == 1 then
if MouseData.clickl == v then
colorimgid = 3
end
elseif eleData.clickType == 2 then
if MouseData.clickr == v then
colorimgid = 3
end
else
if MouseData.clickl == v or MouseData.clickr == v then
colorimgid = 3
end
end
end
local finalcolor
if not enabled[1] and not enabled[2] then
if type(eleData.disabledColor) == "number" then
finalcolor = applyColorAlpha(eleData.disabledColor,galpha)
elseif eleData.disabledColor == true then
local r,g,b,a = fromcolor(colors[1],true)
local average = (r+g+b)/3*eleData.disabledColorPercent
finalcolor = tocolor(average,average,average,a*galpha)
else
finalcolor = colors[colorimgid]
end
else
finalcolor = applyColorAlpha(colors[colorimgid],galpha)
end
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if imgs[colorimgid] then
dxDrawImage(x,y,w,h,imgs[colorimgid],0,0,0,finalcolor,rendSet)
else
dxDrawRectangle(x,y,w,h,finalcolor,rendSet)
end
local text = eleData.text
if #text ~= 0 then
local font = eleData.font or systemFont
local txtSizX,txtSizY = eleData.textsize[1],eleData.textsize[2] or eleData.textsize[1]
local txtoffsetsX,txtoffsetsY = 0,0
local clip = eleData.clip
local wordbreak = eleData.wordbreak
local colorcoded = eleData.colorcoded
if colorimgid == 3 then
txtoffsetsX,txtoffsetsY = eleData.clickoffset[1],eleData.clickoffset[2]
end
local tplt = eleData.rightbottom
local shadowoffx,shadowoffy,shadowc = eleData.shadow[1],eleData.shadow[2],eleData.shadow[3]
if shadowoffx and shadowoffy and shadowc then
shadowc = applyColorAlpha(shadowc,galpha)
dxDrawText(text,x+txtoffsetsX+shadowoffx,y+txtoffsetsY+shadowoffy,x+w+shadowoffx-2,y+h+shadowoffy-1,tocolor(0,0,0,255*galpha),txtSizX,txtSizY,font,tplt[1],tplt[2],clip,wordbreak,rendSet,colorcoded)
end
dxDrawText(text,x+txtoffsetsX,y+txtoffsetsY,x+w-1,y+h-1,applyColorAlpha(eleData.textcolor,galpha),txtSizX,txtSizY,font,tplt[1],tplt[2],clip,wordbreak,rendSet,colorcoded)
end
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx then
if mx >= cx and mx<= cx+w and my >= cy and my <= cy+h then
MouseData.hit = v
end
end
else
visible = false
end
elseif dxType == "dgs-dxeda" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx then
if dgsCheckRadius(v,mx,my) then
MouseData.hit = v
end
if eleData.debug then
local debugShader = eleData.debugShader
if debugShader ~= "Error" then
if not isElement(debugShader) then
debugShader = dxCreateShader("image/eda/ellipse.fx")
if isElement(debugShader) then
eleData.debugShader = debugShader
else
outputChatBox("[DGS]Couldn't create ellipse shader (Maybe video memory isn't enough or your video card isn't support the shader)",255,0,0)
eleData.debugShader = "Error"
end
end
if MouseData.hit == v then
dxSetShaderValue(debugShader,"tcolor",{1,0,0,0.5})
else
dxSetShaderValue(debugShader,"tcolor",{1,1,1,0.5})
end
dxDrawImage(x,y,w,h,debugShader,0,0,0,white,not DEBUG_MODE)
end
end
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
end
else
visible = false
end
elseif dxType == "dgs-dximage" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local colors,imgs = eleData.color,eleData.image
colors = applyColorAlpha(colors,galpha)
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if colors >= 16777216 or colors < 0 then
if imgs then
local sx,sy = eleData.imagesize[1],eleData.imagesize[2]
local px,py = eleData.imagepos[1],eleData.imagepos[2]
local rotOffx,rotOffy = eleData.rotationCenter[1],eleData.rotationCenter[2]
local rot = eleData.rotation or 0
if not sx or not sy or not px or not py then
dxDrawImage(x,y,w,h,imgs,rot,rotOffx,rotOffy,colors,rendSet)
else
dxDrawImageSection(x,y,w,h,px,py,sx,sy,imgs,rot,rotOffy,rotOffy,colors,rendSet)
end
else
dxDrawRectangle(x,y,w,h,colors,rendSet)
end
end
local sideColor = eleData.sideColor
local sideSize = eleData.sideSize
if sideColor >= 16777216 or sideColor < 0 and sideSize ~= 0 then
sideSize = applyColorAlpha(sideSize,galpha)
local renderState = eleData.sideState
if renderState == "in" then
dxDrawLine(x,y+sideSize/2,x+w,y+sideSize/2,sideColor,sideSize,rendSet)
dxDrawLine(x+sideSize/2,y,x+sideSize/2,y+h,sideColor,sideSize,rendSet)
dxDrawLine(x+w-sideSize/2,y,x+w-sideSize/2,y+h,sideColor,sideSize,rendSet)
dxDrawLine(x,y+h-sideSize/2,x+w,y+h-sideSize/2,sideColor,sideSize,rendSet)
elseif renderState == "center" then
dxDrawLine(x-sideSize/2,y,x+w+sideSize/2,y,sideColor,sideSize,rendSet)
dxDrawLine(x,y+sideSize/2,x,y+h-sideSize/2,sideColor,sideSize,rendSet)
dxDrawLine(x+w,y+sideSize/2,x+w,y+h-sideSize/2,sideColor,sideSize,rendSet)
dxDrawLine(x-sideSize/2,y+h,x+w+sideSize/2,y+h,sideColor,sideSize,rendSet)
elseif renderState == "out" then
dxDrawLine(x-sideSize,y-sideSize/2,x+w+sideSize,y-sideSize/2,sideColor,sideSize,rendSet)
dxDrawLine(x-sideSize/2,y,x-sideSize/2,y+h,sideColor,sideSize,rendSet)
dxDrawLine(x+w+sideSize/2,y,x+w+sideSize/2,y+h,sideColor,sideSize,rendSet)
dxDrawLine(x-sideSize,y+h+sideSize/2,x+w+sideSize,y+h+sideSize/2,sideColor,sideSize,rendSet)
end
end
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx then
if mx >= cx and mx<= cx+w and my >= cy and my <= cy+h then
MouseData.hit = v
end
end
else
visible = false
end
elseif dxType == "dgs-dxradiobutton" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local image_f,image_t = eleData.image_f,eleData.image_t
local color_f,color_t = eleData.color_f,eleData.color_t
local rbParent = eleData.rbParent
local image,color
local _buttonSize = eleData.buttonsize
local buttonSize = _buttonSize[2] and _buttonSize[1]*h or _buttonSize[1]
if dgsElementData[rbParent].RadioButton == v then
image,color = image_t,color_t
else
image,color = image_f,color_f
end
local colorimgid = 1
if MouseData.enter == v then
colorimgid = 2
if eleData.clickType == 1 then
if MouseData.clickl == v then
colorimgid = 3
end
elseif eleData.clickType == 2 then
if MouseData.clickr == v then
colorimgid = 3
end
else
if MouseData.clickl == v or MouseData.clickr == v then
colorimgid = 3
end
end
end
local finalcolor
if not enabled[1] and not enabled[2] then
if type(eleData.disabledColor) == "number" then
finalcolor = applyColorAlpha(eleData.disabledColor,galpha)
elseif eleData.disabledColor == true then
local r,g,b,a = fromcolor(color[1],true)
local average = (r+g+b)/3*eleData.disabledColorPercent
finalcolor = tocolor(average,average,average,a*galpha)
else
finalcolor = color[colorimgid]
end
else
finalcolor = applyColorAlpha(color[colorimgid],galpha)
end
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if image[colorimgid] then
dxDrawImage(x,y+h/2-buttonSize/2,buttonSize,buttonSize,image[colorimgid],0,0,0,finalcolor,rendSet)
else
dxDrawRectangle(x,y+h/2-buttonSize/2,buttonSize,buttonSize,finalcolor,rendSet)
end
local font = eleData.font or systemFont
local txtSizX,txtSizY = eleData.textsize[1],eleData.textsize[2] or eleData.textsize[1]
local clip = eleData.clip
local wordbreak = eleData.wordbreak
local _textImageSpace = eleData.textImageSpace
local textImageSpace = _textImageSpace[2] and _textImageSpace[1]*w or _textImageSpace[1]
local colorcoded = eleData.colorcoded
local tplt = eleData.rightbottom
local shadowoffx,shadowoffy,shadowc = eleData.shadow[1],eleData.shadow[2],eleData.shadow[3]
local px = x+buttonSize+textImageSpace
if eleData.PixelInt then
px,y,w,h = px-px%1,y-y%1,w-w%1,h-h%1
end
if shadowoffx and shadowoffy and shadowc then
shadowc = applyColorAlpha(shadowc,galpha)
dxDrawText(eleData.text,px+shadowoffx,y+shadowoffy,px+w+shadowoffx-2,y+h+shadowoffy-1,tocolor(0,0,0,255*galpha),txtSizX,txtSizY,font,tplt[1],tplt[2],clip,wordbreak,rendSet,colorcoded)
end
dxDrawText(eleData.text,px,y,px+w-1,y+h-1,applyColorAlpha(eleData.textcolor,galpha),txtSizX,txtSizY,font,tplt[1],tplt[2],clip,wordbreak,rendSet,colorcoded)
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx then
if mx >= cx and mx<= cx+w and my >= cy and my <= cy+h then
MouseData.hit = v
end
end
else
visible = false
end
elseif dxType == "dgs-dxcheckbox" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local image_f,image_t,image_i = eleData.image_f,eleData.image_t,eleData.image_i
local color_f,color_t,color_i = eleData.color_f,eleData.color_t,eleData.color_i
local image,color
local _buttonSize = eleData.buttonsize
local buttonSize = _buttonSize[2] and _buttonSize[1]*h or _buttonSize[1]
if eleData.CheckBoxState == true then
image,color = image_t,color_t
elseif eleData.CheckBoxState == false then
image,color = image_f,color_f
else
image,color = image_i,color_i
end
local colorimgid = 1
if MouseData.enter == v then
colorimgid = 2
if eleData.clickType == 1 then
if MouseData.clickl == v then
colorimgid = 3
end
elseif eleData.clickType == 2 then
if MouseData.clickr == v then
colorimgid = 3
end
else
if MouseData.clickl == v or MouseData.clickr == v then
colorimgid = 3
end
end
end
local finalcolor
if not enabled[1] and not enabled[2] then
if type(eleData.disabledColor) == "number" then
finalcolor = applyColorAlpha(eleData.disabledColor,galpha)
elseif eleData.disabledColor == true then
local r,g,b,a = fromcolor(color[1],true)
local average = (r+g+b)/3*eleData.disabledColorPercent
finalcolor = tocolor(average,average,average,a*galpha)
else
finalcolor = color[colorimgid]
end
else
finalcolor = applyColorAlpha(color[colorimgid],galpha)
end
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if image[colorimgid] then
dxDrawImage(x,y+h/2-buttonSize/2,buttonSize,buttonSize,image[colorimgid],0,0,0,finalcolor,rendSet)
else
dxDrawRectangle(x,y+h/2-buttonSize/2,buttonSize,buttonSize,finalcolor,rendSet)
end
local font = eleData.font or systemFont
local txtSizX,txtSizY = eleData.textsize[1],eleData.textsize[2] or eleData.textsize[1]
local clip = eleData.clip
local wordbreak = eleData.wordbreak
local _textImageSpace = eleData.textImageSpace
local textImageSpace = _textImageSpace[2] and _textImageSpace[1]*w or _textImageSpace[1]
local colorcoded = eleData.colorcoded
local tplt = eleData.rightbottom
local shadowoffx,shadowoffy,shadowc = eleData.shadow[1],eleData.shadow[2],eleData.shadow[3]
local px = x+buttonSize+textImageSpace
if eleData.PixelInt then
px,y,w,h = px-px%1,y-y%1,w-w%1,h-h%1
end
if shadowoffx and shadowoffy and shadowc then
shadowc = applyColorAlpha(shadowc,galpha)
dxDrawText(eleData.text,px+shadowoffx,y+shadowoffy,px+w+shadowoffx-2,y+h+shadowoffy-1,tocolor(0,0,0,255*galpha),txtSizX,txtSizY,font,tplt[1],tplt[2],clip,wordbreak,rendSet,colorcoded)
end
dxDrawText(eleData.text,px,y,px+w-1,y+h-1,applyColorAlpha(eleData.textcolor,galpha),txtSizX,txtSizY,font,tplt[1],tplt[2],clip,wordbreak,rendSet,colorcoded)
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx then
if mx >= cx and mx<= cx+w and my >= cy and my <= cy+h then
MouseData.hit = v
end
end
else
visible = false
end
elseif dxType == "dgs-dxedit" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local bgimage = eleData.bgimage
local bgcolor = eleData.bgcolor
bgcolor = applyColorAlpha(bgcolor,galpha)
local edit = eleData.edit
if not isElement(edit) then
destroyElement(v)
return
end
if MouseData.nowShow == v then
if isConsoleActive() or isMainMenuActive() or isChatBoxInputActive() then
MouseData.nowShow = false
end
end
local text = eleData.text
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
text = fnc[1](unpack(fnc[2])) or text
end
end
------------------------------------
guiSetText(edit,text)
if eleData.masked then
text = string.rep(eleData.maskText,utf8.len(text))
end
if MouseData.nowShow == v then
if getKeyState("lctrl") and getKeyState("a") then
dgsSetData(v,"cursorpos",0)
dgsSetData(v,"selectfrom",utf8.len(text))
end
end
local cursorPos = eleData.cursorpos
local selectFro = eleData.selectfrom
local selectcolor = eleData.selectcolor
guiEditSetCaretIndex(edit,cursorPos)
guiSetProperty(edit,"SelectionStart",cursorPos)
guiSetProperty(edit,"SelectionLength",selectFro-cursorPos)
guiSetVisible(edit,visible)
local font = eleData.font or systemFont
local txtSizX,txtSizY = eleData.textsize[1],eleData.textsize[2] or eleData.textsize[1]
local renderTarget = eleData.renderTarget
if isElement(renderTarget) then
local textcolor = eleData.textcolor
local width = dxGetTextWidth(utf8.sub(text,0,cursorPos),txtSizX,font)
local selx = 0
if selectFro-cursorPos > 0 then
selx = dxGetTextWidth(utf8.sub(text,cursorPos+1,selectFro),txtSizX,font)
elseif selectFro-cursorPos < 0 then
selx = -dxGetTextWidth(utf8.sub(text,selectFro+1,cursorPos),txtSizX,font)
end
local showPos = eleData.showPos
dxSetRenderTarget(renderTarget,true)
local sideWhite = eleData.sideWhite
local sidelength,sideheight = sideWhite[1]-sideWhite[1]%1,sideWhite[2]-sideWhite[2]%1
local selectRectOffset = 0
if eleData.center then
selectRectOffset = dxGetTextWidth(text,txtSizX,font)
selectRectOffset = w/2-sidelength/2-showPos/2
end
if selx ~= 0 then
local caretHeight = eleData.caretHeight
local selStartY = sideheight+(h-sideheight*2)*(1-caretHeight)
local selEndY = (h-sideheight*2)*caretHeight-sideheight
dxDrawRectangle(width+showPos+selectRectOffset,selStartY,selx,selEndY,selectcolor)
end
dxDrawText(text,showPos,0,w,h,textcolor,txtSizX,txtSizY,font,eleData.center and "center" or "left","center",false,false,false,false)
if eleData.underline then
local textHeight = dxGetFontHeight(txtSizY,font)
local lineOffset = eleData.underlineOffset+h/2+textHeight/2
local lineWidth = eleData.underlineWidth
local textFontLen = eleData.textFontLen
dxDrawLine(showPos,lineOffset,showPos+textFontLen,lineOffset,textcolor,lineWidth)
end
dxSetRenderTarget(rndtgt)
local finalcolor
if not enabled[1] and not enabled[2] then
if type(eleData.disabledColor) == "number" then
finalcolor = eleData.disabledColor
elseif eleData.disabledColor == true then
local r,g,b,a = fromcolor(bgcolor,true)
local average = (r+g+b)/3*eleData.disabledColorPercent
finalcolor = tocolor(average,average,average,a)
else
finalcolor = bgcolor
end
else
finalcolor = bgcolor
end
if bgimage then
dxDrawImage(x,y,w,h,bgimage,0,0,0,finalcolor,rendSet)
else
dxDrawRectangle(x,y,w,h,finalcolor,rendSet)
end
local px,py,pw,ph = x+sidelength,y+sideheight,w-sidelength*2,h-sideheight*2
dxDrawImage(px,py,pw,ph,renderTarget,0,0,0,tocolor(255,255,255,255*galpha),rendSet)
if MouseData.nowShow == v and MouseData.editCursor then
local CaretShow = true
if eleData.readOnly then
CaretShow = eleData.readOnlyCaretShow
end
if CaretShow then
local caretHeight = eleData.caretHeight
local cursorStyle = eleData.cursorStyle
local selStartX = x+width+showPos+sidelength
if cursorStyle == 0 then
if -showPos <= width then
local selStartY = y+sideheight+(h-sideheight*2)*(1-caretHeight)
local selEndY = (h-sideheight*2)*caretHeight
dxDrawLine(selStartX-1,selStartY,selStartX-1,selEndY+selStartY,eleData.caretColor,eleData.cursorThick,isRenderTarget)
end
elseif cursorStyle == 1 then
local cursorWidth = dxGetTextWidth(utf8.sub(text,cursorPos+1,cursorPos+1),txtSizX,font)
if cursorWidth == 0 then
cursorWidth = txtSizX*8
end
if -showPos-cursorWidth <= width then
local offset = eleData.cursorOffset
local selStartY = y+h-sideheight*2
dxDrawLine(selStartX-1,selStartY-offset,selStartX+cursorWidth-1,selStartY-offset,eleData.caretColor,eleData.cursorThick,isRenderTarget)
end
end
end
end
end
local side = eleData.side
if side ~= 0 then
local sidecolor = eleData.sidecolor
dxDrawLine(x,y+side/2-1,x+w,y+side/2-1,sidecolor,side,isRenderTarget)
dxDrawLine(x+side/2-1,y-1,x+side/2-1,y+h,sidecolor,side,isRenderTarget)
dxDrawLine(x+w-side/2,y,x+w-side/2,y+h,sidecolor,side,isRenderTarget)
dxDrawLine(x,y+h-side/2,x+w,y+h-side/2,sidecolor,side,isRenderTarget)
end
------------------------------------
if not eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if enabled[1] and mx then
if mx >= cx and mx<= cx+w and my >= cy and my <= cy+h then
MouseData.hit = v
end
end
else
visible = false
end
elseif dxType == "dgs-dxmemo" then
local x,y,cx,cy = processPositionOffset(v,x,y,w,h,parent,rndtgt,OffsetX,OffsetY)
if x and y then
if eleData.PixelInt then
x,y,w,h = x-x%1,y-y%1,w-w%1,h-h%1
end
local bgimage = eleData.bgimage
local bgcolor = eleData.bgcolor
bgcolor = setColorAlpha(bgcolor,getColorAlpha(bgcolor)*galpha)
local memo = eleData.memo
if not isElement(memo) then
destroyElement(v)
end
if MouseData.nowShow == v then
if isConsoleActive() or isMainMenuActive() or isChatBoxInputActive() then
MouseData.nowShow = false
end
end
local text = eleData.text
local allLine = #text
if MouseData.nowShow == v then
if getKeyState("lctrl") and getKeyState("a") then
dgsSetData(v,"cursorposXY",{0,1})
dgsSetData(v,"selectfrom",{utf8.len(text[allLine]),allLine})
end
end
local cursorPos = eleData.cursorposXY
local selectFro = eleData.selectfrom
local selectcolor = eleData.selectcolor
local font = eleData.font or systemFont
local txtSizX,txtSizY = eleData.textsize[1],eleData.textsize[2]
local renderTarget = eleData.renderTarget
local fontHeight = dxGetFontHeight(eleData.textsize[2],font)
------------------------------------
if eleData.functionRunBefore then
local fnc = eleData.functions
if type(fnc) == "table" then
fnc[1](unpack(fnc[2]))
end
end
------------------------------------
if isElement(renderTarget) then
local selectMode = eleData.selectmode
local textcolor = eleData.textcolor
local showLine = eleData.showLine
local caretHeight = eleData.caretHeight-1
local canHoldLines = math.floor((h-4)/fontHeight)
canHoldLines = canHoldLines > allLine and allLine or canHoldLines
local selPosStart,selPosEnd,selStart,selEnd
dxSetRenderTarget(renderTarget,true)
if allLine > 0 then
local toShowLine = showLine+canHoldLines
toShowLine = toShowLine > #text and #text or toShowLine
local offset = eleData.showPos
if cursorPos[2] == selectFro[2] then
if selectFro[1]>cursorPos[1] then
selPosStart = cursorPos[1]
selPosEnd = selectFro[1]
else
selPosStart = selectFro[1]
selPosEnd = cursorPos[1]
end
if selectFro[2]>cursorPos[2] then
selStart = cursorPos[2]
selEnd = selectFro[2]
else
selStart = selectFro[2]
selEnd = cursorPos[2]
end
local startx = dxGetTextWidth(utf8.sub(text[selStart],0,selPosStart),txtSizX,font)
local selx = dxGetTextWidth(utf8.sub(text[selStart],selPosStart+1,selPosEnd),txtSizX,font)
dxDrawRectangle(offset+startx,2+(selStart-showLine)*fontHeight-fontHeight*caretHeight,selx,fontHeight*(caretHeight+1)-4,selectcolor)
else
if selectFro[2]>cursorPos[2] then
selStart = cursorPos[2]
selEnd = selectFro[2]
selPosStart = cursorPos[1]
selPosEnd = selectFro[1]
else
selStart = selectFro[2]
selEnd = cursorPos[2]
selPosStart = selectFro[1]
selPosEnd = cursorPos[1]
end
local startx = dxGetTextWidth(utf8.sub(text[selStart],0,selPosStart),txtSizX,font)
for i=selStart > showLine and selStart or showLine,selEnd < toShowLine and selEnd or toShowLine do
if i ~= selStart and i ~= selEnd then
local selx = dxGetTextWidth(text[i],txtSizX,font)
dxDrawRectangle(offset,2+(i-showLine)*fontHeight-fontHeight*caretHeight,selx,fontHeight*(caretHeight+1)-4,selectcolor)
elseif i == selStart then
local selx = dxGetTextWidth(utf8.sub(text[i],selPosStart+1),txtSizX,font)
dxDrawRectangle(offset+startx,2+(i-showLine)*fontHeight-fontHeight*caretHeight,selx,fontHeight*(caretHeight+1)-4,selectcolor)
elseif i == selEnd then
local selx = dxGetTextWidth(utf8.sub(text[i],0,selPosEnd),txtSizX,font)
dxDrawRectangle(offset,2+(i-showLine)*fontHeight-fontHeight*caretHeight,selx,fontHeight*(caretHeight+1)-4,selectcolor)
end
end
end
for i=showLine,toShowLine do
local ypos = (i-showLine)*fontHeight
dxDrawText(text[i],offset,ypos,dxGetTextWidth(text[i],txtSizX,font),fontHeight+ypos,textcolor,txtSizX,txtSizY,font,"left","top",true,false,false,false)
end
end
dxSetRenderTarget(rndtgt)
local finalcolor
if not enabled[1] and not enabled[2] then
if type(eleData.disabledColor) == "number" then
finalcolor = eleData.disabledColor
elseif eleData.disabledColor == true then
local r,g,b,a = fromcolor(bgcolor,true)
local average = (r+g+b)/3*eleData.disabledColorPercent
finalcolor = tocolor(average,average,average,a)
else
finalcolor = bgcolor
end
else
finalcolor = bgcolor
end
if bgimage then
dxDrawImage(x,y,w,h,bgimage,0,0,0,finalcolor,rendSet)
else
dxDrawRectangle(x,y,w,h,finalcolor,rendSet)
end
local scbThick = eleData.scrollBarThick
local scrollbars = eleData.scrollbars
local scbTakes1,scbTakes2 = dgsElementData[scrollbars[1]].visible and scbThick+2 or 4,dgsElementData[scrollbars[2]].visible and scbThick or 0
dxDrawImageSection(x+2,y,w-scbTakes1,h-scbTakes2,0,0,w-scbTakes1,h-scbTakes2,renderTarget,0,0,0,tocolor(255,255,255,255*galpha),rendSet)
if MouseData.nowShow == v and MouseData.memoCursor then
local CaretShow = true
if eleData.readOnly then