-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGhostFrame.lua
More file actions
executable file
·134 lines (110 loc) · 3.54 KB
/
GhostFrame.lua
File metadata and controls
executable file
·134 lines (110 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
-- Creates frame template for all buttons
function ghostCreateFrame()
local title = CreateFrame("Frame", "Ghost", UIParent)
title:SetMovable(1)
title:EnableMouse(1)
title:SetScript("OnMouseDown",function()
if ghost['lockFrame'] == false or IsShiftKeyDown() then
this:StartMoving();
end
end)
title:SetScript("OnMouseUp",function() this:StopMovingOrSizing() end)
title:SetPoint("CENTER",0,0)
title:SetWidth(209)
title:SetHeight(209)
Ghost:Hide();
end
-- Creates button
function ghostCreateButton()
local Frame = Ghost;
local newRow = true;
local i = 0;
for row = 1, 5, 1 do
for col = 1, 5, 1 do
i = i + 1;
local btn = CreateFrame("CheckButton", "ghostButton"..i, Frame, "ActionBarButtonTemplate")
btn:SetID(ghost["ButtonID"][i]);
if (newRow == true) then
if (i == 1) then
btn:SetPoint("TOPLEFT", Frame, 7, -24)
else
btn:SetPoint("TOP", "ghostButton"..i - 5, "BOTTOM", 0, -4)
end
newRow = false;
else
btn:SetPoint("LEFT", "ghostButton"..i - 1, "RIGHT",4 , 0)
end
btn:SetScript("OnDragStart", function()
if ghost['lockButton'] == false or IsShiftKeyDown() then
PickupAction(this:GetID())
end
end)
-- font template for buttons
btn.title = btn:CreateFontString("ghostButton"..i.."Text", "OVERLAY")
btn.title:SetFont(STANDARD_TEXT_FONT, 13, "OUTLINE")
btn.title:SetTextColor(1, 1, 1)
btn.title:SetPoint("TOP", btn ,"TOP", 0, 0)
end
newRow = true;
end
-- The title box. I rather like this.
local title = CreateFrame("Frame", "GhostGuideText", Ghost )
title:SetFrameStrata("BACKGROUND")
title:SetWidth(36)
title:SetHeight(36)
title:SetPoint("CENTER", "ghostButton13", "TOP", 0, -18)
local t = title:CreateTexture(nil,"BACKGROUND")
t:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Background")
t:SetAllPoints(title)
t:SetVertexColor(1, 1, 1, .5)
title.texture = t
title.title = title:CreateFontString(nil, "OVERLAY")
title.title:SetFont(STANDARD_TEXT_FONT, 12, "OUTLINE")
title.title:SetTextColor(1, 1, 0, .8)
title.title:SetPoint("TOP", title, "TOP", 0, -1)
title.title:SetText("Ghost")
end
-- Show frame under mouse pointer
function ghostShowFrame()
if (keystate == "down") then
local frameScale = ghost['frameScale'];
local mouseX, mouseY = GetCursorPosition();
local wowScale = UIParent:GetEffectiveScale()
Ghost:ClearAllPoints();
Ghost:SetScale(frameScale);
Ghost:SetPoint("CENTER",WorldFrame,"BOTTOMLEFT", ( mouseX / frameScale) / wowScale, (mouseY / frameScale) / wowScale );
-- Check if we need to show/ hide binding text
if ghost['showBindingText'] == true then
ghostButtonText();
else
ghostButtonTextHide();
end
GhostGuideText:Show();
Ghost:Show();
else
GhostGuideText:Hide();
Ghost:Hide();
end
end
-- Set button text
function ghostButtonText()
for i = 1, 25, 1 do
local key1, key2 = GetBindingKey(format("ghostButton" .. i));
key1 = tostring(key1);
key1 = string.gsub(key1,"ALT","a");
key1 = string.gsub(key1,"CTRL","c");
key1 = string.gsub(key1,"SHIFT","s");
key1 = string.gsub(key1,"NUMPAD", "np");
key1 = string.gsub(key1,"nil", "");
local gText = format("ghostButton"..i.."Text");
getglobal(gText):SetText(key1);
getglobal(gText):Show();
end
end
-- remove button text
function ghostButtonTextHide()
for i = 1, 25, 1 do
local gText = format("ghostButton"..i.."Text");
getglobal(gText):Hide();
end
end