/Tukui/modules/extras/align.lua

http://github.com/Asphyxia/Tukui · Lua · 53 lines · 43 code · 7 blank · 3 comment · 6 complexity · 4f6d818a39953bb6c5d6623176441650 MD5 · raw file

  1. ---------------------------------------------------------------------------------------------
  2. -- Align.lua - Credits to Epicgrim
  3. ---------------------------------------------------------------------------------------------
  4. local T, C, L = unpack( select( 2, ... ) )
  5. SLASH_ALI1 = "/ali"
  6. SlashCmdList["ALI"] = function( gridsize )
  7. local defsize = 16
  8. local w = tonumber( string.match( ( { GetScreenResolutions() } )[GetCurrentResolution()], "(%d+)x+%d" ) )
  9. local h = tonumber( string.match( ( { GetScreenResolutions() } )[GetCurrentResolution()], "%d+x(%d+)" ) )
  10. local x = tonumber( gridsize ) or defsize
  11. function Grid()
  12. ali = CreateFrame( "Frame", nil, UIParent )
  13. ali:SetFrameLevel( 0 )
  14. ali:SetFrameStrata( "BACKGROUND" )
  15. for i = - ( w / x / 2 ), w / x / 2 do
  16. local Aliv = ali:CreateTexture( nil, "BACKGROUND" )
  17. Aliv:SetTexture( .3, 0, 0, .7 )
  18. Aliv:Point( "CENTER", UIParent, "CENTER", i * x, 0 )
  19. Aliv:SetSize( 1, h )
  20. end
  21. for i = - ( h / x / 2 ), h / x / 2 do
  22. local Alih = ali:CreateTexture( nil, "BACKGROUND" )
  23. Alih:SetTexture( .3, 0, 0, .7 )
  24. Alih:Point( "CENTER", UIParent, "CENTER", 0, i * x )
  25. Alih:SetSize( w, 1 )
  26. end
  27. end
  28. if Ali then
  29. if ox ~= x then
  30. ox = x
  31. ali:Hide()
  32. Grid()
  33. Ali = true
  34. print( "Ali: ON" )
  35. else
  36. ali:Hide()
  37. print( "Ali: OFF" )
  38. Ali = false
  39. end
  40. else
  41. ox = x
  42. Grid()
  43. Ali = true
  44. print( "Ali: ON" )
  45. end
  46. end