forked from LorekeeperZinnia/Dex
-
Notifications
You must be signed in to change notification settings - Fork 5
/
out.lua
11113 lines (9619 loc) · 392 KB
/
out.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
local EmbeddedModules = {
["Explorer"] = function()
--[[
Explorer App Module
The main explorer interface
]]
-- Common Locals
local Main,Lib,Apps,Settings -- Main Containers
local Explorer, Properties, ScriptViewer, Notebook -- Major Apps
local API,RMD,env,service,plr,create,createSimple -- Main Locals
local function initDeps(data)
Main = data.Main
Lib = data.Lib
Apps = data.Apps
Settings = data.Settings
API = data.API
RMD = data.RMD
env = data.env
service = data.service
plr = data.plr
create = data.create
createSimple = data.createSimple
end
local function initAfterMain()
Explorer = Apps.Explorer
Properties = Apps.Properties
ScriptViewer = Apps.ScriptViewer
Notebook = Apps.Notebook
end
local function main()
local Explorer = {}
local nodes,tree,listEntries,explorerOrders,searchResults,specResults = {},{},{},{},{},{}
local expanded
local entryTemplate,treeFrame,toolBar,descendantAddedCon,descendantRemovingCon,itemChangedCon
local ffa = game.FindFirstAncestorWhichIsA
local getDescendants = game.GetDescendants
local getTextSize = service.TextService.GetTextSize
local updateDebounce,refreshDebounce = false,false
local nilNode = {Obj = Instance.new("Folder")}
local idCounter = 0
local scrollV,scrollH,selection,clipboard
local renameBox,renamingNode,searchFunc
local sortingEnabled,autoUpdateSearch
local table,math = table,math
local nilMap,nilCons = {},{}
local connectSignal = game.DescendantAdded.Connect
local addObject,removeObject,moveObject = nil,nil,nil
addObject = function(root)
if nodes[root] then return end
local isNil = false
local rootParObj = ffa(root,"Instance")
local par = nodes[rootParObj]
-- Nil Handling
if not par then
if nilMap[root] then
nilCons[root] = nilCons[root] or {
connectSignal(root.ChildAdded,addObject),
connectSignal(root.AncestryChanged,moveObject),
}
par = nilNode
isNil = true
else
return
end
elseif nilMap[rootParObj] or par == nilNode then
nilMap[root] = true
nilCons[root] = nilCons[root] or {
connectSignal(root.ChildAdded,addObject),
connectSignal(root.AncestryChanged,moveObject),
}
isNil = true
end
local newNode = {Obj = root, Parent = par}
nodes[root] = newNode
-- Automatic sorting if expanded
if sortingEnabled and expanded[par] and par.Sorted then
local left,right = 1,#par
local floor = math.floor
local sorter = Explorer.NodeSorter
local pos = (right == 0 and 1)
if not pos then
while true do
if left >= right then
if sorter(newNode,par[left]) then
pos = left
else
pos = left+1
end
break
end
local mid = floor((left+right)/2)
if sorter(newNode,par[mid]) then
right = mid-1
else
left = mid+1
end
end
end
table.insert(par,pos,newNode)
else
par[#par+1] = newNode
par.Sorted = nil
end
local insts = getDescendants(root)
for i = 1,#insts do
local obj = insts[i]
if nodes[obj] then continue end -- Deferred
local par = nodes[ffa(obj,"Instance")]
if not par then continue end
local newNode = {Obj = obj, Parent = par}
nodes[obj] = newNode
par[#par+1] = newNode
-- Nil Handling
if isNil then
nilMap[obj] = true
nilCons[obj] = nilCons[obj] or {
connectSignal(obj.ChildAdded,addObject),
connectSignal(obj.AncestryChanged,moveObject),
}
end
end
if searchFunc and autoUpdateSearch then
searchFunc({newNode})
end
if not updateDebounce and Explorer.IsNodeVisible(par) then
if expanded[par] then
Explorer.PerformUpdate()
elseif not refreshDebounce then
Explorer.PerformRefresh()
end
end
end
removeObject = function(root)
local node = nodes[root]
if not node then return end
-- Nil Handling
if nilMap[node.Obj] then
moveObject(node.Obj)
return
end
local par = node.Parent
if par then
par.HasDel = true
end
local function recur(root)
for i = 1,#root do
local node = root[i]
if not node.Del then
nodes[node.Obj] = nil
if #node > 0 then recur(node) end
end
end
end
recur(node)
node.Del = true
nodes[root] = nil
if par and not updateDebounce and Explorer.IsNodeVisible(par) then
if expanded[par] then
Explorer.PerformUpdate()
elseif not refreshDebounce then
Explorer.PerformRefresh()
end
end
end
moveObject = function(obj)
local node = nodes[obj]
if not node then return end
local oldPar = node.Parent
local newPar = nodes[ffa(obj,"Instance")]
if oldPar == newPar then return end
-- Nil Handling
if not newPar then
if nilMap[obj] then
newPar = nilNode
else
return
end
elseif nilMap[newPar.Obj] or newPar == nilNode then
nilMap[obj] = true
nilCons[obj] = nilCons[obj] or {
connectSignal(obj.ChildAdded,addObject),
connectSignal(obj.AncestryChanged,moveObject),
}
end
if oldPar then
local parPos = table.find(oldPar,node)
if parPos then table.remove(oldPar,parPos) end
end
node.Id = nil
node.Parent = newPar
if sortingEnabled and expanded[newPar] and newPar.Sorted then
local left,right = 1,#newPar
local floor = math.floor
local sorter = Explorer.NodeSorter
local pos = (right == 0 and 1)
if not pos then
while true do
if left >= right then
if sorter(node,newPar[left]) then
pos = left
else
pos = left+1
end
break
end
local mid = floor((left+right)/2)
if sorter(node,newPar[mid]) then
right = mid-1
else
left = mid+1
end
end
end
table.insert(newPar,pos,node)
else
newPar[#newPar+1] = node
newPar.Sorted = nil
end
if searchFunc and searchResults[node] then
local currentNode = node.Parent
while currentNode and (not searchResults[currentNode] or expanded[currentNode] == 0) do
expanded[currentNode] = true
searchResults[currentNode] = true
currentNode = currentNode.Parent
end
end
if not updateDebounce and (Explorer.IsNodeVisible(newPar) or Explorer.IsNodeVisible(oldPar)) then
if expanded[newPar] or expanded[oldPar] then
Explorer.PerformUpdate()
elseif not refreshDebounce then
Explorer.PerformRefresh()
end
end
end
Explorer.ViewWidth = 0
Explorer.Index = 0
Explorer.EntryIndent = 20
Explorer.FreeWidth = 32
Explorer.GuiElems = {}
Explorer.InitRenameBox = function()
renameBox = create({{1,"TextBox",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderColor3=Color3.new(0.062745101749897,0.51764708757401,1),BorderMode=2,ClearTextOnFocus=false,Font=3,Name="RenameBox",PlaceholderColor3=Color3.new(0.69803923368454,0.69803923368454,0.69803923368454),Position=UDim2.new(0,26,0,2),Size=UDim2.new(0,200,0,16),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,Visible=false,ZIndex=2}}})
renameBox.Parent = Explorer.Window.GuiElems.Content.List
renameBox.FocusLost:Connect(function()
if not renamingNode then return end
pcall(function() renamingNode.Obj.Name = renameBox.Text end)
renamingNode = nil
Explorer.Refresh()
end)
renameBox.Focused:Connect(function()
renameBox.SelectionStart = 1
renameBox.CursorPosition = #renameBox.Text + 1
end)
end
Explorer.SetRenamingNode = function(node)
renamingNode = node
renameBox.Text = tostring(node.Obj)
renameBox:CaptureFocus()
Explorer.Refresh()
end
Explorer.SetSortingEnabled = function(val)
sortingEnabled = val
Settings.Explorer.Sorting = val
end
Explorer.UpdateView = function()
local maxNodes = math.ceil(treeFrame.AbsoluteSize.Y / 20)
local maxX = treeFrame.AbsoluteSize.X
local totalWidth = Explorer.ViewWidth + Explorer.FreeWidth
scrollV.VisibleSpace = maxNodes
scrollV.TotalSpace = #tree + 1
scrollH.VisibleSpace = maxX
scrollH.TotalSpace = totalWidth
scrollV.Gui.Visible = #tree + 1 > maxNodes
scrollH.Gui.Visible = totalWidth > maxX
local oldSize = treeFrame.Size
treeFrame.Size = UDim2.new(1,(scrollV.Gui.Visible and -16 or 0),1,(scrollH.Gui.Visible and -39 or -23))
if oldSize ~= treeFrame.Size then
Explorer.UpdateView()
else
scrollV:Update()
scrollH:Update()
renameBox.Size = UDim2.new(0,maxX-100,0,16)
if scrollV.Gui.Visible and scrollH.Gui.Visible then
scrollV.Gui.Size = UDim2.new(0,16,1,-39)
scrollH.Gui.Size = UDim2.new(1,-16,0,16)
Explorer.Window.GuiElems.Content.ScrollCorner.Visible = true
else
scrollV.Gui.Size = UDim2.new(0,16,1,-23)
scrollH.Gui.Size = UDim2.new(1,0,0,16)
Explorer.Window.GuiElems.Content.ScrollCorner.Visible = false
end
Explorer.Index = scrollV.Index
end
end
Explorer.NodeSorter = function(a,b)
if a.Del or b.Del then return false end -- Ghost node
local aClass = a.Class
local bClass = b.Class
if not aClass then aClass = a.Obj.ClassName a.Class = aClass end
if not bClass then bClass = b.Obj.ClassName b.Class = bClass end
local aOrder = explorerOrders[aClass]
local bOrder = explorerOrders[bClass]
if not aOrder then aOrder = RMD.Classes[aClass] and tonumber(RMD.Classes[aClass].ExplorerOrder) or 9999 explorerOrders[aClass] = aOrder end
if not bOrder then bOrder = RMD.Classes[bClass] and tonumber(RMD.Classes[bClass].ExplorerOrder) or 9999 explorerOrders[bClass] = bOrder end
if aOrder ~= bOrder then
return aOrder < bOrder
else
local aName,bName = tostring(a.Obj),tostring(b.Obj)
if aName ~= bName then
return aName < bName
elseif aClass ~= bClass then
return aClass < bClass
else
local aId = a.Id if not aId then aId = idCounter idCounter = (idCounter+0.001)%999999999 a.Id = aId end
local bId = b.Id if not bId then bId = idCounter idCounter = (idCounter+0.001)%999999999 b.Id = bId end
return aId < bId
end
end
end
Explorer.Update = function()
table.clear(tree)
local maxNameWidth,maxDepth,count = 0,1,1
local nameCache = {}
local font = Enum.Font.SourceSans
local size = Vector2.new(math.huge,20)
local useNameWidth = Settings.Explorer.UseNameWidth
local tSort = table.sort
local sortFunc = Explorer.NodeSorter
local isSearching = (expanded == Explorer.SearchExpanded)
local textServ = service.TextService
local function recur(root,depth)
if depth > maxDepth then maxDepth = depth end
depth = depth + 1
if sortingEnabled and not root.Sorted then
tSort(root,sortFunc)
root.Sorted = true
end
for i = 1,#root do
local n = root[i]
if (isSearching and not searchResults[n]) or n.Del then continue end
if useNameWidth then
local nameWidth = n.NameWidth
if not nameWidth then
local objName = tostring(n.Obj)
nameWidth = nameCache[objName]
if not nameWidth then
nameWidth = getTextSize(textServ,objName,14,font,size).X
nameCache[objName] = nameWidth
end
n.NameWidth = nameWidth
end
if nameWidth > maxNameWidth then
maxNameWidth = nameWidth
end
end
tree[count] = n
count = count + 1
if expanded[n] and #n > 0 then
recur(n,depth)
end
end
end
recur(nodes[game],1)
-- Nil Instances
if env.getnilinstances then
if not (isSearching and not searchResults[nilNode]) then
tree[count] = nilNode
count = count + 1
if expanded[nilNode] then
recur(nilNode,2)
end
end
end
Explorer.MaxNameWidth = maxNameWidth
Explorer.MaxDepth = maxDepth
Explorer.ViewWidth = useNameWidth and Explorer.EntryIndent*maxDepth + maxNameWidth + 26 or Explorer.EntryIndent*maxDepth + 226
Explorer.UpdateView()
end
Explorer.StartDrag = function(offX,offY)
if Explorer.Dragging then return end
Explorer.Dragging = true
local dragTree = treeFrame:Clone()
dragTree:ClearAllChildren()
for i,v in pairs(listEntries) do
local node = tree[i + Explorer.Index]
if node and selection.Map[node] then
local clone = v:Clone()
clone.Active = false
clone.Indent.Expand.Visible = false
clone.Parent = dragTree
end
end
local newGui = Instance.new("ScreenGui")
newGui.DisplayOrder = Main.DisplayOrders.Menu
dragTree.Parent = newGui
Lib.ShowGui(newGui)
local dragOutline = create({
{1,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="DragSelect",Size=UDim2.new(1,0,1,0),}},
{2,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Size=UDim2.new(1,0,0,1),ZIndex=2,}},
{3,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Position=UDim2.new(0,0,1,-1),Size=UDim2.new(1,0,0,1),ZIndex=2,}},
{4,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Size=UDim2.new(0,1,1,0),ZIndex=2,}},
{5,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Position=UDim2.new(1,-1,0,0),Size=UDim2.new(0,1,1,0),ZIndex=2,}},
})
dragOutline.Parent = treeFrame
local mouse = Main.Mouse or service.Players.LocalPlayer:GetMouse()
local function move()
local posX = mouse.X - offX
local posY = mouse.Y - offY
dragTree.Position = UDim2.new(0,posX,0,posY)
for i = 1,#listEntries do
local entry = listEntries[i]
if Lib.CheckMouseInGui(entry) then
dragOutline.Position = UDim2.new(0,entry.Indent.Position.X.Offset-scrollH.Index,0,entry.Position.Y.Offset)
dragOutline.Size = UDim2.new(0,entry.Size.X.Offset-entry.Indent.Position.X.Offset,0,20)
dragOutline.Visible = true
return
end
end
dragOutline.Visible = false
end
move()
local input = service.UserInputService
local mouseEvent,releaseEvent
mouseEvent = input.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
move()
end
end)
releaseEvent = input.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
releaseEvent:Disconnect()
mouseEvent:Disconnect()
newGui:Destroy()
dragOutline:Destroy()
Explorer.Dragging = false
for i = 1,#listEntries do
if Lib.CheckMouseInGui(listEntries[i]) then
local node = tree[i + Explorer.Index]
if node then
if selection.Map[node] then return end
local newPar = node.Obj
local sList = selection.List
for i = 1,#sList do
local n = sList[i]
pcall(function() n.Obj.Parent = newPar end)
end
Explorer.ViewNode(sList[1])
end
break
end
end
end
end)
end
Explorer.NewListEntry = function(index)
local newEntry = entryTemplate:Clone()
newEntry.Position = UDim2.new(0,0,0,20*(index-1))
local isRenaming = false
newEntry.InputBegan:Connect(function(input)
local node = tree[index + Explorer.Index]
if not node or selection.Map[node] or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
newEntry.Indent.BackgroundColor3 = Settings.Theme.Button
newEntry.Indent.BorderSizePixel = 0
newEntry.Indent.BackgroundTransparency = 0
end)
newEntry.InputEnded:Connect(function(input)
local node = tree[index + Explorer.Index]
if not node or selection.Map[node] or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
newEntry.Indent.BackgroundTransparency = 1
end)
newEntry.MouseButton1Down:Connect(function()
end)
newEntry.MouseButton1Up:Connect(function()
end)
newEntry.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local releaseEvent,mouseEvent
local mouse = Main.Mouse or plr:GetMouse()
local startX = mouse.X
local startY = mouse.Y
local listOffsetX = startX - treeFrame.AbsolutePosition.X
local listOffsetY = startY - treeFrame.AbsolutePosition.Y
releaseEvent = game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
releaseEvent:Disconnect()
mouseEvent:Disconnect()
end
end)
mouseEvent = game:GetService("UserInputService").InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local deltaX = mouse.X - startX
local deltaY = mouse.Y - startY
local dist = math.sqrt(deltaX^2 + deltaY^2)
if dist > 5 then
releaseEvent:Disconnect()
mouseEvent:Disconnect()
isRenaming = false
Explorer.StartDrag(listOffsetX,listOffsetY)
end
end
end)
end
end)
newEntry.MouseButton2Down:Connect(function()
end)
newEntry.Indent.Expand.InputBegan:Connect(function(input)
local node = tree[index + Explorer.Index]
if not node or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
Explorer.MiscIcons:DisplayByKey(newEntry.Indent.Expand.Icon, expanded[node] and "Collapse_Over" or "Expand_Over")
end)
newEntry.Indent.Expand.InputEnded:Connect(function(input)
local node = tree[index + Explorer.Index]
if not node or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
Explorer.MiscIcons:DisplayByKey(newEntry.Indent.Expand.Icon, expanded[node] and "Collapse" or "Expand")
end)
newEntry.Indent.Expand.MouseButton1Down:Connect(function()
local node = tree[index + Explorer.Index]
if not node or #node == 0 then return end
expanded[node] = not expanded[node]
Explorer.Update()
Explorer.Refresh()
end)
newEntry.Parent = treeFrame
return newEntry
end
Explorer.Refresh = function()
local maxNodes = math.max(math.ceil((treeFrame.AbsoluteSize.Y) / 20),0)
local renameNodeVisible = false
local isa = game.IsA
for i = 1,maxNodes do
local entry = listEntries[i]
if not listEntries[i] then entry = Explorer.NewListEntry(i) listEntries[i] = entry Explorer.ClickSystem:Add(entry) end
local node = tree[i + Explorer.Index]
if node then
local obj = node.Obj
local depth = Explorer.EntryIndent*Explorer.NodeDepth(node)
entry.Visible = true
entry.Position = UDim2.new(0,-scrollH.Index,0,entry.Position.Y.Offset)
entry.Size = UDim2.new(0,Explorer.ViewWidth,0,20)
entry.Indent.EntryName.Text = tostring(node.Obj)
entry.Indent.Position = UDim2.new(0,depth,0,0)
entry.Indent.Size = UDim2.new(1,-depth,1,0)
entry.Indent.EntryName.TextTruncate = (Settings.Explorer.UseNameWidth and Enum.TextTruncate.None or Enum.TextTruncate.AtEnd)
if (isa(obj,"LocalScript") or isa(obj,"Script")) and obj.Disabled then
Explorer.MiscIcons:DisplayByKey(entry.Indent.Icon, isa(obj,"LocalScript") and "LocalScript_Disabled" or "Script_Disabled")
else
local rmdEntry = RMD.Classes[obj.ClassName]
Explorer.ClassIcons:Display(entry.Indent.Icon, rmdEntry and rmdEntry.ExplorerImageIndex or 0)
end
if selection.Map[node] then
entry.Indent.BackgroundColor3 = Settings.Theme.ListSelection
entry.Indent.BorderSizePixel = 0
entry.Indent.BackgroundTransparency = 0
else
if Lib.CheckMouseInGui(entry) then
entry.Indent.BackgroundColor3 = Settings.Theme.Button
else
entry.Indent.BackgroundTransparency = 1
end
end
if node == renamingNode then
renameNodeVisible = true
renameBox.Position = UDim2.new(0,depth+25-scrollH.Index,0,entry.Position.Y.Offset+2)
renameBox.Visible = true
end
if #node > 0 and expanded[node] ~= 0 then
if Lib.CheckMouseInGui(entry.Indent.Expand) then
Explorer.MiscIcons:DisplayByKey(entry.Indent.Expand.Icon, expanded[node] and "Collapse_Over" or "Expand_Over")
else
Explorer.MiscIcons:DisplayByKey(entry.Indent.Expand.Icon, expanded[node] and "Collapse" or "Expand")
end
entry.Indent.Expand.Visible = true
else
entry.Indent.Expand.Visible = false
end
else
entry.Visible = false
end
end
if not renameNodeVisible then
renameBox.Visible = false
end
for i = maxNodes+1, #listEntries do
Explorer.ClickSystem:Remove(listEntries[i])
listEntries[i]:Destroy()
listEntries[i] = nil
end
end
Explorer.PerformUpdate = function(instant)
updateDebounce = true
Lib.FastWait(not instant and 0.1)
if not updateDebounce then return end
updateDebounce = false
if not Explorer.Window:IsVisible() then return end
Explorer.Update()
Explorer.Refresh()
end
Explorer.ForceUpdate = function(norefresh)
updateDebounce = false
Explorer.Update()
if not norefresh then Explorer.Refresh() end
end
Explorer.PerformRefresh = function()
refreshDebounce = true
Lib.FastWait(0.1)
refreshDebounce = false
if updateDebounce or not Explorer.Window:IsVisible() then return end
Explorer.Refresh()
end
Explorer.IsNodeVisible = function(node)
if not node then return end
local curNode = node.Parent
while curNode do
if not expanded[curNode] then return false end
curNode = curNode.Parent
end
return true
end
Explorer.NodeDepth = function(node)
local depth = 0
if node == nilNode then
return 1
end
local curNode = node.Parent
while curNode do
if curNode == nilNode then depth = depth + 1 end
curNode = curNode.Parent
depth = depth + 1
end
return depth
end
Explorer.SetupConnections = function()
if descendantAddedCon then descendantAddedCon:Disconnect() end
if descendantRemovingCon then descendantRemovingCon:Disconnect() end
if itemChangedCon then itemChangedCon:Disconnect() end
if Main.Elevated then
descendantAddedCon = game.DescendantAdded:Connect(addObject)
descendantRemovingCon = game.DescendantRemoving:Connect(removeObject)
else
descendantAddedCon = game.DescendantAdded:Connect(function(obj) pcall(addObject,obj) end)
descendantRemovingCon = game.DescendantRemoving:Connect(function(obj) pcall(removeObject,obj) end)
end
if Settings.Explorer.UseNameWidth then
itemChangedCon = game.ItemChanged:Connect(function(obj,prop)
if prop == "Parent" and nodes[obj] then
moveObject(obj)
elseif prop == "Name" and nodes[obj] then
nodes[obj].NameWidth = nil
end
end)
else
itemChangedCon = game.ItemChanged:Connect(function(obj,prop)
if prop == "Parent" and nodes[obj] then
moveObject(obj)
end
end)
end
end
Explorer.ViewNode = function(node)
if not node then return end
Explorer.MakeNodeVisible(node)
Explorer.ForceUpdate(true)
local visibleSpace = scrollV.VisibleSpace
for i,v in next,tree do
if v == node then
local relative = i - 1
if Explorer.Index > relative then
scrollV.Index = relative
elseif Explorer.Index + visibleSpace - 1 <= relative then
scrollV.Index = relative - visibleSpace + 2
end
end
end
scrollV:Update() Explorer.Index = scrollV.Index
Explorer.Refresh()
end
Explorer.ViewObj = function(obj)
Explorer.ViewNode(nodes[obj])
end
Explorer.MakeNodeVisible = function(node,expandRoot)
if not node then return end
local hasExpanded = false
if expandRoot and not expanded[node] then
expanded[node] = true
hasExpanded = true
end
local currentNode = node.Parent
while currentNode do
hasExpanded = true
expanded[currentNode] = true
currentNode = currentNode.Parent
end
if hasExpanded and not updateDebounce then
coroutine.wrap(Explorer.PerformUpdate)(true)
end
end
Explorer.ShowRightClick = function()
local context = Explorer.RightClickContext
context:Clear()
local sList = selection.List
local sMap = selection.Map
local emptyClipboard = #clipboard == 0
local presentClasses = {}
local apiClasses = API.Classes
for i = 1,#sList do
local node = sList[i]
local class = node.Class
if not class then class = node.Obj.ClassName node.Class = class end
local curClass = apiClasses[class]
while curClass and not presentClasses[curClass.Name] do
presentClasses[curClass.Name] = true
curClass = curClass.Superclass
end
end
context:AddRegistered("CUT")
context:AddRegistered("COPY")
context:AddRegistered("PASTE",emptyClipboard)
context:AddRegistered("DUPLICATE")
context:AddRegistered("DELETE")
context:AddRegistered("RENAME",#sList ~= 1)
context:AddDivider()
context:AddRegistered("GROUP")
context:AddRegistered("UNGROUP")
context:AddRegistered("SELECT_CHILDREN")
context:AddRegistered("JUMP_TO_PARENT")
context:AddRegistered("EXPAND_ALL")
context:AddRegistered("COLLAPSE_ALL")
context:AddDivider()
if expanded == Explorer.SearchExpanded then
context:AddRegistered("CLEAR_SEARCH_AND_JUMP_TO")
end
if env.setclipboard then
context:AddRegistered("COPY_PATH")
end
context:AddRegistered("INSERT_OBJECT")
context:AddRegistered("SAVE_INST")
context:AddRegistered("CALL_FUNCTION")
context:AddRegistered("VIEW_CONNECTIONS")
context:AddRegistered("GET_REFERENCES")
context:AddRegistered("VIEW_API")
context:QueueDivider()
if presentClasses["BasePart"] or presentClasses["Model"] then
context:AddRegistered("TELEPORT_TO")
context:AddRegistered("VIEW_OBJECT")
end
if presentClasses["Player"] then
context:AddRegistered("SELECT_CHARACTER")
end
if presentClasses["LuaSourceContainer"] then
context:AddRegistered("VIEW_SCRIPT")
end
if sMap[nilNode] then
context:AddRegistered("REFRESH_NIL")
context:AddRegistered("HIDE_NIL")
end
Explorer.LastRightClickX,Explorer.LastRightClickY = Main.Mouse.X,Main.Mouse.Y
context:Show()
end
Explorer.InitRightClick = function()
local context = Lib.ContextMenu.new()
context:Register("CUT",{Name = "Cut", IconMap = Explorer.MiscIcons, Icon = "Cut", DisabledIcon = "Cut_Disabled", Shortcut = "Ctrl+Z", OnClick = function()
local destroy,clone = game.Destroy,game.Clone
local sList,newClipboard = selection.List,{}
local count = 1
for i = 1,#sList do
local inst = sList[i].Obj
local s,cloned = pcall(clone,inst)
if s and cloned then
newClipboard[count] = cloned
count = count + 1
end
pcall(destroy,inst)
end
clipboard = newClipboard
selection:Clear()
end})
context:Register("COPY",{Name = "Copy", IconMap = Explorer.MiscIcons, Icon = "Copy", DisabledIcon = "Copy_Disabled", Shortcut = "Ctrl+C", OnClick = function()
local clone = game.Clone
local sList,newClipboard = selection.List,{}
local count = 1
for i = 1,#sList do
local inst = sList[i].Obj
local s,cloned = pcall(clone,inst)
if s and cloned then
newClipboard[count] = cloned
count = count + 1
end
end
clipboard = newClipboard
end})
context:Register("PASTE",{Name = "Paste Into", IconMap = Explorer.MiscIcons, Icon = "Paste", DisabledIcon = "Paste_Disabled", Shortcut = "Ctrl+Shift+V", OnClick = function()
local sList = selection.List
local newSelection = {}
local count = 1
for i = 1,#sList do
local node = sList[i]
local inst = node.Obj
Explorer.MakeNodeVisible(node,true)
for c = 1,#clipboard do
local cloned = clipboard[c]:Clone()
if cloned then
cloned.Parent = inst
local clonedNode = nodes[cloned]
if clonedNode then newSelection[count] = clonedNode count = count + 1 end
end
end
end
selection:SetTable(newSelection)
if #newSelection > 0 then
Explorer.ViewNode(newSelection[1])
end
end})
context:Register("DUPLICATE",{Name = "Duplicate", IconMap = Explorer.MiscIcons, Icon = "Copy", DisabledIcon = "Copy_Disabled", Shortcut = "Ctrl+D", OnClick = function()
local clone = game.Clone
local sList = selection.List
local newSelection = {}
local count = 1
for i = 1,#sList do
local node = sList[i]
local inst = node.Obj
local instPar = node.Parent and node.Parent.Obj
Explorer.MakeNodeVisible(node)
local s,cloned = pcall(clone,inst)
if s and cloned then
cloned.Parent = instPar
local clonedNode = nodes[cloned]
if clonedNode then newSelection[count] = clonedNode count = count + 1 end
end
end
selection:SetTable(newSelection)
if #newSelection > 0 then
Explorer.ViewNode(newSelection[1])
end
end})
context:Register("DELETE",{Name = "Delete", IconMap = Explorer.MiscIcons, Icon = "Delete", DisabledIcon = "Delete_Disabled", Shortcut = "Del", OnClick = function()
local destroy = game.Destroy
local sList = selection.List
for i = 1,#sList do
pcall(destroy,sList[i].Obj)
end
selection:Clear()
end})
context:Register("RENAME",{Name = "Rename", IconMap = Explorer.MiscIcons, Icon = "Rename", DisabledIcon = "Rename_Disabled", Shortcut = "F2", OnClick = function()
local sList = selection.List
if sList[1] then
Explorer.SetRenamingNode(sList[1])
end
end})