if engine.ActiveGamemode() ~= "sandbox" then return end include('shared.lua') --Don't draw our hull model function ENT:Draw() end local function draw_edit_panel(filename,who) if not GCompute then error("GCompute not installed!") end if not GCompute.IDE then error("GCompute was initalized wrong or has changed, update this file!") end local inst = GCompute.IDE.GetInstance() inst:SetVisible (true) print("Opening file browser!") --Remove donation panel for k,v in pairs(inst.ViewManager.Views) do if type(k) == "table" and k.Title == "Donate!" then k:SetVisible(false) end end local fileuri = "game/data/" .. filename print("Trying to open","game/data/" .. filename) --Open up this npc's file inst:OpenFile(fileuri,function(succ,res,view) view:Select() end) --Set our file browser to the right place for k,v in pairs(inst.ViewManager.Views) do if k.Title == "File Browser" then k.FolderListView:SetPath(string.GetPathFromFilename(fileuri)) end end --Detour it's save to let the server know the file was saved. local doc = inst.DocumentManager.DocumentsByUri[fileuri] print("Doc was",doc) doc:AddEventListener("Saved",function() print("Saved",doc) net.Start("edit_sendsave") net.WriteString(doc.Uri) net.WriteEntity(who) net.SendToServer() end) end function Reload_Gcompute(what) print("attempting to refresh instances of ", what) local inst = GCompute.IDE:GetInstance() for k,v in pairs(inst.ViewManager.ViewsById) do if v.Title == what then v:CreateFileChangeNotificationBar () v.FileChangeNotificationBar:DispatchEvent("ReloadRequested") local oldvisible = v.FileChangeNotificationBar.SetVisible v.FileChangeNotificationBar.SetVisible = function(self,bool) if bool then self.SetVisible = oldvisible end end break end end end net.Receive("edit_notify_file_changed",function() local what = net.ReadString() Reload_Gcompute(what) end) net.Receive("edit_confirmremove",function() local who = net.ReadString() local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 250 ) frame:Center() frame:MakePopup() local but = vgui.Create( "DButton", frame ) but:SetText( "\nYes, I want to remove\n" .. who .. "\n") but:Dock(TOP) but.DoClick = function() // A custom function run when clicked ( note the . instead of : ) net.Start("edit_removeconfirmed") net.WriteString(who) net.SendToServer() frame:Close() end local but2 = vgui.Create("DButton",frame) but2:SetText("\nNo I don't want to remove\n" .. who .. "\n") but2:Dock(BOTTOM) but2.DoClick = function() // A custom function run when clicked ( note the . instead of : ) net.Start("edit_removedeny") net.WriteString(who) net.SendToServer() frame:Close() end but:SizeToContents() but2:SizeToContents() end) net.Receive("edit_sendopen",function() print('got request to edit someone') local file = net.ReadString() local who = net.ReadEntity() print(file) draw_edit_panel(file,who) end) hook.Add( "Think", "edit_type_tip", function() local tr = LocalPlayer():GetEyeTrace() local e = tr.Entity if e.Entity then AddWorldTip( nil, e:GetClass(), nil, tr.HitPos, e ) end end )