-
Notifications
You must be signed in to change notification settings - Fork 34
/
dgsExportedFunction.lua
622 lines (609 loc) · 23.5 KB
/
dgsExportedFunction.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
dgsLogLuaMemory()
local loadstring = loadstring
dgsExportedFunctionName = {}
dgsResName = getResourceName(resource)
addEventHandler("onClientResourceStart",resourceRoot,function()
triggerEvent("onDgsStart",resourceRoot,dgsResName)
end)
function dgsImportFunction()
if not sourceResource or sourceResource == resource then return "return true" end
local allCode = [[
--Check Error Message Above
if not dgsImportHead then
local getResourceRootElement = getResourceRootElement
local call = call
local getResourceFromName = getResourceFromName
local tostring = tostring
local unpack = unpack
local outputDebugString = outputDebugString
local DGSCallMT = {}
local functionCallLogger = {}
dgsImportHead = {}
dgsImportHead.dgsName = "]]..dgsResName..[["
dgsImportHead.dgsResource = getResourceFromName(dgsImportHead.dgsName)
dgsRoot = getResourceRootElement(dgsImportHead.dgsResource)
dgsImportHead.dgsTypes = getElementData(dgsRoot,"DGSType")
addEventHandler("onClientResourceStop",dgsRoot,function()
outputDebugString("[DGS] Alert! DGS has stopped. Everything keeps disconnected from DGS till the next time DGS starts!",2)
function onDgsStart(dResN)
outputDebugString("[DGS] DGS has started, reconnecting to DGS...",3)
dgsImportHead = nil
dgsRoot = nil
loadstring(exports[dResN]:dgsImportFunction())()
removeEventHandler("onDgsStart",root,onDgsStart)
end
addEventHandler("onDgsStart",root,onDgsStart)
end)
local isTraceDebug = getElementData(localPlayer,"DGS-DebugTracer") or (getElementData(localPlayer,"DGS-DEBUG") == 3)
addEventHandler("onClientElementDataChange",localPlayer,function(key,_,v)
if key == "DGS-DebugTracer" or key == "DGS-DEBUG" then
isTraceDebug = getElementData(localPlayer,"DGS-DebugTracer") and (getElementData(localPlayer,"DGS-DEBUG") == 3)
end
end,false)
local fncCallLoggerDef = {line=-1,file="Unknown",fncName="Unknown"}
local fncCallLoggerSelf = {line=-1,file="Unknown",fncName="Unknown"}
function DGSCallMT:__index(fncName)
if type(fncName) ~= 'string' then fncName = tostring(fncName) end
self[fncName] = function(...)
if not dgsImportHead then return outputDebugString("[DGS] "..getResourceName(getThisResource())..": DGS import data is missing or DGS is not running, please reimport dgs functions",4,255,0,0) end
if isElement(dgsRoot) then
local isCreateFunction = fncName:sub(1,9) == "dgsCreate"
if isTraceDebug then
local data
local index = 1
local isLocated = false
repeat
local d = debug.getinfo(index)
if not d then break end
data = d
index = index+1
if data.func == self[fncName] then
if isLocated == true then
break
else
isLocated = true --Need to get the next index
end
end
until data and data.source:sub(1,1) == "@"
if data then
functionCallLogger = fncCallLoggerSelf
functionCallLogger.line=data.currentline
functionCallLogger.file=data.source
functionCallLogger.fncName=fncName
local retValue = {call(dgsImportHead.dgsResource, fncName, ...)}
if isCreateFunction and isElement(retValue[1]) and dgsGetType(retValue[1],true) then
call(dgsImportHead.dgsResource, "dgsSetProperty",retValue[1],"debugTrace",functionCallLogger)
end
return unpack(retValue)
else
functionCallLogger = fncCallLoggerDef
end
end
return call(dgsImportHead.dgsResource, fncName, ...)
else
dgsImportHead = nil
dgsRoot = nil
return nil
end
end
return self[fncName]
end
addEventHandler("DGSI_onDebugRequestContext",resourceRoot,function()
triggerEvent("DGSI_onDebugSendContext",resourceRoot,functionCallLogger)
end,false)
addEventHandler("DGSI_onDebug",resourceRoot,function(debugType,...)
if isTraceDebug then
if debugType == "PropertyCompatibility" then
local line,file,fncName = functionCallLogger.line,functionCallLogger.file,functionCallLogger.fncName
local oldPropertyName,newPropertyName = ...
outputDebugString("Compatibility Check "..file..":"..line.." @'"..fncName.."', replace property '"..oldPropertyName.."' with '"..newPropertyName.."'",4,255,180,100)
elseif debugType == "FunctionCompatibility" then
local line,file,fncName = functionCallLogger.line,functionCallLogger.file,functionCallLogger.fncName
local oldFunctionName,newFunctionName = ...
outputDebugString("Compatibility Check "..file..":"..line.." @'"..fncName.."', replace function '"..oldFunctionName.."' with '"..newFunctionName.."'",4,255,180,100)
elseif debugType == "ArgumentCompatibility" then
local line,file,fncName = functionCallLogger.line,functionCallLogger.file,functionCallLogger.fncName
local argument,detail = ...
outputDebugString("Compatibility Check "..file..":"..line.." @'"..fncName.."', at argument "..argument..". "..detail,4,255,180,100)
elseif debugType == "AnimationError" then
local property,file,line,fncName = ...
if file and line and fncName then
outputDebugString("Traced "..file..":"..line.." @'"..fncName.."'",4,255,180,100)
end
end
end
end,false)
DGS = setmetatable({}, DGSCallMT)
triggerEvent("DGSI_onImport",root,resourceRoot)
end
]]
for i,fnName in ipairs(getResourceExportedFunctions()) do
allCode = allCode.."\n "..fnName.." = DGS."..fnName..";"
end
return allCode
end
G2DHookerEvents = {}
function dgsG2DLoadHooker(isLocal)
if table.count(G2DHookerEvents) == 0 then
addEventHandler("onDgsEditAccepted",root,handleHookerEvents)
addEventHandler("onDgsTextChange",root,handleHookerEvents)
addEventHandler("onDgsComboBoxSelect",root,handleHookerEvents)
addEventHandler("onDgsTabSelect",root,handleHookerEvents)
end
G2DHookerEvents[sourceResource or resource] = true
local usingLocal = isLocal and "local" or ""
return [[
if loadedG2D then return end
isGUIGridList = {}
isGUIComboBox = {}
loadedG2D = true
loadstring(exports["]]..dgsResName..[["]:dgsImportFunction())()
for fName,fnc in pairs(_G) do
if fName:sub(1,3) == "gui" then
_G["_"..fName] = fnc
end
end
--GUI TO DGS
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
guiSetInputEnabled = dgsSetInputEnabled
guiSetInputMode = dgsSetInputMode
guiSetPosition = dgsSetPosition
guiSetSize = function (gl,w,h,relative)
local v = dgsSetSize(gl,w,h,relative)
if _getElementType(gl) == "dgs-dxcombobox" then
local width,height = dgsGetSize(gl,false)
dgsSetSize(gl,width,22,false)
dgsComboBoxSetBoxHeight(gl,height-22,false)
end
return v
end
guiSetText = dgsSetText
guiSetVisible = dgsSetVisible
guiCreateBrowser = dgsCreateBrowser
guiCreateButton = dgsCreateButton
guiCheckBoxGetSelected = dgsCheckBoxGetSelected
guiCheckBoxSetSelected = dgsCheckBoxSetSelected
guiCreateCheckBox = dgsCreateCheckBox
guiCreateComboBox = function(...)
local x,y,w,h,caption,relative,parent = ...
local combobox = dgsCreateComboBox(x,y,w,h,caption,relative,parent)
local width,height = dgsGetSize(combobox,false)
dgsSetSize(combobox,width,22,false)
dgsSetProperty(combobox,"relative",{relative,relative})
dgsComboBoxSetBoxHeight(combobox,height-22,false)
isGUIComboBox[combobox] = true
addEventHandler("onDgsDestroy",combobox,function()
isGUIComboBox[source] = nil
end,false)
return combobox
end
guiComboBoxAddItem = dgsComboBoxAddItem
guiComboBoxClear = dgsComboBoxClear
guiComboBoxGetItemCount = dgsComboBoxGetItemCount
guiComboBoxGetItemText = function(combobox,item)
if not item or item == -1 then return false end
item = isGUIComboBox[combobox] and item+1 or item
if dgsComboBoxGetItemCount(combobox) < item then return false end
return dgsComboBoxGetItemText(combobox,item)
end
guiComboBoxGetSelected = function(combobox,...)
if isGUIComboBox[combobox] then
local selectedItem = dgsComboBoxGetSelectedItem(combobox,...)
selectedItem = selectedItem == -1 and -1 or selectedItem-1
return selectedItem
else
return dgsComboBoxGetSelectedItem(combobox,...)
end
end
guiComboBoxIsOpen = dgsComboBoxGetState
guiComboBoxRemoveItem = function(combobox,item,...)
if item and item ~= -1 then
item = isGUIComboBox[combobox] and item+1 or item
end
if item and dgsComboBoxGetItemCount(combobox) < item then return false end
return dgsComboBoxRemoveItem(combobox,item,...)
end
guiComboBoxSetItemText = function(combobox,item,...)
if item and item ~= -1 then
item = isGUIComboBox[combobox] and item+1 or item
end
if item and dgsComboBoxGetItemCount(combobox) < item then return false end
return dgsComboBoxSetItemText(combobox,item,...)
end
guiComboBoxSetOpen = dgsComboBoxSetState
guiComboBoxSetSelected = function(combobox,item,...)
if item and isGUIComboBox[combobox] and item ~= -1 then
item = item+1
end
if item and dgsComboBoxGetItemCount(combobox) < item then return false end
return dgsComboBoxSetSelectedItem(combobox,item,...)
end
guiCreateEdit = dgsCreateEdit
guiEditGetCaretIndex = dgsEditGetCaretPosition
guiEditGetMaxLength = dgsEditGetMaxLength
guiEditIsMasked = dgsEditGetMasked
guiEditIsReadOnly = dgsEditGetReadOnly
guiEditSetCaretIndex = dgsEditSetCaretPosition
guiEditSetMasked = dgsEditSetMasked
guiEditSetMaxLength = dgsEditSetMaxLength
guiEditSetReadOnly = dgsEditSetReadOnly
guiCreateGridList = function(...)
local gl = dgsCreateGridList(...)
dgsSetProperty(gl,"defaultSortFunctions",{"numGreaterLowerStrFirst","numGreaterUpperStrFirst"})
isGUIGridList[gl] = true
addEventHandler("onDgsDestroy",gl,function()
isGUIGridList[source] = nil
end,false)
return gl
end
guiGridListAddColumn = dgsGridListAddColumn
guiGridListInsertRowAfter = function(gl,row,...)
if column and dgsGridListGetColumnCount(gl) == 0 then return false end
local rowData = dgsGetProperty(gl,"rowData")
if isGUIGridList[gl] then
row = tonumber(row) or #rowData
return dgsGridListInsertRowAfter(gl,row+1,...)-1
else
row = tonumber(row) or #rowData+1
return dgsGridListInsertRowAfter(gl,row,...)
end
end
guiGridListAddRow = function(gl,...)
local row = dgsGridListAddRow(gl,nil,...)
return row and row-1 or row
end
guiGridListGetItemColor = function(gl,row,column)
if column and dgsGridListGetColumnCount(gl) < column then return false end
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListGetItemColor(gl,row,column)
end
guiGridListGetItemData = function(gl,row,column)
if column and dgsGridListGetColumnCount(gl) < column then return false end
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListGetItemData(gl,row,column)
end
guiGridListSetItemData = function(gl,row,column,...)
if column and dgsGridListGetColumnCount(gl) < column then return false end
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListSetItemData(gl,row,column,...)
end
guiGridListGetItemText = function(gl,row,column,...)
if column and dgsGridListGetColumnCount(gl) < column then return false end
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListGetItemText(gl,row,column,...)
end
guiGridListSetItemText = function(gl,row,column,...)
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListSetItemText(gl,row,column,...)
end
guiGridListGetSelectedCount = dgsGridListGetSelectedCount
guiGridListGetSelectedItem = function(gl)
if isGUIGridList[gl] then
local selectedRow,selectedColumn = dgsGridListGetSelectedItem(gl)
selectedRow = selectedRow == -1 and -1 or selectedRow-1
selectedColumn = selectedColumn == -1 and 0 or selectedColumn
return selectedRow,selectedColumn
else
return dgsGridListGetSelectedItem(gl)
end
end
guiGridListGetSelectedItems = function(gl,isOrigin)
local newItems = dgsGridListGetSelectedItems(gl,isOrigin)
if not isOrigin then
for k,v in ipairs(newItems) do
newItems[k].row = newItems[k].row+1
end
else
--To Do
end
return newItems
end
guiGridListRemoveRow = function(gl,row,...)
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListRemoveRow(gl,row,...)
end
guiGridListSetItemColor = function(gl,row,column,...)
if column and dgsGridListGetColumnCount(gl) < column then return false end
if row and row ~= -1 then
row = isGUIGridList[gl] and row+1 or row
end
if row and dgsGridListGetRowCount(gl) < row then return false end
return dgsGridListSetItemColor(gl,row,column,...)
end
guiGridListSetSelectedItem = function(gl,row,column,...)
if column then
if column <= 0 then
column = -1
elseif dgsGridListGetColumnCount(gl) < column then
return false
end
end
if row then
if row <= -1 then
row = -1
elseif isGUIGridList[gl] then
row = row+1
if dgsGridListGetRowCount(gl) < row then
return false
end
end
end
return dgsGridListSetSelectedItem(gl,row,column,...)
end
guiGridListAutoSizeColumn = function (gl,column)
if column and dgsGridListGetColumnCount(gl) < column then return false end
return dgsGridListAutoSizeColumn(gl,column)
end
guiGridListClear = dgsGridListClear
guiGridListGetColumnCount = dgsGridListGetColumnCount
guiGridListGetColumnTitle = function (gl,column)
if column and dgsGridListGetColumnCount(gl) < column then return false end
return dgsGridListGetColumnTitle(gl,column)
end
guiGridListGetColumnWidth = function (gl,column,...)
if column and dgsGridListGetColumnCount(gl) < column then return false end
return dgsGridListGetColumnWidth(gl,column,...)
end
guiGridListGetRowCount = dgsGridListGetRowCount
guiGridListGetSelectionMode = dgsGridListGetSelectionMode
guiGridListIsSortingEnabled = dgsGridListGetSortEnabled
guiGridListRemoveColumn = function (gl,column)
if column and dgsGridListGetColumnCount(gl) < column then return false end
return dgsGridListRemoveColumn(gl,column)
end
guiGridListSetColumnTitle = function (gl,column,...)
if column and dgsGridListGetColumnCount(gl) < column then return false end
return dgsGridListSetColumnTitle(gl,column,...)
end
guiGridListSetColumnWidth = function (gl,column,...)
if column and dgsGridListGetColumnCount(gl) < column then return false end
return dgsGridListSetColumnWidth(gl,column,...)
end
guiGridListSetColumnTitle = dgsGridListSetColumnTitle
guiGridListSetColumnWidth = dgsGridListSetColumnWidth
guiGridListSetScrollBars = dgsGridListSetScrollBarState
guiGridListSetSelectionMode = function (gl,mode)
local selectionModes = {
[0] = {mode=1,multi=false},
[1] = {mode=1,multi=true},
[2] = {mode=3,multi=false},
[3] = {mode=3,multi=true},
[4] = {mode=2,multi=false},
[5] = {mode=2,multi=true},
[6] = {mode=2,multi=false},
[7] = {mode=2,multi=true},
[8] = {mode=3,multi=false},
[9] = {mode=3,multi=true},
}
local g2dMode = selectionModes[mode]
dgsGridListSetSelectedItems(gl,{})
dgsGridListSetMultiSelectionEnabled(gl,g2dMode.multi)
return dgsGridListSetSelectionMode(gl,g2dMode.mode)
end
guiGridListSetSortingEnabled = dgsGridListSetSortEnabled
guiCreateMemo = dgsCreateMemo
guiMemoGetCaretIndex = dgsMemoGetCaretPosition
guiMemoIsReadOnly = dgsMemoIsReadOnly
guiMemoSetCaretIndex = dgsMemoSetCaretPosition
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 = function(...)
local window = dgsCreateWindow(...)
dgsSetProperty(window,"ignoreTitle",true)
dgsWindowSetCloseButtonEnabled(window,false)
return window
end
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
guiGetBrowser = dgsGetBrowser
local fontReplace = {
["default-normal"]="default",
["default-small"]="arial",
["default-bold-small"]="default-bold",
["clear-normal"]="clear",
["sa-gothic"]="beckett",
["sa-header"]="diploma",
}
guiSetFont = function(gl,font)
return dgsSetFont(gl,fontReplace[font] or font)
end
guiSetProperty = function(gl,prop,v)
local eleType = getElementType(gl)
if prop == "NormalTextColour" or prop == "HoverTextColour" or prop == "PushedTextColour" then
local a,r,g,b = getColorFromString("#"..v)
local ct = dgsGetProperty(gl,"textColor")
if prop == "NormalTextColour" and type (ct) ~= "table" then
return dgsSetProperty(gl,"textColor",tocolor(r,g,b,a))
else
if type(ct) ~= "table" then
ct = {ct}
end
ct[prop == "NormalTextColour" and 1 or prop == "HoverTextColour" and 2 or 3] = tocolor(r,g,b,a)
return dgsSetProperty(gl,"textColor",ct)
end
elseif prop == "Disabled" then
return dgsSetProperty(gl,"enabled",not v:lower() == "true")
elseif prop == "Visible" then
return dgsSetVisible(gl,v:lower() == "true")
elseif prop == "ReadOnly" then
return dgsSetProperty(gl,"readOnly",v:lower() == "true")
elseif prop == "Alpha" or prop == "Font" or prop == "Text" then
return dgsSetProperty(gl,prop:lower(),v)
elseif prop == "AlwaysOnTop" then
v = v:lower() == "true"
return dgsSetLayer(gl,v and "top" or "center")
else
return dgsSetProperty(gl,prop,v)
end
end
local eventReplace = {
onClientGUIAccepted="onDgsEditAccepted-C",
onClientGUIBlur="onDgsBlur",
onClientGUIChanged="onDgsTextChange-C",
onClientGUIClick="onDgsMouseClickUp",
onClientGUIComboBoxAccepted="onDgsComboBoxSelect-C",
onClientGUIDoubleClick="onDgsMouseDoubleClickUp",
onClientGUIFocus="onDgsFocus",
onClientGUIMouseDown="onDgsMouseDown",
onClientGUIMouseUp="onDgsMouseUp",
onClientGUIMove="onDgsElementMove",
onClientGUIScroll="onDgsElementScroll",
onClientGUISize="onDgsElementSize",
onClientGUITabSwitched="onDgsTabSelect-C",
onClientMouseEnter="onDgsMouseEnter",
onClientMouseLeave="onDgsMouseLeave",
onClientMouseMove="onDgsMouseMove",
onClientMouseWheel="onDgsMouseWheel",
}
_addEventHandler = addEventHandler
addEventHandler = function(event,...)
return _addEventHandler(eventReplace[event] or event,...)
end
_removeEventHandler = removeEventHandler
removeEventHandler = function(event,...)
return _removeEventHandler(eventReplace[event] or event,...)
end
local typeReplace ={
["dgs-dxbutton"]="gui-button",
["dgs-dxedit"]="gui-edit",
["dgs-dxprogressbar"]="gui-progressbar",
["dgs-dxwindow"]="gui-window",
["dgs-dxlabel"]="gui-label",
["dgs-dxscrollpane"]="gui-scrollpane",
["dgs-dxtab"]="gui-tab",
["dgs-dxmemo"]="gui-memo",
["dgs-dxtabpanel"]="gui-tabpanel",
["dgs-dximage"]="gui-staticimage",
["dgs-dxscrollbar"]="gui-scrollbar",
["dgs-dxcombobox"]="gui-combobox",
["dgs-dxcheckbox"]="gui-checkbox",
["dgs-dxradiobutton"]="gui-radiobutton",
["dgs-dxgridlist"]="gui-gridlist",
}
_getElementType = getElementType
getElementType = function(gl)
local typ = _getElementType(gl)
return typ and typeReplace[typ] or typ
end
]]
end
function handleHookerEvents(...)
triggerEvent(eventName.."-C",source,source,...)
end
-------Inside DGS
setElementData(root,"__DGSRes",resource,false)
addEventHandler("onClientResourceStop",resourceRoot,function() setElementData(root,"__DGSRes",false,false) end)
OOPImportCache = nil
OOPImportTimer = nil
function dgsImportOOPClass()
if OOPImportCache then return OOPImportCache end
local handle = fileOpen("classlib.lua", true)
local buffer = fileGetContents(handle)
fileClose(handle)
if not buffer then return outputChatBox("[DGS] Failed to load classlib.lua (File mismatch)",255,0,0) end
local str = buffer
if fileExists("customOOP.lua") then
local handle = fileOpen("customOOP.lua", true)
local buffer = fileGetContents(handle)
fileClose(handle)
if not buffer then outputChatBox("[DGS] Failed to load customOOP.lua (File mismatch)",255,0,0) end
local s = content:gsub("\r\n","\n")
local list = split(s,"\n")
for i=1,#list do
if fileExists(list[i]) then
local handle = fileOpen(list[i], true)
local buffer = fileGetContents(handle)
fileClose(handle)
if not buffer then outputChatBox("[DGS] Failed to load "..list[i].." (File mismatch)",255,0,0) end
local f,e = loadstring(buffer)
if f then
str = str.."\n"..buffer
else
outputDebugString("[DGS]Failed to load custom OOP script ("..list[i]..":"..e..")",1)
end
else
outputDebugString("[DGS]Failed to load custom OOP script (Could not find "..list[i]..")",1)
end
end
end
OOPImportCache = str
OOPImportTimer = setTimer(function()
OOPImportCache = nil
OOPImportTimer = nil
collectgarbage()
end,1000,1) --Clear cache
return OOPImportCache
end