forked from thisdp/dgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathG2DManager_s.lua
More file actions
915 lines (879 loc) · 26.1 KB
/
G2DManager_s.lua
File metadata and controls
915 lines (879 loc) · 26.1 KB
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
---Speed UP
utf8Sub = utf8.sub
local function tableCount(tabl)
local cnt = 0
for k,v in pairs(tabl) do
cnt = cnt + 1
end
return cnt
end
G2D = {}
G2D.backup = true
G2D.select = {}
G2DHelp = {
--Options,Extra,Argument,Comment
{"-add","Resource Name","Retain selections and select other resources (-m :Pattern Match)"},
{"-c"," ","Clear selections"},
{"-h"," ","G2D Help"},
{"-rm","Resource Name","Remove specific selected resources from list (-m :Pattern Match)"},
{"-l"," ","List all selected resources"},
{"-e"," ","Start to convert"},
{"-q"," ","Stop converting process"},
}
addCommandHandler("g2d",function(player,command,...)
if not dgsConfig.g2d then return end
local account = getPlayerAccount(player)
if account then
local accn = getAccountName(account)
if accn == "Console" then
local args = {...}
if args[1] == "-rm" or args[1] == "-remove" then
if args[2] and args[2] ~= "" then
if args[3] == "-m" or args[3] == "-match" then
for k,v in pairs(G2D.select) do
if string.match(k:lower(),args[2]:lower()) then
G2D.select[k] = nil
end
end
else
for k,v in pairs(G2D.select) do
if k:lower() == args[2]:lower() then
G2D.select[k] = nil
end
end
end
outputDebugString("[DGS-G2D] Selected "..tableCount(G2D.select).." resources, to see the selections, use -l")
else
outputDebugString("[DGS-G2D] Selected 0 resources, to see the selections, use -l")
end
elseif args[1] == "-a" or args[1] == "-add" then
if args[2] and args[2] ~= "" then
if args[3] == "-m" or args[3] == "-match" then
for k,v in ipairs(getResources()) do
local resN = getResourceName(v)
if string.match(resN:lower(),args[2]:lower()) then
G2D.select[resN] = v
end
end
else
for k,v in ipairs(getResources()) do
local resN = getResourceName(v)
if resN:lower() == args[2]:lower() then
G2D.select[resN] = v
end
end
end
outputDebugString("[DGS-G2D] Selected "..tableCount(G2D.select).." resources, to see the selections, use -l")
else
outputDebugString("[DGS-G2D] Selected 0 resources, to see the selections, use -l")
end
elseif args[1] == "-l" or args[1] == "-list" then
outputDebugString("[DGS-G2D] There are "..tableCount(G2D.select).." resources selected:")
for k,v in pairs(G2D.select) do
outputDebugString(k)
end
elseif args[1] == "-c" or args[1] == "-clear" then
G2D.select = {}
outputDebugString("[DGS-G2D] Selections cleared!")
elseif args[1] == "-e" or args[1] == "-exe" then
if not G2D.Process then
print("[DGS-G2D] Scanning files...")
local process = {}
for resN,res in pairs(G2D.select) do
local xml = xmlLoadFile(":"..resN.."/meta.xml")
for k,v in pairs(xmlNodeGetChildren(xml)) do
if xmlNodeGetName(v) == "script" and xmlNodeGetAttribute(v,"type") == "client" then
local path = xmlNodeGetAttribute(v,"src")
table.insert(process,":"..resN.."/"..path)
end
end
end
print("[DGS-G2D] "..#process.." files to be converted")
G2D.Process = true
G2D.Running = {}
G2D.Files = process
G2DStart()
else
print("[DGS-G2D] G2D is running!")
end
elseif args[1] == "-q" then
if G2D.Process then
print("[DGS-G2D] G2D process terminated!")
G2D.Process = false
else
print("[DGS-G2D] G2D is not running!")
end
else
outputDebugString("[DGS-G2D] Command help")
outputDebugString("Option Arguments Comment")
for i=1,#G2DHelp do
local items = G2DHelp[i]
outputDebugString(items[1].." "..items[2].." "..items[3])
end
end
end
end
end)
local keyword = {
["and"] = 1,
["break"] = 2,
["do"] = 3,
["else"] = 4,
["elseif"] = 5,
["end"] = 6,
["false"] = 7,
["for"] = 8,
["function"] = 9,
["if"] = 10,
["in"] = 11,
["local"] = 12,
["nil"] = 13,
["not"] = 14,
["or"] = 15,
["repeat"] = 16,
["return"] = 17,
["then"] = 18,
["true"] = 19,
["until"] = 20,
["while"] = 21,
}
local singleCharType = {
["+"]="operator",
["-"]="operator",
["*"]="operator",
["/"]="operator",
["%"]="operator",
["^"]="operator",
["#"]="operator",
[":"]="operator",
["\\"]="operator",
[","]="separator",
[";"]="separator",
["["]="separator",
["]"]="separator",
["{"]="separator",
["}"]="separator",
["("]="separator",
[")"]="separator",
}
local filter = {
" ","\v","\t","\r","\n",
}
local FRI = {} --Filter Reverse Index
for i=1,#filter do
FRI[filter[i]] = i
end
local function isLetter(letter,isIdentifier)
return (letter >= 'a' and letter <= 'z') or (letter >= 'A' and letter <= 'Z') or (isIdentifier and letter == '_')
end
local digital = {}
local digitalHex = {A="A",B="B",C="C",D="D",E="E",F="F",a="a",b="b",c="c",d="d",e="e",f="f"}
for i=0,9 do
digital[""..i..""]=i
end
local function isSpace(letter)
return letter == " " or letter == " "
end
local function isDigital(letter,isHex)
if isHex then
return digital[letter] or digitalHex[letter] or false
else
return digital[letter] or false
end
end
local transfer = {
a = "\\a",
b = "\\b",
f = "\\f",
n = "\\n",
r = "\\r",
t = "\\t",
v = "\\v",
}
LexState = {}
setmetatable(LexState,{
__call = function(self,readText)
return {
buffer="",
line=1,
prevLine=1,
prevIndex=0,
token="",
index=0,
checkindex=0,
lineIndex=0,
current="",
result={},
textLength=utf8.len(readText),
readText=readText,
next=function(self)
self.index = self.index+1
self.lineIndex = self.lineIndex+1
self.current = utf8Sub(self.readText,self.index,self.index)
if self.current == "\n" then
self.line = self.line+1
self.lineIndex=1
end
self.checkindex = self.index
return self.current ~= "" and self.current or false
end,
outputnext=function(self)
return utf8Sub(self.readText,self.index+1,self.index+1)
end,
checknext=function(self,target,...)
self.checkindex = self.checkindex+1
local nextStr = utf8Sub(self.readText,self.checkindex,self.checkindex)
local targetType = type(target)
if targetType == "string" then
for i=1,#target do
if utf8Sub(target,i,i) == nextStr then
return true
end
end
elseif targetType == "function" then
return target(nextStr,...)
end
return false
end,
checksamenext=function(self,target,...)
local nextStr = utf8Sub(self.readText,self.checkindex,self.checkindex)
local targetType = type(target)
if targetType == "string" then
for i=1,#target do
if utf8Sub(target,i,i) == nextStr then
return true
end
end
elseif targetType == "function" then
return target(nextStr,...)
end
return false
end,
checkcurrent=function(self,target)
for i=1,#target do
if utf8Sub(target,i,i) == nextStr then
return true
end
end
return false
end,
save=function(self,c)
self.buffer = self.buffer..(c or self.current)
end,
resetbuffer=function(self)
self.buffer = ""
end,
saveline=function(self)
self.prevIndex = self.lineIndex
self.prevLine = self.line
end,
finish=function(self,token)
self.prevIndex = self.index
self.prevLine = self.line
self.result[#self.result+1] = {self.buffer,token or singleCharType[self.buffer] or "undefined",self.line}
self.buffer = ""
end
}
end
})
local function throw(ls,err)
G2D.Process = false
assert(false,"[Line:"..ls.prevLine..",Index:"..ls.prevIndex.."]"..err)
end
local function readstring(ls,terminal)
ls:saveline()
while(ls:next() ~= terminal) do
if ls.current == "" or ls.current == "\r" or ls.current == "\n" then
throw(ls,"unfinished short string")
elseif ls.current == "\\" then
ls:next() --skip "\"
if transfer[ls.current] then
ls:save(transfer[ls.current])
elseif ls.current == "\r" or ls.current == "\n" then
if ls.current == "\r" then
ls:save("\\r")
ls:next()
end
if ls.current == "\n" then
ls:save("\\n")
end
elseif ls.current == "\\" then
ls:save("\\\\")
elseif isDigital(ls.current) then
local i = 1
local c = ""
repeat
c = c..ls.current
until(ls:next() and (not isDigital(ls.current) or i >= 3))
if c > "255" then
throw(ls,"escape sequence too large")
end
ls.save(c:char())
else
ls:save("\\")
ls:save()
end
else
ls:save()
end
end
ls:finish("short string")
end
local function readlongstring(ls,isComment)
ls:saveline()
while(ls:next()) do
if ls.current == "" then
throw(ls,"unfinished long string")
elseif ls.current == "]" then
if ls:checknext("]") then
ls:next() --skip the second ]
ls:finish(isComment or "long string")
break
else
ls:save()
end
else
ls:save()
end
end
end
local function readnumber(ls)
ls:saveline()
local isHex
if ls.current == "0" and ls:checksamenext("Xx") then
ls:save() --save 0
ls:next() --next
ls:save() --save x
ls:next() --next
isHex = true
if not isDigital(ls.current,isHex) then
throw(ls,"malformed number (1)")
end
end
repeat
ls:save()
if not ls:checknext(isDigital,isHex) then break end
until(not ls:next())
if not isHex and ls:checksamenext("Ee") then
ls:next()
ls:save()
ls:next()
if ls:checkcurrent("+-") then
ls:save()
ls:next()
end
elseif ls:checksamenext(".") then
ls:next()
ls:save()
ls:next()
else
ls:finish("number")
return
end
if not isDigital(ls.current,isHex) then
throw(ls,"malformed number (2)")
end
repeat
ls:save()
if not ls:checksamenext(isDigital,isHex) then break end
until(not ls:next())
if ls.current == "e" then
ls:next()
if isLetter(ls.current,true) or ls:checkcurrent(".") then
throw(ls,"malformed number (3) "..ls.current.."")
end
repeat
ls:save()
if not ls:checknext(isDigital,isHex) then break end
until(not ls:next())
elseif isLetter(ls.current,true) or ls:checkcurrent(".") then
throw(ls,"malformed number (3) "..ls.current.."")
end
ls:finish("number")
end
local function DGSLLex(ls)
ls:next()
while(ls.index <= ls.textLength) do
if ls.current == "\r" then
ls:save()
ls:finish("space")
elseif ls.current == "\n" then
ls:save()
ls:finish("space")
elseif ls.current == "\t" then
ls:save()
ls:finish("space")
elseif ls.current == "-" then --check operator or comment
if ls:checknext("-") then --comment
ls:next() --skip two -
ls:next()
if ls:checkcurrent("[") and ls:checknext("[") then --long comment
ls:next() --skip 1 [ , anther one gives the reader as start
readlongstring(ls,"long comment")
else --short comment
if ls:checkcurrent("\r\n") then
ls:finish("short comment")
else
local nnext
repeat
if ls:checknext("\r\n") then
ls:save()
break
end
ls:save()
until(not ls:next())
ls:finish("short comment")
end
end
else --operator
ls:save()
ls:finish("operator")
end
elseif ls.current == "[" then
if ls:checknext("[") then
ls:next() --skip 1 [
readlongstring(ls)
else
ls:save()
ls:finish("separator")
end
elseif ls.current == "'" or ls.current == '"' then
readstring(ls,ls.current)
elseif ls.current == "=" then
ls:save()
if ls:checknext("=") then
ls:next()
ls:save()
ls:finish("operator")
else
ls:finish("operator")
end
elseif ls.current == "<" then
ls:save()
if ls:checknext("=") then
ls:next()
ls:save()
ls:finish("operator")
else
ls:finish("operator")
end
elseif ls.current == ">" then
ls:save()
if ls:checknext("=") then
ls:next()
ls:save()
ls:finish("operator")
else
ls:finish("operator")
end
elseif ls.current == "~" then
ls:save()
if ls:checknext("=") then
ls:next()
ls:save()
ls:finish("operator")
else
ls:finish("operator")
end
elseif ls.current == "." then
if ls:checknext(".") then
ls:save()
ls:next()
ls:save()
if ls:checknext(".") then
ls:next()
ls:save()
ls:finish("operator")
else
ls:finish("operator")
end
else
if ls:checknext(isDigital) then
readnumber(ls)
else
ls:save()
ls:finish("operator")
end
end
else
if isSpace(ls.current) then
ls:save()
ls:finish("space")
elseif isDigital(ls.current) then
readnumber(ls)
elseif isLetter(ls.current,true) then
repeat
ls:save()
if (not ls:checknext(isLetter,true)) and (not ls:checksamenext(isDigital)) then break end
until(not ls:next())
if keyword[ls.buffer] then
ls:finish("keyword")
else
ls:finish("identifier")
end
else
ls:save()
ls:finish()
end
end
ls:next()
end
end
OPRS = {"ADD","SUB","MUL","DIV","MOD","POW","CONCAT","LT","GT","NE","EQ","LE","GE","AND","OR","NOBINOPR","NOT","MINUS","LEN","NOUNOPR"}
OPR = {}
for i=1,#OPRS do
OPR[OPRS[i]] = i
end
TKOPRTransf = {
["~"]=OPR.NOT,
["-"]=OPR.MINUS,
["#"]=OPR.LEN,
["+"]=OPR.ADD,
["-"]=OPR.SUB,
["*"]=OPR.MUL,
["/"]=OPR.DIV,
["%"]=OPR.MOD,
["^"]=OPR.POW,
[".."]=OPR.CONCAT,
["<"]=OPR.LT,
[">"]=OPR.GT,
["~="]=OPR.NE,
["=="]=OPR.EQ,
["<="]=OPR.LE,
[">="]=OPR.GE,
["and"]=OPR.AND,
["or"]=OPR.OR,
}
function getUNOPR(op)
return TKOPRTransf[op] or OPR.NOUNOPR
end
function getBINOPR(op)
return TKOPRTransf[op] or OPR.NOBINOPR
end
AnalyzerState = {}
setmetatable(AnalyzerState,{
__call = function(self,lexResult)
return {
tokenIndex=0,
separatorDepth = 0,
blockDepth = 0,
lexResult=lexResult,
replacedFunction = {},
replacedEvent = {},
executeProcess = function(self)
local GUIFnc = self.replacedFunction[1]
local DGSFnc = self.replacedFunction[2]
local GUIEvt = self.replacedEvent[1]
local DGSEvt = self.replacedEvent[2]
local resLen = #self.lexResult
while(true) do
local item = self:getNext()
if not item then break end
if item[2] == "identifier" and GUIFnc then
if item[1] == GUIFnc[1] then -- matched, get into the process
self.lexResult[self.tokenIndex][1] = DGSFnc[1]
end
elseif item[2] == "short string" and DGSEvt then
if item[1] == GUIEvt[1] then
self.lexResult[self.tokenIndex][1] = DGSEvt[1]
end
end
end
end,
getNext = function(self,dontSkipSpace)
self.tokenIndex = self.tokenIndex+1
if self.lexResult[self.tokenIndex] and self.lexResult[self.tokenIndex][2] == "space" and not dontSkipSpace then
return self:getNext()
end
return self.lexResult[self.tokenIndex]
end,
getCurrent = function(self)
return self.lexResult[self.tokenIndex]
end,
removeCurrent = function(self)
table.remove(self.lexResult,self.tokenIndex)
return self.tokenIndex
end,
insertCurrent = function(self,insert)
table.insert(self.lexResult,self.tokenIndex,insert)
end,
set = function(self,repFnc,isEvent)
if isEvent then
self.replacedEvent = repFnc
self.replacedFunction = {}
else
self.replacedEvent = {}
self.replacedFunction = repFnc
end
self.tokenIndex=0
self.separatorDepth = 0
end,
generateFile = function(self,filename)
local path = filename:sub(2)
local file = fileCreate("G2DOutput/"..path)
local newtab = {}
local isDGSDef = false
for i=1,#self.lexResult do
if self.lexResult[i][2] == "short comment" then
newtab[i] = "--"..self.lexResult[i][1]
elseif self.lexResult[i][2] == "long comment" then
newtab[i] = "--[["..self.lexResult[i][1].."]]"
elseif self.lexResult[i][2] == "short string" then
newtab[i] = "\""..self.lexResult[i][1].."\""
elseif self.lexResult[i][2] == "long string" then
newtab[i] = "[["..self.lexResult[i][1].."]]"
else
newtab[i] = self.lexResult[i][1]
end
if self.lexResult[i][1] == "__DGSDef" then
isDGSDef = true
end
end
if not isDGSDef then
table.insert(newtab,1,Hooker)
end
fileWrite(file,table.concat(newtab))
fileClose(file)
end,
}
end
})
convertFunctionTable = {
{{"guiBringToFront"},{"dgsBringToFront"}},
{{"guiCreateFont"},{"dgsCreateFont"}},
{{"guiBlur"},{"dgsBlur"}},
{{"guiFocus"},{"dgsFocus"}},
{{"guiGetAlpha"},{"dgsGetAlpha"}},
{{"guiGetEnabled"},{"dgsGetEnabled"}},
{{"guiGetFont"},{"dgsGetFont"}},
{{"guiGetInputEnabled"},{"dgsGetInputEnabled"}},
{{"guiGetInputMode"},{"dgsGetInputMode"}},
{{"guiGetPosition"},{"dgsGetPosition"}},
{{"guiGetProperties"},{"dgsGetProperties"}},
{{"guiGetProperty"},{"dgsGetProperty"}},
{{"guiGetScreenSize"},{"dgsGetScreenSize"}},
{{"guiGetSize"},{"dgsGetSize"}},
{{"guiGetText"},{"dgsGetText"}},
{{"guiGetVisible"},{"dgsGetVisible"}},
{{"guiMoveToBack"},{"dgsMoveToBack"}},
{{"guiSetAlpha"},{"dgsSetAlpha"}},
{{"guiSetEnabled"},{"dgsSetEnabled"}},
{{"guiSetFont"},{"dgsSetFont"}},
{{"guiSetInputEnabled"},{"dgsSetInputEnabled"}},
{{"guiSetInputMode"},{"dgsSetInputMode"}},
{{"guiSetPosition"},{"dgsSetPosition"}},
{{"guiSetProperty"},{"dgsSetProperty"}},
{{"guiSetSize"},{"dgsSetSize"}},
{{"guiSetText"},{"dgsSetText"}},
{{"guiSetVisible"},{"dgsSetVisible"}},
{{"guiCreateBrowser"},{"dgsCreateBrowser"}},
{{"guiCreateButton"},{"dgsCreateButton"}},
{{"guiCheckBoxGetSelected"},{"dgsCheckBoxGetSelected"}},
{{"guiCheckBoxSetSelected"},{"dgsCheckBoxSetSelected"}},
{{"guiCreateCheckBox"},{"dgsCreateCheckBox"}},
{{"guiCreateComboBox"},{"dgsCreateComboBox"}},
{{"guiComboBoxAddItem"},{"dgsComboBoxAddItem"}},
{{"guiComboBoxClear"},{"dgsComboBoxClear"}},
{{"guiComboBoxGetItemCount"},{"dgsComboBoxGetItemCount"}},
{{"guiComboBoxGetItemText"},{"dgsComboBoxGetItemText"}},
{{"guiComboBoxGetSelected"},{"dgsComboBoxGetSelected"}},
{{"guiComboBoxIsOpen"},{"dgsComboBoxGetState"}},
{{"guiComboBoxRemoveItem"},{"dgsComboBoxRemoveItem"}},
{{"guiComboBoxSetItemText"},{"dgsComboBoxSetItemText"}},
{{"guiComboBoxSetOpen"},{"dgsComboBoxSetState"}},
{{"guiComboBoxSetSelected"},{"dgsComboBoxSetSelected"}},
{{"guiCreateEdit"},{"dgsCreateEdit"}},
{{"guiEditGetCaretIndex"},{"dgsEditGetCaretPosition"}},
{{"guiEditGetMaxLength"},{"dgsEditGetMaxLength"}},
{{"guiEditIsMasked"},{"dgsEditGetMasked"}},
{{"guiEditIsReadOnly"},{"dgsEditGetReadOnly"}},
{{"guiEditSetCaretIndex"},{"dgsEditSetCaretPosition"}},
{{"guiEditSetMasked"},{"dgsEditSetMasked"}},
{{"guiEditSetMaxLength"},{"dgsEditSetMaxLength"}},
{{"guiEditSetReadOnly"},{"dgsEditSetReadOnly"}},
{{"guiCreateGridList"},{"dgsCreateGridList"}},
{{"guiGridListAddColumn"},{"dgsGridListAddColumn"}},
{{"guiGridListAddRow"},{"dgsGridListAddRow"}},
{{"guiGridListAutoSizeColumn"},{"dgsGridListAutoSizeColumn"}},
{{"guiGridListClear"},{"dgsGridListClear"}},
{{"guiGridListGetColumnCount"},{"dgsGridListGetColumnCount"}},
{{"guiGridListGetColumnTitle"},{"dgsGridListGetColumnTitle"}},
{{"guiGridListGetColumnWidth"},{"dgsGridListGetColumnWidth"}},
{{"guiGridListGetItemColor"},{"dgsGridListGetItemColor"}},
{{"guiGridListGetItemData"},{"dgsGridListGetItemData"}},
{{"guiGridListGetItemText"},{"dgsGridListGetItemText"}},
{{"guiGridListGetRowCount"},{"dgsGridListGetRowCount"}},
{{"guiGridListGetSelectedCount"},{"dgsGridListGetSelectedCount"}},
{{"guiGridListGetSelectedItem"},{"dgsGridListGetSelectedItem"}},
{{"guiGridListGetSelectedItems"},{"dgsGridListGetSelectedItems"}},
{{"guiGridListGetSelectionMode"},{"dgsGridListGetSelectionMode"}},
{{"guiGridListIsSortingEnabled"},{"dgsGridListGetSortEnabled"}},
{{"guiGridListRemoveColumn"},{"dgsGridListRemoveColumn"}},
{{"guiGridListRemoveRow"},{"dgsGridListRemoveRow"}},
{{"guiGridListSetColumnTitle"},{"dgsGridListSetColumnTitle"}},
{{"guiGridListSetColumnWidth"},{"dgsGridListSetColumnWidth"}},
{{"guiGridListSetItemColor"},{"dgsGridListSetItemColor"}},
{{"guiGridListSetItemData"},{"dgsGridListSetItemData"}},
{{"guiGridListSetItemText"},{"dgsGridListSetItemText"}},
{{"guiGridListSetScrollBars"},{"dgsGridListSetScrollBarState"}},
{{"guiGridListSetSelectedItem"},{"dgsGridListSetSelectedItem"}},
{{"guiGridListSetSelectionMode"},{"dgsGridListSetSelectionMode"}},
{{"guiGridListSetSortingEnabled"},{"dgsGridListSetSortEnabled"}},
{{"guiCreateMemo"},{"dgsCreateMemo"}},
{{"guiMemoGetCaretIndex"},{"dgsMemoGetCaretIndex"}},
{{"guiMemoIsReadOnly"},{"dgsMemoIsReadOnly"}},
{{"guiMemoSetCaretIndex"},{"dgsMemoSetCaretIndex"}},
{{"guiMemoSetReadOnly"},{"dgsMemoSetReadOnly"}},
{{"guiCreateProgressBar"},{"dgsCreateProgressBar"}},
{{"guiProgressBarGetProgress"},{"dgsProgressBarGetProgress"}},
{{"guiProgressBarSetProgress"},{"dgsProgressBarSetProgress"}},
{{"guiCreateRadioButton"},{"dgsCreateRadioButton"}},
{{"guiRadioButtonGetSelected"},{"dgsRadioButtonGetSelected"}},
{{"guiRadioButtonSetSelected"},{"dgsRadioButtonSetSelected"}},
{{"guiCreateScrollBar"},{"dgsCreateScrollBar"}},
{{"guiScrollBarGetScrollPosition"},{"dgsScrollBarGetScrollPosition"}},
{{"guiScrollBarSetScrollPosition"},{"dgsScrollBarSetScrollPosition"}},
{{"guiCreateScrollPane"},{"dgsCreateScrollPane"}},
{{"guiScrollPaneSetScrollBars"},{"dgsScrollPaneSetScrollBarState"}},
{{"guiCreateStaticImage"},{"dgsCreateImage"}},
{{"guiStaticImageGetNativeSize"},{"dgsImageGetNativeSize"}},
{{"guiStaticImageLoadImage"},{"dgsImageSetImage"}},
{{"guiCreateTabPanel"},{"dgsCreateTabPanel"}},
{{"guiGetSelectedTab"},{"dgsGetSelectedTab"}},
{{"guiSetSelectedTab"},{"dgsSetSelectedTab"}},
{{"guiCreateTab"},{"dgsCreateTab"}},
{{"guiDeleteTab"},{"dgsDeleteTab"}},
{{"guiCreateLabel"},{"dgsCreateLabel"}},
{{"guiLabelGetColor"},{"dgsLabelGetColor"}},
{{"guiLabelGetFontHeight"},{"dgsLabelGetFontHeight"}},
{{"guiLabelGetTextExtent"},{"dgsLabelGetTextExtent"}},
{{"guiLabelSetColor"},{"dgsLabelSetColor"}},
{{"guiLabelSetHorizontalAlign"},{"dgsLabelSetHorizontalAlign"}},
{{"guiLabelSetVerticalAlign"},{"dgsLabelSetVerticalAlign"}},
{{"guiCreateWindow"},{"dgsCreateWindow"}},
{{"guiWindowIsMovable"},{"dgsWindowGetMovable"}},
{{"guiWindowIsSizable"},{"dgsWindowGetSizable"}},
{{"guiWindowSetMovable"},{"dgsWindowSetMovable"}},
{{"guiWindowSetSizable"},{"dgsWindowSetSizable"}},
{{"guiGridListGetHorizontalScrollPosition"},{"dgsGridListGetHorizontalScrollPosition"}},
{{"guiGridListSetHorizontalScrollPosition"},{"dgsGridListSetHorizontalScrollPosition"}},
{{"guiGridListGetVerticalScrollPosition"},{"dgsGridListGetVerticalScrollPosition"}},
{{"guiGridListSetVerticalScrollPosition"},{"dgsGridListSetVerticalScrollPosition"}},
{{"guiMemoGetVerticalScrollPosition"},{"dgsMemoGetVerticalScrollPosition"}},
{{"guiMemoSetVerticalScrollPosition"},{"dgsMemoSetVerticalScrollPosition"}},
{{"guiScrollPaneGetHorizontalScrollPosition"},{"dgsScrollPaneGetHorizontalScrollPosition"}},
{{"guiScrollPaneGetVerticalScrollPosition"},{"dgsScrollPaneGetVerticalScrollPosition"}},
{{"guiScrollPaneSetHorizontalScrollPosition"},{"dgsScrollPaneSetHorizontalScrollPosition"}},
{{"guiScrollPaneSetVerticalScrollPosition"},{"dgsScrollPaneSetVerticalScrollPosition"}},
{{"guiGridListInsertRowAfter"},{"dgsGridListInsertRowAfter"}},
{{"guiGetBrowser"},{"dgsGetBrowser"}},
}
Hooker = [[
----------GUI To DGS Converted----------
if not getElementData(root,"__DGSDef") then
setElementData(root,"__DGSDef",true)
addEvent("onDgsEditAccepted-C",true)
addEvent("onDgsTextChange-C",true)
addEvent("onDgsComboBoxSelect-C",true)
addEvent("onDgsTabSelect-C",true)
function fncTrans(...)
triggerEvent(eventName.."-C",source,source,...)
end
addEventHandler("onDgsEditAccepted",root,fncTrans)
addEventHandler("onDgsTextChange",root,fncTrans)
addEventHandler("onDgsComboBoxSelect",root,fncTrans)
addEventHandler("onDgsTabSelect",root,fncTrans)
loadstring(exports.dgs:dgsImportFunction())()
end
----------GUI To DGS Converted----------
]]
converEventTable = {
{{"onClientGUIAccepted", },{"onDgsEditAccepted-C"}},
{{"onClientGUIBlur", },{"onDgsBlur"}},
{{"onClientGUIChanged", },{"onDgsTextChange-C"}},
{{"onClientGUIClick", },{"onDgsMouseClickUp"}},
{{"onClientGUIComboBoxAccepted", },{"onDgsComboBoxSelect-C"}},
{{"onClientGUIDoubleClick", },{"onDgsMouseDoubleClick"}},
{{"onClientGUIFocus", },{"onDgsFocus"}},
{{"onClientGUIMouseDown", },{"onDgsMouseDown"}},
{{"onClientGUIMouseUp", },{"onDgsMouseUp"}},
{{"onClientGUIMove", },{"onDgsElementMove"}},
{{"onClientGUIScroll", },{"onDgsElementScroll"}},
{{"onClientGUISize", },{"onDgsElementSize"}},
{{"onClientGUITabSwitched", },{"onDgsTabSelect-C"}},
{{"onClientMouseEnter", },{"onDgsMouseEnter"}},
{{"onClientMouseLeave", },{"onDgsMouseLeave"}},
{{"onClientMouseMove", },{"onDgsMouseMove"}},
{{"onClientMouseWheel", },{"onDgsMouseWheel"}},
}
function showProgress(progress)
print("[G2D] Progress "..string.format("%.2f",progress).."%")
end
G2DRunningData = {
File=false,
Timer= false
}
function G2DStart()
local k,filename = next(G2D.Files,(G2D.Running or {})[2])
if not filename then
G2D.Process = false
return print("[G2D] Process Done")
end
local cor = coroutine.create(processFile)
G2D.Running = {cor,k}
G2D.StartTick = getTickCount()
local result,errmess = coroutine.resume(cor,filename)
if not result then
print(errmess)
end
end
function processExpired(isEnd)
if not isEnd then
setTimer(function()
G2D.StartTick = getTickCount()
coroutine.resume(G2D.Running[1])
end,50,1)
else
G2DStart()
end
end
function processFile(filename)
print("[G2D] Start to process file '"..filename.."'")
local file = fileOpen(filename)
local str = fileRead(file,fileGetSize(file))
local utf8BOM = false
local txtByte = {str:byte(1,3)}
if txtByte[1] == 0xEF and txtByte[2] == 0xBB and txtByte[3] == 0xBF then
str = str:sub(4)
utf8BOM = true
end
fileClose(file)
local ls = LexState(str)
DGSLLex(ls)
local az = AnalyzerState(ls.result)
local convTabCnt = #convertFunctionTable
print("[G2D] Replacing Functions")
for i=1,convTabCnt do
az:set(convertFunctionTable[i])
az:executeProcess()
if getTickCount()-G2D.StartTick >= 100 then
showProgress((i-1)/convTabCnt*100)
processExpired()
coroutine.yield()
end
end
local convTabCnt = #converEventTable
print("[G2D] Replacing Events")
for i=1,convTabCnt do
az:set(converEventTable[i],true)
az:executeProcess()
if getTickCount()-G2D.StartTick >= 100 then
showProgress((i-1)/convTabCnt*100)
processExpired()
coroutine.yield()
end
end
showProgress(100)
az:generateFile(filename,utf8BOM)
return processExpired(true)
end