vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local grid
2 local boxSize = 32
3  
4 function Grid_Show()
5 if not grid then
6 Grid_Create()
7 elseif grid.boxSize ~= boxSize then
8 grid:Hide()
9 Grid_Create()
10 else
11 grid:Show()
12 end
13 end
14  
15 function Grid_Hide()
16 if grid then
17 grid:Hide()
18 end
19 end
20  
21 local isAligning = false
22 SLASH_TOGGLEGRID1 = "/align"
23 SlashCmdList["TOGGLEGRID"] = function(arg)
24 if isAligning then
25 Grid_Hide()
26 isAligning = false
27 else
28 boxSize = (math.ceil((tonumber(arg) or boxSize) / 32) * 32)
29 if boxSize > 128 then boxSize = 128 end
30 Grid_Show()
31 isAligning = true
32 end
33 end
34  
35 function Grid_Create()
36 grid = CreateFrame('Frame', nil, UIParent)
37 grid.boxSize = boxSize
38 grid:SetAllPoints(UIParent)
39  
40 local size = 2
41 local width = GetScreenWidth()
42 local ratio = width / GetScreenHeight()
43 local height = GetScreenHeight() * ratio
44  
45 local wStep = width / boxSize
46 local hStep = height / boxSize
47  
48 for i = 0, boxSize do
49 local tx = grid:CreateTexture(nil, 'BACKGROUND')
50 if i == boxSize / 2 then
51 tx:SetTexture(1, 0, 0, 0.5)
52 else
53 tx:SetTexture(0, 0, 0, 0.5)
54 end
55 tx:SetPoint("TOPLEFT", grid, "TOPLEFT", i*wStep - (size/2), 0)
56 tx:SetPoint('BOTTOMRIGHT', grid, 'BOTTOMLEFT', i*wStep + (size/2), 0)
57 end
58 height = GetScreenHeight()
59  
60 do
61 local tx = grid:CreateTexture(nil, 'BACKGROUND')
62 tx:SetTexture(1, 0, 0, 0.5)
63 tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2) + (size/2))
64 tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2 + size/2))
65 end
66  
67 for i = 1, math.floor((height/2)/hStep) do
68 local tx = grid:CreateTexture(nil, 'BACKGROUND')
69 tx:SetTexture(0, 0, 0, 0.5)
70  
71 tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2+i*hStep) + (size/2))
72 tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2+i*hStep + size/2))
73  
74 tx = grid:CreateTexture(nil, 'BACKGROUND')
75 tx:SetTexture(0, 0, 0, 0.5)
76  
77 tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2-i*hStep) + (size/2))
78 tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2-i*hStep + size/2))
79  
80 end
81  
82 end