Guest User

Untitled

a guest
May 23rd, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. local g_Root = getRootElement()
  2. local g_ResRoot = getResourceRootElement(getThisResource())
  3. --local g_Me = getLocalPlayer()
  4.  
  5. local g_Gui = nil
  6. function guiCmd()
  7.     if not g_Gui or not guiGetVisible(g_Gui._root) then
  8.         showGUI()
  9.     else
  10.         hideGUI()
  11.     end
  12. end
  13. addCommandHandler("gui", guiCmd)
  14.  
  15. function showGUI()
  16.     if not g_Gui then
  17.         buildGUI()
  18.     else
  19.         guiSetVisible(g_Gui._root, true)
  20.     end
  21.     showCursor(true)
  22. end
  23.  
  24. function buildGUI()
  25.     g_Gui = build_window()
  26.    
  27.     if g_Gui._placeHolders.frame_2 then
  28.         local rect = g_Gui._placeHolders.frame_2
  29.         g_Gui.manualLabel = guiCreateLabel(rect.left, rect.top, rect.width, rect.height, "Manually added label", false, rect.parent)
  30.         guiLabelSetColor(g_Gui.manualLabel, 0, 255, 0)
  31.     end
  32.    
  33.     if g_Gui.dynScrollArea then
  34.         g_Gui.dynamicWidgets = {}
  35.         local top = 0
  36.         for i=1,20 do
  37.             local widget, width, height = build_widget(g_Gui.dynScrollArea, 0, top)
  38.             guiSetText(widget.label, string.format("Dynamic item #%d", i))
  39.             table.insert(g_Gui.dynamicWidgets, widget)
  40.             top = top + height
  41.         end
  42.     end
  43. end
  44.  
  45.  
  46. function hideGUI()
  47.     if not g_Gui then
  48.         return
  49.     end
  50.     guiSetVisible(g_Gui._root, false)
  51.     showCursor(false)
  52. end
  53.  
  54. function on_closeBtn_clicked(button, state, absoluteX, absoluteY)
  55.     if (button ~= "left") or (state ~= "up") then
  56.         return
  57.     end
  58.    
  59.     hideGUI()
  60.    
  61. end
Advertisement
Add Comment
Please, Sign In to add comment