PageRenderTime 100ms CodeModel.GetById 50ms app.highlight 3ms RepoModel.GetById 27ms app.codeStats 0ms

/Tukui/modules/extras/align.lua

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