forked from wowgaming/3.3.5-interface-files
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CharacterFrame.lua
160 lines (145 loc) · 4.81 KB
/
CharacterFrame.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
CHARACTERFRAME_SUBFRAMES = { "PaperDollFrame", "PetPaperDollFrame", "SkillFrame", "ReputationFrame", "TokenFrame" };
local NUM_CHARACTERFRAME_TABS = 5;
function ToggleCharacter (tab)
local subFrame = _G[tab];
if ( subFrame ) then
if (not subFrame.hidden) then
PanelTemplates_SetTab(CharacterFrame, subFrame:GetID());
if ( CharacterFrame:IsShown() ) then
if ( subFrame:IsShown() ) then
HideUIPanel(CharacterFrame);
else
PlaySound("igCharacterInfoTab");
CharacterFrame_ShowSubFrame(tab);
end
else
ShowUIPanel(CharacterFrame);
CharacterFrame_ShowSubFrame(tab);
end
end
end
end
function CharacterFrame_ShowSubFrame (frameName)
for index, value in pairs(CHARACTERFRAME_SUBFRAMES) do
if ( value == frameName ) then
_G[value]:Show()
else
_G[value]:Hide();
end
end
end
function CharacterFrameTab_OnClick (self, button)
local name = self:GetName();
if ( name == "CharacterFrameTab1" ) then
ToggleCharacter("PaperDollFrame");
elseif ( name == "CharacterFrameTab2" ) then
ToggleCharacter("PetPaperDollFrame");
elseif ( name == "CharacterFrameTab3" ) then
ToggleCharacter("ReputationFrame");
elseif ( name == "CharacterFrameTab4" ) then
ToggleCharacter("SkillFrame");
elseif ( name == "CharacterFrameTab5" ) then
ToggleCharacter("TokenFrame");
end
PlaySound("igCharacterInfoTab");
end
function CharacterFrame_OnLoad (self)
self:RegisterEvent("UNIT_NAME_UPDATE");
self:RegisterEvent("UNIT_PORTRAIT_UPDATE");
self:RegisterEvent("PLAYER_PVP_RANK_CHANGED");
SetTextStatusBarTextPrefix(PlayerFrameHealthBar, HEALTH);
SetTextStatusBarTextPrefix(PlayerFrameManaBar, MANA);
SetTextStatusBarTextPrefix(MainMenuExpBar, XP);
TextStatusBar_UpdateTextString(MainMenuExpBar);
-- Tab Handling code
PanelTemplates_SetNumTabs(self, 5);
PanelTemplates_SetTab(self, 1);
end
function CharacterFrame_OnEvent (self, event, ...)
if ( not self:IsShown() ) then
return;
end
local arg1 = ...;
if ( event == "UNIT_PORTRAIT_UPDATE" ) then
if ( arg1 == "player" ) then
SetPortraitTexture(CharacterFramePortrait, arg1);
end
return;
elseif ( event == "UNIT_NAME_UPDATE" ) then
if ( arg1 == "player" ) then
CharacterNameText:SetText(UnitPVPName(arg1));
end
return;
elseif ( event == "PLAYER_PVP_RANK_CHANGED" ) then
CharacterNameText:SetText(UnitPVPName("player"));
end
end
function CharacterFrame_OnShow (self)
PlaySound("igCharacterInfoOpen");
SetPortraitTexture(CharacterFramePortrait, "player");
CharacterNameText:SetText(UnitPVPName("player"));
UpdateMicroButtons();
PlayerFrameHealthBar.showNumeric = true;
PlayerFrameManaBar.showNumeric = true;
PlayerFrameAlternateManaBar.showNumeric = true;
MainMenuExpBar.showNumeric = true;
PetFrameHealthBar.showNumeric = true;
PetFrameManaBar.showNumeric = true;
ShowTextStatusBarText(PlayerFrameHealthBar);
ShowTextStatusBarText(PlayerFrameManaBar);
ShowTextStatusBarText(PlayerFrameAlternateManaBar);
ShowTextStatusBarText(MainMenuExpBar);
ShowTextStatusBarText(PetFrameHealthBar);
ShowTextStatusBarText(PetFrameManaBar);
ShowWatchedReputationBarText();
SetButtonPulse(CharacterMicroButton, 0, 1); --Stop the button pulse
end
function CharacterFrame_OnHide (self)
PlaySound("igCharacterInfoClose");
UpdateMicroButtons();
PlayerFrameHealthBar.showNumeric = nil;
PlayerFrameManaBar.showNumeric = nil;
PlayerFrameAlternateManaBar.showNumeric = nil;
MainMenuExpBar.showNumeric =nil;
PetFrameHealthBar.showNumeric = nil;
PetFrameManaBar.showNumeric = nil;
HideTextStatusBarText(PlayerFrameHealthBar);
HideTextStatusBarText(PlayerFrameManaBar);
HideTextStatusBarText(PlayerFrameAlternateManaBar);
HideTextStatusBarText(MainMenuExpBar);
HideTextStatusBarText(PetFrameHealthBar);
HideTextStatusBarText(PetFrameManaBar);
HideWatchedReputationBarText();
end
local function CompareFrameSize(frame1, frame2)
return frame1:GetWidth() > frame2:GetWidth();
end
local CharTabtable = {};
function CharacterFrame_TabBoundsCheck(self)
if ( string.sub(self:GetName(), 1, 17) ~= "CharacterFrameTab" ) then
return;
end
local totalSize = 60;
for i=1, NUM_CHARACTERFRAME_TABS do
_G["CharacterFrameTab"..i.."Text"]:SetWidth(0);
PanelTemplates_TabResize(_G["CharacterFrameTab"..i], 0);
totalSize = totalSize + _G["CharacterFrameTab"..i]:GetWidth();
end
local diff = totalSize - 465
if ( diff > 0 and CharacterFrameTab5:IsShown() and CharacterFrameTab2:IsShown()) then
--Find the biggest tab
for i=1, NUM_CHARACTERFRAME_TABS do
CharTabtable[i]=_G["CharacterFrameTab"..i];
end
table.sort(CharTabtable, CompareFrameSize);
local i=1;
while ( diff > 0 and i <= NUM_CHARACTERFRAME_TABS) do
local tabText = _G[CharTabtable[i]:GetName().."Text"]
local change = min(10, diff);
tabText:SetWidth(tabText:GetWidth() - change);
diff = diff - change;
PanelTemplates_TabResize(CharTabtable[i], 0);
i = i+1;
end
end
end