Guest User

addons/ulx/lua/ulx/modules/cl/xgui_client.lua

a guest
Mar 29th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.87 KB | None | 0 0
  1. --XGUI: A GUI for ULX -- by Stickly Man!
  2. xgui = {}
  3.  
  4. --Make a spot for modules to store data and hooks
  5. xgui.data = {}
  6. xgui.hook = { onProcessModules={}, onOpen={} }
  7. --Call this function in your client-side module code to ensure the data types have been instantiated on the client.
  8. function xgui.prepareDataType( dtype, location )
  9. if not xgui.data[dtype] then
  10. xgui.data[dtype] = location or {}
  11. xgui.hook[dtype] = { clear={}, process={}, done={}, add={}, update={}, remove={} }
  12. end
  13. end
  14.  
  15. --Set up various hooks modules can "hook" into.
  16. function xgui.hookEvent( dtype, event, func )
  17. if not xgui.hook[dtype] or ( event and not xgui.hook[dtype][event] ) then
  18. Msg( "XGUI: Attempted to add to invalid type or event to a hook! (" .. dtype .. ", " .. ( event or "nil" ) .. ")\n" )
  19. else
  20. if not event then
  21. table.insert( xgui.hook[dtype], func )
  22. else
  23. table.insert( xgui.hook[dtype][event], func )
  24. end
  25. end
  26. end
  27.  
  28. --Set up tables and functions for creating and storing modules
  29. xgui.modules = {}
  30.  
  31. xgui.modules.tab={}
  32. function xgui.addModule( name, panel, icon, access, tooltip )
  33. table.insert( xgui.modules.tab, { name=name, panel=panel, icon=icon, access=access, tooltip=tooltip } )
  34. end
  35.  
  36. xgui.modules.setting={}
  37. function xgui.addSettingModule( name, panel, icon, access, tooltip )
  38. table.insert( xgui.modules.setting, { name=name, panel=panel, icon=icon, access=access, tooltip=tooltip } )
  39. end
  40.  
  41. xgui.modules.submodule={}
  42. function xgui.addSubModule( name, panel, access, mtype )
  43. table.insert( xgui.modules.submodule, { name=name, panel=panel, access=access, mtype=mtype } )
  44. end
  45. --Set up a spot to store entries for autocomplete.
  46. xgui.tabcompletes = {}
  47. xgui.ulxmenucompletes = {}
  48.  
  49.  
  50. --Set up XGUI clientside settings, load settings from file if it exists
  51. xgui.settings = {}
  52. if ULib.fileExists( "data/ulx/xgui_settings.txt" ) then
  53. local input = ULib.fileRead( "data/ulx/xgui_settings.txt" )
  54. input = input:match( "^.-\n(.*)$" )
  55. xgui.settings = ULib.parseKeyValues( input )
  56. end
  57. --Set default settings if they didn't get loaded
  58. if not xgui.settings.moduleOrder then xgui.settings.moduleOrder = { "Cmds", "Groups", "Maps", "Settings", "Bans" } end
  59. if not xgui.settings.settingOrder then xgui.settings.settingOrder = { "Sandbox", "Server", "XGUI" } end
  60. if not xgui.settings.animTime then xgui.settings.animTime = 0.22 else xgui.settings.animTime = tonumber( xgui.settings.animTime ) end
  61. if not xgui.settings.infoColor then
  62. --Default color
  63. xgui.settings.infoColor = Color( 100, 255, 255, 128 )
  64. else
  65. --Ensure that the color contains numbers, not strings
  66. xgui.settings.infoColor = Color(xgui.settings.infoColor.r, xgui.settings.infoColor.g, xgui.settings.infoColor.b, xgui.settings.infoColor.a)
  67. end
  68. if not xgui.settings.showLoadMsgs then xgui.settings.showLoadMsgs = true else xgui.settings.showLoadMsgs = ULib.toBool( xgui.settings.showLoadMsgs ) end
  69. if not xgui.settings.skin then xgui.settings.skin = "Default" end
  70. if not xgui.settings.xguipos then xgui.settings.xguipos = { pos=5, xoff=0, yoff=0 } end
  71. if not xgui.settings.animIntype then xgui.settings.animIntype = 1 end
  72. if not xgui.settings.animOuttype then xgui.settings.animOuttype = 1 end
  73.  
  74.  
  75. function xgui.init( authedply )
  76. if not authedply then authedply = LocalPlayer() end
  77. if authedply ~= LocalPlayer() then return end
  78.  
  79. xgui.load_helpers()
  80.  
  81. --Initiate the base window (see xgui_helpers.lua for code)
  82. xgui.makeXGUIbase{}
  83.  
  84. --Create the bottom infobar
  85. xgui.infobar = xlib.makepanel{ x=10, y=399, w=580, h=20, parent=xgui.anchor }
  86. xgui.infobar:NoClipping( true )
  87. xgui.infobar.Paint = function( self, w, h )
  88. draw.RoundedBoxEx( 4, 0, 1, 580, 20, xgui.settings.infoColor, false, false, true, true )
  89. end
  90. local version_type = ulx.revision and ( ulx.revision > 0 and " SVN " .. ulx.revision or " Release") or (" N/A")
  91. xlib.makelabel{ x=5, y=-10, label="\nULX Admin Mod :: XGUI - by Stickly Man! :: v13.8.30 | ULX v" .. string.format("%.2f", ulx.version) .. version_type .. " | ULib v" .. ULib.VERSION, parent=xgui.infobar }:NoClipping( true )
  92. xgui.thetime = xlib.makelabel{ x=515, y=-10, label="", parent=xgui.infobar }
  93. xgui.thetime:NoClipping( true )
  94. xgui.thetime.check = function()
  95. xgui.thetime:SetText( os.date( "\n%I:%M:%S %p" ) )
  96. xgui.thetime:SizeToContents()
  97. timer.Simple( 1, xgui.thetime.check )
  98. end
  99. xgui.thetime.check()
  100.  
  101. --Create an offscreen place to parent modules that the player can't access
  102. xgui.null = xlib.makepanel{ x=-10, y=-10, w=0, h=0 }
  103. xgui.null:SetVisible( false )
  104.  
  105. --Load modules
  106. local sm = xgui.settings.showLoadMsgs
  107. if sm then
  108. Msg( "\n///////////////////////////////////////\n" )
  109. Msg( "// ULX GUI -- Made by Stickly Man! //\n" )
  110. Msg( "///////////////////////////////////////\n" )
  111. Msg( "// Loading GUI Modules... //\n" )
  112. end
  113. for _, file in ipairs( file.Find( "ulx/xgui/*.lua", "LUA" ) ) do
  114. include( "ulx/xgui/" .. file )
  115. if sm then Msg( "// " .. file .. string.rep( " ", 32 - file:len() ) .. "//\n" ) end
  116. end
  117. if sm then Msg( "// Loading Setting Modules... //\n" ) end
  118. for _, file in ipairs( file.Find( "ulx/xgui/settings/*.lua", "LUA" ) ) do
  119. include( "ulx/xgui/settings/" .. file )
  120. if sm then Msg( "// " .. file .. string.rep( " ", 32 - file:len() ) .. "//\n" ) end
  121. end
  122. if sm then Msg( "// Loading Gamemode Module(s)... //\n" ) end
  123. if ULib.isSandbox() and GAMEMODE.FolderName ~= "sandbox" then -- If the gamemode sandbox-derived (but not sandbox, that will get added later), then add the sandbox Module
  124. include( "ulx/xgui/gamemodes/sandbox.lua" )
  125. if sm then Msg( "// sandbox.lua //\n" ) end
  126. end
  127. for _, file in ipairs( file.Find( "ulx/xgui/gamemodes/*.lua", "LUA" ) ) do
  128. if string.lower( file ) == string.lower( GAMEMODE.FolderName .. ".lua" ) then
  129. include( "ulx/xgui/gamemodes/" .. file )
  130. if sm then Msg( "// " .. file .. string.rep( " ", 32 - file:len() ) .. "//\n" ) end
  131. break
  132. end
  133. if sm then Msg( "// No module found! //\n" ) end
  134. end
  135. if sm then Msg( "// Modules Loaded! //\n" ) end
  136. if sm then Msg( "///////////////////////////////////////\n\n" ) end
  137.  
  138. --Find any existing modules that aren't listed in the requested order.
  139. local function checkModulesOrder( moduleTable, sortTable )
  140. for _, m in ipairs( moduleTable ) do
  141. local notlisted = true
  142. for _, existing in ipairs( sortTable ) do
  143. if m.name == existing then
  144. notlisted = false
  145. break
  146. end
  147. end
  148. if notlisted then
  149. table.insert( sortTable, m.name )
  150. end
  151. end
  152. end
  153. checkModulesOrder( xgui.modules.tab, xgui.settings.moduleOrder )
  154. checkModulesOrder( xgui.modules.setting, xgui.settings.settingOrder )
  155.  
  156. --Check if the server has XGUI installed
  157. RunConsoleCommand( "_xgui", "getInstalled" )
  158.  
  159. hook.Remove( "UCLAuthed", "InitXGUI" )
  160. xgui.initialized = true
  161.  
  162. xgui.processModules()
  163. end
  164. hook.Add( "UCLAuthed", "InitXGUI", xgui.init, 20 )
  165.  
  166. function xgui.saveClientSettings()
  167. local output = "// This file stores clientside settings for XGUI.\n"
  168. output = output .. ULib.makeKeyValues( xgui.settings )
  169. ULib.fileWrite( "data/ulx/xgui_settings.txt", output )
  170. end
  171.  
  172. function xgui.checkModuleExists( modulename, moduletable )
  173. for k, v in ipairs( moduletable ) do
  174. if v.name == modulename then
  175. return k
  176. end
  177. end
  178. return false
  179. end
  180.  
  181. function xgui.processModules()
  182. local activetab = nil
  183. if xgui.base:GetActiveTab() then
  184. activetab = xgui.base:GetActiveTab():GetValue()
  185. end
  186.  
  187. local activesettingstab = nil
  188. if xgui.settings_tabs:GetActiveTab() then
  189. activesettingstab = xgui.settings_tabs:GetActiveTab():GetValue()
  190. end
  191.  
  192. xgui.base:Clear() --We need to remove any existing tabs in the GUI
  193. xgui.tabcompletes = {}
  194. xgui.ulxmenucompletes = {}
  195. for _, modname in ipairs( xgui.settings.moduleOrder ) do
  196. local module = xgui.checkModuleExists( modname, xgui.modules.tab )
  197. if module then
  198. module = xgui.modules.tab[module]
  199. if module.xbutton == nil then
  200. module.xbutton = xlib.makebutton{ x=555, y=-5, w=32, h=32, btype="close", parent=module.panel }
  201. module.xbutton.DoClick = function()
  202. xgui.hide()
  203. end
  204. end
  205. if LocalPlayer():query( module.access ) then
  206. xgui.base:AddSheet( module.name, module.panel, module.icon, false, false, module.tooltip )
  207. module.tabpanel = xgui.base.Items[#xgui.base.Items].Tab
  208. table.insert( xgui.tabcompletes, "xgui show " .. modname )
  209. table.insert( xgui.ulxmenucompletes, "ulx menu " .. modname )
  210. else
  211. module.tabpanel = nil
  212. module.panel:SetParent( xgui.null )
  213. end
  214. end
  215. end
  216.  
  217. xgui.settings_tabs:Clear() --Clear out settings tabs for reprocessing
  218. for _, modname in ipairs( xgui.settings.settingOrder ) do
  219. local module = xgui.checkModuleExists( modname, xgui.modules.setting )
  220. if module then
  221. module = xgui.modules.setting[module]
  222. if LocalPlayer():query( module.access ) then
  223. xgui.settings_tabs:AddSheet( module.name, module.panel, module.icon, false, false, module.tooltip )
  224. module.tabpanel = xgui.settings_tabs.Items[#xgui.settings_tabs.Items].Tab
  225. table.insert( xgui.tabcompletes, "xgui show " .. modname )
  226. table.insert( xgui.ulxmenucompletes, "ulx menu " .. modname )
  227. else
  228. module.tabpanel = nil
  229. module.panel:SetParent( xgui.null )
  230. end
  231. end
  232. end
  233.  
  234. --Call any functions that requested to be called when permissions change
  235. xgui.callUpdate( "onProcessModules" )
  236. table.sort( xgui.tabcompletes )
  237. table.sort( xgui.ulxmenucompletes )
  238.  
  239. local hasFound = false
  240. if activetab then
  241. for _, v in pairs( xgui.base.Items ) do
  242. if v.Tab:GetValue() == activetab then
  243. xgui.base:SetActiveTab( v.Tab, true )
  244. hasFound = true
  245. break
  246. end
  247. end
  248. if not hasFound then
  249. xgui.base.m_pActiveTab = "none"
  250. xgui.base:SetActiveTab( xgui.base.Items[1].Tab, true )
  251. end
  252. end
  253.  
  254. hasFound = false
  255. if activesettingstab then
  256. for _, v in pairs( xgui.settings_tabs.Items ) do
  257. if v.Tab:GetValue() == activesettingstab then
  258. xgui.settings_tabs:SetActiveTab( v.Tab, true )
  259. hasFound = true
  260. break
  261. end
  262. end
  263. if not hasFound then
  264. xgui.settings_tabs.m_pActiveTab = "none"
  265. xgui.settings_tabs:SetActiveTab( xgui.settings_tabs.Items[1].Tab, true )
  266. end
  267. end
  268. end
  269.  
  270. function xgui.checkNotInstalled( tabname )
  271. if xgui.notInstalledWarning then return end
  272.  
  273. gui.EnableScreenClicker( true )
  274. RestoreCursorPosition()
  275. xgui.notInstalledWarning = xlib.makeframe{ label="XGUI Warning!", w=375, h=110, nopopup=true, showclose=false, skin=xgui.settings.skin }
  276. xlib.makelabel{ x=10, y=30, wordwrap=true, w=365, label="XGUI has not initialized properly with the server. This could be caused by a heavy server load after a mapchange, a major error during XGUI server startup, or XGUI not being installed.", parent=xgui.notInstalledWarning }
  277.  
  278. xlib.makebutton{ x=37, y=83, w=80, label="Offline Mode", parent=xgui.notInstalledWarning }.DoClick = function()
  279. xgui.notInstalledWarning:Remove()
  280. xgui.notInstalledWarning = nil
  281. offlineWarning = xlib.makeframe{ label="XGUI Warning!", w=375, h=110, nopopup=true, showclose=false, skin=xgui.settings.skin }
  282. xlib.makelabel{ x=10, y=30, wordwrap=true, w=365, label="XGUI will run locally in offline mode. Some features will not work, and information will be missing. You can attempt to reconnect to the server using the 'Refresh Server Data' button in the XGUI client menu.", parent=offlineWarning }
  283. xlib.makebutton{ x=77, y=83, w=80, label="OK", parent=offlineWarning }.DoClick = function()
  284. offlineWarning:Remove()
  285. xgui.offlineMode = true
  286. xgui.show( tabname )
  287. end
  288. xlib.makebutton{ x=217, y=83, w=80, label="Cancel", parent=offlineWarning }.DoClick = function()
  289. offlineWarning:Remove()
  290. RememberCursorPosition()
  291. gui.EnableScreenClicker( false )
  292. end
  293. end
  294.  
  295. xlib.makebutton{ x=257, y=83, w=80, label="Close", parent=xgui.notInstalledWarning }.DoClick = function()
  296. xgui.notInstalledWarning:Remove()
  297. xgui.notInstalledWarning = nil
  298. RememberCursorPosition()
  299. gui.EnableScreenClicker( false )
  300. end
  301.  
  302. xlib.makebutton{ x=147, y=83, w=80, label="Try Again", parent=xgui.notInstalledWarning }.DoClick = function()
  303. xgui.notInstalledWarning:Remove()
  304. xgui.notInstalledWarning = nil
  305. RememberCursorPosition()
  306. gui.EnableScreenClicker( false )
  307. local reattempt = xlib.makeframe{ label="XGUI: Attempting reconnection...", w=200, h=20, nopopup=true, showclose=false, skin=xgui.settings.skin }
  308. timer.Simple( 1, function()
  309. RunConsoleCommand( "_xgui", "getInstalled" )
  310. reattempt:Remove()
  311. timer.Simple( 0.5, function() xgui.show( tabname ) end )
  312. end )
  313. end
  314. end
  315.  
  316. function xgui.show( tabname )
  317. if not xgui.anchor then return end
  318. if not xgui.initialized then return end
  319.  
  320. --Check if XGUI is not installed, display the warning if hasn't been shown yet.
  321. if not xgui.isInstalled and not xgui.offlineMode then
  322. xgui.checkNotInstalled( tabname )
  323. return
  324. end
  325.  
  326. if not game.SinglePlayer() and not ULib.ucl.authed[LocalPlayer():UniqueID()] then
  327. local unauthedWarning = xlib.makeframe{ label="XGUI Error!", w=250, h=90, showclose=true, skin=xgui.settings.skin }
  328. xlib.makelabel{ label="Your ULX player has not been Authed!", x=10, y=30, parent=unauthedWarning }
  329. xlib.makelabel{ label="Please wait a couple seconds and try again.", x=10, y=45, parent=unauthedWarning }
  330. xlib.makebutton{ x=50, y=63, w=60, label="Try Again", parent=unauthedWarning }.DoClick = function()
  331. unauthedWarning:Remove()
  332. xgui.show( tabname )
  333. end
  334. xlib.makebutton{ x=140, y=63, w=60, label="Close", parent=unauthedWarning }.DoClick = function()
  335. unauthedWarning:Remove()
  336. end
  337. return
  338. end
  339.  
  340. if xgui.base.refreshSkin then
  341. xgui.base:SetSkin( xgui.settings.skin )
  342. xgui.base.refreshSkin = nil
  343. end
  344.  
  345. --In case the string name had spaces, it sent the whole argument table. Convert it to a string here!
  346. if type( tabname ) == "table" then
  347. tabname = table.concat( tabname, " " )
  348. end
  349. --Sets the active tab to tabname if it was specified
  350. if tabname and tabname ~= "" then
  351. local found, settingsTab
  352. for _, v in ipairs( xgui.modules.tab ) do
  353. if string.lower( v.name ) == "settings" then settingsTab = v.tabpanel end
  354. if string.lower( v.name ) == string.lower( tabname ) and v.panel:GetParent() ~= xgui.null then
  355. xgui.base:SetActiveTab( v.tabpanel )
  356. if xgui.anchor:IsVisible() then return end
  357. found = true
  358. break
  359. end
  360. end
  361. if not found then
  362. for _, v in ipairs( xgui.modules.setting ) do
  363. if string.lower( v.name ) == string.lower( tabname ) and v.panel:GetParent() ~= xgui.null then
  364. xgui.base:SetActiveTab( settingsTab )
  365. xgui.settings_tabs:SetActiveTab( v.tabpanel )
  366. if xgui.anchor:IsVisible() then return end
  367. found = true
  368. break
  369. end
  370. end
  371. end
  372. if not found then return end --If invalid input was taken, then do nothing.
  373. end
  374.  
  375. xgui.base.animOpen()
  376. gui.EnableScreenClicker( true )
  377. RestoreCursorPosition()
  378. xgui.anchor:SetMouseInputEnabled( true )
  379.  
  380. --Calls the functions requesting to hook when XGUI is opened
  381. xgui.callUpdate( "onOpen" )
  382. end
  383.  
  384. function xgui.hide()
  385. if not xgui.anchor then return end
  386. if not xgui.anchor:IsVisible() then return end
  387. RememberCursorPosition()
  388. gui.EnableScreenClicker( false )
  389. xgui.anchor:SetMouseInputEnabled( false )
  390. xgui.base.animClose()
  391. CloseDermaMenus()
  392. end
  393.  
  394. function xgui.toggle( tabname )
  395. if xgui.anchor and ( not xgui.anchor:IsVisible() or ( tabname and #tabname ~= 0 ) ) then
  396. xgui.show( tabname )
  397. else
  398. xgui.hide()
  399. end
  400. end
  401.  
  402. --New XGUI Data stuff
  403. function xgui.expectChunks( numofchunks )
  404. if xgui.isInstalled then
  405. xgui.expectingdata = true
  406. xgui.chunkbox.max = numofchunks
  407. xgui.chunkbox.value = 0
  408. xgui.chunkbox:SetFraction( 0 )
  409. xgui.chunkbox.Label:SetText( "Getting data: Waiting for server..." )
  410. xgui.chunkbox:SetVisible( true )
  411. xgui.flushQueue( "chunkbox" ) --Remove the queue entry that would hide the chunkbox
  412. end
  413. end
  414.  
  415. function xgui.getChunk( flag, datatype, data )
  416. if xgui.expectingdata then
  417. --print( datatype, flag ) --Debug
  418. xgui.chunkbox:Progress( datatype )
  419. if flag == -1 then return --Ignore these chunks
  420. elseif flag == 0 then --Data should be purged
  421. table.Empty( xgui.data[datatype] )
  422. xgui.flushQueue( datatype )
  423. xgui.callUpdate( datatype, "clear" )
  424. elseif flag == 1 then
  425. if not xgui.mergeData then --A full data table is coming in
  426. if not data then data = {} end --Failsafe for no table being sent
  427. xgui.flushQueue( datatype )
  428. table.Empty( xgui.data[datatype] )
  429. table.Merge( xgui.data[datatype], data )
  430. xgui.callUpdate( datatype, "clear" )
  431. xgui.callUpdate( datatype, "process", data )
  432. xgui.callUpdate( datatype, "done" )
  433. else --A chunk of data is coming in
  434. table.Merge( xgui.data[datatype], data )
  435. xgui.callUpdate( datatype, "process", data )
  436. end
  437. elseif flag == 2 or flag == 3 then --Add/Update a portion of data
  438. table.Merge( xgui.data[datatype], data )
  439. xgui.callUpdate( datatype, flag == 2 and "add" or "update", data )
  440. elseif flag == 4 then --Remove a key from the table
  441. xgui.removeDataEntry( xgui.data[datatype], data ) --Needs to be called recursively!
  442. xgui.callUpdate( datatype, "remove", data )
  443. elseif flag == 5 then --Begin a set of chunks (Clear the old data, then flag to merge incoming data)
  444. table.Empty( xgui.data[datatype] )
  445. xgui.mergeData = true
  446. xgui.flushQueue( datatype )
  447. xgui.callUpdate( datatype, "clear" )
  448. elseif flag == 6 then --End a set of chunks (Clear the merge flag)
  449. xgui.mergeData = nil
  450. xgui.callUpdate( datatype, "done" )
  451. end
  452. xgui.callUpdate( datatype )
  453. end
  454. end
  455.  
  456. function xgui.removeDataEntry( data, entry )
  457. for k, v in pairs( entry ) do
  458. if type( v ) == "table" then
  459. xgui.removeDataEntry( data[k], v )
  460. else
  461. if type(v) == "number" then
  462. table.remove( data, v )
  463. else
  464. data[v] = nil
  465. end
  466. end
  467. end
  468. end
  469.  
  470. function xgui.callUpdate( dtype, event, data )
  471. --Run any functions that request to be called when "curtable" is updated
  472. if not xgui.hook[dtype] or ( event and not xgui.hook[dtype][event] ) then
  473. Msg( "XGUI: Attemped to call nonexistent type or event to a hook! (" .. dtype .. ", " .. ( event or "nil" ) .. ")\n" )
  474. else
  475. if not event then
  476. for _, func in ipairs( xgui.hook[dtype] ) do func( data ) end
  477. else
  478. for _, func in ipairs( xgui.hook[dtype][event] ) do func( data ) end
  479. end
  480. end
  481. end
  482.  
  483. --If the player's group is changed, reprocess the XGUI modules for permissions, and request for extra data if needed
  484. function xgui.PermissionsChanged( ply )
  485. if ply == LocalPlayer() and xgui.isInstalled then
  486. xgui.processModules()
  487. local types = {}
  488. for dtype, data in pairs( xgui.data ) do
  489. if table.Count( data ) > 0 then table.insert( types, dtype ) end
  490. end
  491. RunConsoleCommand( "xgui", "refreshdata", unpack( types ) )
  492. end
  493. end
  494. hook.Add( "UCLAuthed", "XGUI_PermissionsChanged", xgui.PermissionsChanged )
  495.  
  496. function xgui.getInstalled()
  497. if not xgui.isInstalled then
  498. if xgui.notInstalledWarning then
  499. xgui.notInstalledWarning:Remove()
  500. xgui.notInstalledWarning = nil
  501. end
  502. xgui.isInstalled = true
  503. xgui.offlineMode = false
  504. RunConsoleCommand( "xgui", "getdata" )
  505. end
  506. end
  507.  
  508. function xgui.cmd_base( ply, func, args )
  509. if not args[ 1 ] then
  510. xgui.toggle()
  511. elseif xgui.isInstalled then --First check that it's installed
  512. RunConsoleCommand( "_xgui", unpack( args ) )
  513. end
  514. end
  515.  
  516. function xgui.tab_completes()
  517. return xgui.tabcompletes
  518. end
  519.  
  520. function xgui.ulxmenu_tab_completes()
  521. return xgui.ulxmenucompletes
  522. end
  523.  
  524. ULib.cmds.addCommandClient( "xgui", xgui.cmd_base )
  525. ULib.cmds.addCommandClient( "xgui show", function( ply, cmd, args ) xgui.show( args ) end, xgui.tab_completes )
  526. ULib.cmds.addCommandClient( "xgui hide", xgui.hide )
  527. ULib.cmds.addCommandClient( "xgui toggle", function() xgui.toggle() end )
  528.  
  529. --local ulxmenu = ulx.command( CATEGORY_NAME, "ulx menu", ulx.menu, "!menu" )
  530. ULib.cmds.addCommandClient( "ulx menu", function( ply, cmd, args ) xgui.toggle( args ) end, xgui.ulxmenu_tab_completes )
Add Comment
Please, Sign In to add comment