-
Notifications
You must be signed in to change notification settings - Fork 6
/
ui.lua
321 lines (262 loc) · 10.9 KB
/
ui.lua
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
local _G = _G or getfenv(0)
local resizes = {
MainMenuBar, MainMenuExpBar, MainMenuBarMaxLevelBar,
ReputationWatchBar, ReputationWatchStatusBar,
}
local frames = {
BonusActionBarTexture0, BonusActionBarTexture1,
ShapeshiftBarLeft, ShapeshiftBarMiddle, ShapeshiftBarRight,
MainMenuMaxLevelBar2, MainMenuMaxLevelBar3,
}
local textures = {
MainMenuBarTexture0, MainMenuBarTexture1,
MainMenuXPBarTexture2, MainMenuXPBarTexture3,
ReputationWatchBarTexture2, ReputationWatchBarTexture3,
ReputationXPBarTexture2, ReputationXPBarTexture3,
SlidingActionBarTexture0, SlidingActionBarTexture1,
}
local normtextures = {
ShapeshiftButton1, ShapeshiftButton2,
ShapeshiftButton3, ShapeshiftButton4,
ShapeshiftButton5, ShapeshiftButton6,
}
-- general function to hide textures and frames
local function hide(frame, texture)
if not frame then return end
if texture and texture == 1 and frame.SetTexture then
frame:SetTexture("")
elseif texture and texture == 2 and frame.SetNormalTexture then
frame:SetNormalTexture("")
else
frame:ClearAllPoints()
frame.Show = function() return end
frame:Hide()
end
end
-- reduce actionbar size
for id, frame in pairs(resizes) do frame:SetWidth(488) end
-- hide reduced frames
for id, frame in pairs(frames) do hide(frame) end
-- clear reduced textures
for id, frame in pairs(textures) do hide(frame, 1) end
-- clear some button textures
for id, frame in pairs(normtextures) do hide(frame, 2) end
-- create a jump button
ActionButtonJmp = CreateFrame("CheckButton", "ActionButtonJmp", MainMenuBarArtFrame, "ActionButtonTemplate")
local ui = CreateFrame("Frame", "ShaguControllerUI", UIParent)
ui:RegisterEvent("PLAYER_ENTERING_WORLD")
ui:SetScript("OnEvent", function()
-- update ui when frame positions get managed
ui.manage_positions_hook = UIParent_ManageFramePositions
UIParent_ManageFramePositions = ui.manage_positions
ui:UnregisterAllEvents()
end)
ui:SetScript("OnUpdate", function()
-- update ui once the first frame is shown
UIParent_ManageFramePositions()
this:Hide()
end)
local actionhide = CreateFrame("Frame", "ShaguControllerActionHide", BonusActionBarFrame)
actionhide.buttons = {}
actionhide:SetScript("OnShow", function()
for button, bonus in pairs(this.buttons) do
if button:GetID() ~= 0 then
button:EnableMouse(bonus)
button:SetAlpha(bonus)
end
end
end)
actionhide:SetScript("OnHide", function()
for button, bonus in pairs(this.buttons) do
if button:GetID() ~= 0 then
button:EnableMouse(bonus == 0 and 1 or 0)
button:SetAlpha(bonus == 0 and 1 or 0)
end
end
end)
ui.manage_button = function(self, frame, pos, x, y, image, bonus)
if frame and tonumber(frame) then
self:manage_button(_G["ActionButton" .. frame], pos, x, y, image)
self:manage_button(_G["BonusActionButton" .. frame], pos, x, y, image, true)
return
end
if pos == "DISABLED" then
frame.Show = function() return end
frame:ClearAllPoints()
frame:Hide()
return
end
-- add button to actionhide registry
actionhide.buttons[frame] = bonus and 1 or 0
-- set button scale and set position
local scale = image == "" and 1 or 1.2
local revscale = scale == 1 and 1.2 or 1
frame:SetScale(scale)
frame:ClearAllPoints()
frame:SetPoint("CENTER", UIParent, pos, x*revscale, y*revscale)
-- hide keybind text
_G[frame:GetName().."HotKey"]:Hide()
-- add keybind icon
if not frame.keybind_icon then
frame.keybind_icon = CreateFrame("Frame", nil, frame)
frame.keybind_icon:SetFrameLevel(255)
frame.keybind_icon:SetAllPoints(frame)
frame.keybind_icon.tex = frame.keybind_icon:CreateTexture(nil, "OVERLAY")
frame.keybind_icon.tex:SetTexture(image)
frame.keybind_icon.tex:SetPoint("TOPRIGHT", frame.keybind_icon, "TOPRIGHT", 0, 0)
frame.keybind_icon.tex:SetWidth(16)
frame.keybind_icon.tex:SetHeight(16)
-- handle out of range as desaturation of keybind and icon
_G[frame:GetName().."HotKey"].SetVertexColor = function(self, r, g, b, a)
if r == 1.0 and g == 0.1 and b == 0.1 then
_G[frame:GetName().."Icon"]:SetDesaturated(true)
frame.keybind_icon.tex:SetDesaturated(true)
else
_G[frame:GetName().."Icon"]:SetDesaturated(false)
frame.keybind_icon.tex:SetDesaturated(false)
end
end
end
end
ui.manage_jump_button = function(self, frame)
local icon = _G[frame:GetName().."Icon"]
local name = _G[frame:GetName().."Name"]
icon:Show()
icon:SetTexture("Interface\\Icons\\inv_gizmo_rocketboot_01")
icon.SetTexture = function() return end
icon.Hide = function() return end
name:SetPoint("BOTTOM", 0, 5)
name:SetText("Jump")
name.SetText = function() return end
frame:Show()
frame.Hide = function() return end
frame.GetID = function() return 0 end
end
local buttonmap = {
-- dummy jump button
{ ActionButtonJmp, "BOTTOMRIGHT", -220, 45, "Interface\\AddOns\\ShaguController\\img\\a" },
-- right controls
{ 1, "BOTTOMRIGHT", -220, 135, "Interface\\AddOns\\ShaguController\\img\\y" },
{ 2, "BOTTOMRIGHT", -265, 90, "Interface\\AddOns\\ShaguController\\img\\x" },
{ 3, "BOTTOMRIGHT", -175, 90, "Interface\\AddOns\\ShaguController\\img\\b" },
{ 4, "BOTTOMRIGHT", -220, 90, "" },
-- left controls
{ 5, "BOTTOMLEFT", 220, 135, "Interface\\AddOns\\ShaguController\\img\\up" },
{ 6, "BOTTOMLEFT", 220, 90, "" },
-- This is my personal preference where the last 3 buttons of an actionbar
-- are usually mapped and mandatory skills for me. If you want to continue
-- the line, change this to 7,8,9 and change the disabled ones to 10,11,12.
-- also make sure to update the keybinds.lua accordingly.
{ 10, "BOTTOMLEFT", 265, 90, "Interface\\AddOns\\ShaguController\\img\\right" },
{ 11, "BOTTOMLEFT", 220, 45, "Interface\\AddOns\\ShaguController\\img\\down" },
{ 12, "BOTTOMLEFT", 175, 90, "Interface\\AddOns\\ShaguController\\img\\left" },
-- disabled
{ 7, "DISABLED" },
{ 8, "DISABLED" },
{ 9, "DISABLED" },
}
ui.manage_positions = function(a1, a2, a3)
-- run original function first
ui.manage_positions_hook(a1, a2, a3)
-- move and skin all buttons
for id, button in pairs(buttonmap) do
ui:manage_button(unpack(button))
end
-- skin jump button
ui:manage_jump_button(ActionButtonJmp)
-- move and resize chat
ChatFrameEditBox:ClearAllPoints()
ChatFrameEditBox:SetPoint("TOP", UIParent, "TOP", 0, -10)
ChatFrameEditBox:SetWidth(300)
ChatFrameEditBox:SetScale(2)
-- on-screen keyboard helper
ChatFrame1.oskHelper = ChatFrame1.oskHelper or CreateFrame("Button", nil, UIParent)
ChatFrame1.oskHelper:SetFrameStrata("BACKGROUND")
ChatFrame1.oskHelper:SetAllPoints(ChatFrame1)
ChatFrame1.oskHelper:SetScript("OnClick", function()
if not ChatFrameEditBox:IsVisible() then
ChatFrameEditBox:Show()
ChatFrameEditBox:Raise()
else
ChatFrameEditBox:Hide()
end
end)
ChatFrame1.oskHelper:SetScript("OnUpdate", function()
if ChatFrameEditBox:IsVisible() and this.state ~= 1 then
ChatFrame1:SetScale(2)
ChatFrame1:ClearAllPoints()
ChatFrame1:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0)
ChatFrame1:SetPoint("BOTTOMRIGHT", UIParent, "RIGHT", 0, -14)
FCF_SetWindowColor(ChatFrame1, 0,0,0)
FCF_SetWindowAlpha(ChatFrame1, .5)
this.state = 1
elseif not ChatFrameEditBox:IsVisible() and this.state ~= 0 then
local anchor = MainMenuBarArtFrame
anchor = MultiBarBottomLeft:IsVisible() and MultiBarBottomLeft or anchor
anchor = MultiBarBottomRight:IsVisible() and MultiBarBottomRight or anchor
anchor = ShapeshiftBarFrame:IsVisible() and ShapeshiftBarFrame or anchor
anchor = PetActionBarFrame:IsVisible() and PetActionBarFrame or anchor
ChatFrame1:SetScale(1)
ChatFrame1:ClearAllPoints()
ChatFrame1:SetPoint("LEFT", MultiBarBottomLeft, "LEFT", 17, 0)
ChatFrame1:SetPoint("RIGHT", MultiBarBottomLeft, "RIGHT", -17, 0)
ChatFrame1:SetPoint("BOTTOM", anchor, "TOP", 0, 13)
ChatFrame1:SetPoint("TOP", UIParent, "CENTER", 0, -200)
FCF_SetWindowColor(ChatFrame1, 0,0,0)
FCF_SetWindowAlpha(ChatFrame1, 0)
this.state = 0
end
end)
-- move and hide some chat buttons
ChatFrameMenuButton:Hide()
ChatFrameMenuButton.Show = function() return end
for i=1, NUM_CHAT_WINDOWS do
_G["ChatFrame"..i.."DownButton"]:ClearAllPoints()
_G["ChatFrame"..i.."DownButton"]:SetPoint("BOTTOMRIGHT", _G["ChatFrame"..i], "BOTTOMRIGHT", 0, -5)
_G["ChatFrame"..i.."UpButton"]:ClearAllPoints()
_G["ChatFrame"..i.."UpButton"]:SetPoint("RIGHT", _G["ChatFrame"..i.."DownButton"], "LEFT", 0, 0)
_G["ChatFrame"..i.."BottomButton"]:Hide()
_G["ChatFrame"..i.."BottomButton"].Show = function() return end
end
-- move pet action bar
local anchor = MainMenuBarArtFrame
anchor = MultiBarBottomLeft:IsVisible() and MultiBarBottomLeft or anchor
anchor = MultiBarBottomRight:IsVisible() and MultiBarBottomRight or anchor
anchor = ShapeshiftBarFrame:IsVisible() and ShapeshiftBarFrame or anchor
PetActionBarFrame:ClearAllPoints()
PetActionBarFrame:SetPoint("BOTTOM", anchor, "TOP", 0, 3)
-- move shapeshift bar
local anchor = MainMenuBarArtFrame
anchor = MultiBarBottomLeft:IsVisible() and MultiBarBottomLeft or anchor
anchor = MultiBarBottomRight:IsVisible() and MultiBarBottomRight or anchor
ShapeshiftBarFrame:ClearAllPoints()
ShapeshiftBarFrame:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 15, -5)
-- move normal action bars
MultiBarBottomLeft:ClearAllPoints()
MultiBarBottomLeft:SetPoint("BOTTOM", MainMenuBar, "TOP", 0, 20)
MultiBarBottomRight:ClearAllPoints()
MultiBarBottomRight:SetPoint("BOTTOM", MultiBarBottomLeft, "TOP", 0, 5)
-- experience bar
MainMenuXPBarTexture0:SetPoint("LEFT", MainMenuExpBar, "LEFT")
MainMenuXPBarTexture1:SetPoint("RIGHT", MainMenuExpBar, "RIGHT")
-- reputation bar
ReputationWatchBar:SetPoint("BOTTOM", MainMenuExpBar, "TOP", 0, 0)
ReputationWatchBarTexture0:SetPoint("LEFT", ReputationWatchBar, "LEFT")
ReputationWatchBarTexture1:SetPoint("RIGHT", ReputationWatchBar, "RIGHT")
-- move elements for reduced actionbar size
MainMenuMaxLevelBar0:SetPoint("LEFT", MainMenuBarArtFrame, "LEFT")
MainMenuBarTexture2:SetPoint("LEFT", MainMenuBarArtFrame, "LEFT")
MainMenuBarTexture3:SetPoint("RIGHT", MainMenuBarArtFrame, "RIGHT")
ActionBarDownButton:SetPoint("BOTTOMLEFT", MainMenuBarArtFrame, "BOTTOMLEFT", -5, -5)
ActionBarUpButton:SetPoint("TOPLEFT", MainMenuBarArtFrame, "TOPLEFT", -5, -5)
MainMenuBarPageNumber:SetPoint("LEFT", MainMenuBarArtFrame, "LEFT", 25, -5)
CharacterMicroButton:SetPoint("LEFT", MainMenuBarArtFrame, "LEFT", 38, 0)
MainMenuBarLeftEndCap:SetPoint("RIGHT", MainMenuBarArtFrame, "LEFT", 30, 0)
MainMenuBarRightEndCap:SetPoint("LEFT", MainMenuBarArtFrame, "RIGHT", -30, 0)
-- move pfQuest arrow if existing
if pfQuest and pfQuest.route and pfQuest.route.arrow then
pfQuest.route.arrow:SetPoint("CENTER", 0, -120)
end
end
-- save to main frame
ShaguController.ui = ui