forked from aim2kill/FishingBuddy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFishingOutfitFrame.lua
executable file
·178 lines (165 loc) · 5.33 KB
/
FishingOutfitFrame.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
-- Wrap OutfitDisplayFrame with our "improvements"
FishingBuddy.OutfitFrame = {};
local function StylePoints(outfit)
local isp = FishingBuddy.OutfitManager.ItemStylePoints;
local points = 0;
if ( outfit )then
for slot in outfit do
if ( outfit[slot].item ) then
local _,_,check, enchant = string.find(outfit[slot].item,
"^(%d+):(%d+)");
points = points + isp(check, enchant);
end
end
end
return points;
end
local match;
local function ItemBonusPoints(item)
local points = 0;
if ( item and item ~= "" ) then
if ( not match ) then
match = FishingBuddy.GetFishingSkillName().." %+(%d+)";
end
FishingOutfitTooltip:SetHyperlink("item:"..item);
local bodyslot = FishingOutfitTooltipTextLeft2:GetText();
local textline = 2;
while (bodyslot) do
local _,_,bonus = string.find(bodyslot, match);
if bonus then
points = points + bonus;
end
textline = textline + 1;
bodyslot = getglobal("FishingOutfitTooltipTextLeft"..textline):GetText();
end
-- See if the Eternium Fishing Line has been applied
local _,_,check, enchant = string.find(item, "^(%d+):(%d+)");
if ( enchant == "2603" ) then
points = points + 5;
end
end
return points;
end
local function BonusPoints(outfit)
local points = 0;
if ( outfit )then
for slot in outfit do
points = points + ItemBonusPoints(outfit[slot].item);
end
end
return points;
end
local function UpdateSwitchButton(outfit)
if ( outfit and not OutfitDisplayFrame_SwitchWillFail(FishingOutfitFrame, outfit) ) then
FishingOutfitSwitchButton:Enable();
else
FishingOutfitSwitchButton:Disable();
end
end
FishingBuddy.OutfitFrame.OutfitChanged = function(button)
local outfit = OutfitDisplayFrame_GetOutfit(FishingOutfitFrame);
if ( outfit ) then
FishingBuddy.SetOutfit(outfit);
end
local points = BonusPoints(outfit);
if ( points >= 0 ) then
points = "+"..points;
else
points = 0 - points;
points = "-"..points;
end
FishingOutfitSkill:SetText(FishingBuddy.CONFIG_SKILL_TEXT..points);
points = StylePoints(outfit);
local pstring;
if ( points == 1 ) then
pstring = FishingBuddy.POINT;
else
pstring = FishingBuddy.POINTS;
end
FishingOutfitStyle:SetText(FishingBuddy.CONFIG_STYLISH_TEXT..points.." "..pstring);
UpdateSwitchButton(outfit);
FishingOutfitFrame.valid = true;
end
FishingBuddy.OutfitFrame.OnLoad = function()
-- Handle the override
if ( OutfitDisplayFrame_OnLoad ) then
OutfitDisplayFrame_OnLoad();
FishingOutfitSkill.tooltip = FishingBuddy.CONFIG_SKILL_INFO;
FishingOutfitStyle.tooltip = FishingBuddy.CONFIG_STYLISH_INFO;
FishingOutfitSwitchButton:SetText(FishingBuddy.SWITCHOUTFIT);
FishingOutfitFrame.OutfitChanged = FishingBuddy.OutfitFrame.OutfitChanged;
else
FishingBuddy.DisableSubFrame("FishingOutfitFrame");
end
end
FishingBuddy.OutfitFrame.OnShow = function()
if ( not this.valid ) then
local outfit = FishingBuddy.GetOutfit();
OutfitDisplayFrame_SetOutfit(FishingOutfitFrame, outfit);
FishingBuddy.OutfitFrame.OutfitChanged();
end
end
FishingBuddy.OutfitFrame.OnHide = function()
-- FishingOutfitFrame_OutfitChanged();
end
FishingBuddy.OutfitFrame.Button_OnClick = function()
-- make sure we have the current state
FishingBuddy.SetOutfit(OutfitDisplayFrame_GetOutfit(FishingOutfitFrame));
FishingBuddy.OutfitFrame.Switch();
end
-- only have one outfit at the moment
-- don't switch if
-- we can't find everything in the outfit
-- we have saved stuff but we're not wearing everything in the outfit
-- We don't have the outfit display frame!
FishingBuddy.OutfitFrame.Switch = function()
if (CursorHasItem()) then
FishingBuddy.UIError(FishingBuddy.CURSORBUSYMSG);
return false;
end
if ( OutfitDisplayFrame_IsSwapping() ) then
FishingBuddy.UIError(OUTFITDISPLAYFRAME_TOOFASTMSG);
return false;
end
local isfishing = FishingBuddy.IsFishingPole();
local outfit = FishingBuddy.GetOutfit();
local waswearing = FishingBuddy.GetWasWearing();
if ( waswearing ) then
local msg;
if ( isfishing ) then
msg = OutfitDisplayFrame_SwitchWillFail(FishingOutfitFrame, waswearing);
else
msg = FishingBuddy.CANTSWITCHBACK;
FishingBuddy.SetWasWearing(nil);
StartedFishing = nil;
end
if ( msg ) then
FishingBuddy.UIError(msg);
return false;
end
local check = OutfitDisplayFrame_SwitchOutfit(waswearing);
if ( check ) then
FishingBuddy.SetWasWearing(nil);
FishingBuddy.OutfitManager.CheckSwitch(false);
end
elseif ( outfit ) then
local msg;
if ( not isfishing ) then
msg = OutfitDisplayFrame_SwitchWillFail(FishingOutfitFrame, outfit);
else
msg = FishingBuddy.POLEALREADYEQUIPPED;
end
if ( msg ) then
FishingBuddy.UIError(msg);
return false;
end
local waswearing = OutfitDisplayFrame_SwitchOutfit(outfit);
if ( waswearing ) then
FishingBuddy.SetWasWearing(waswearing);
FishingBuddy.OutfitManager.CheckSwitch(true);
end
else
FishingBuddy.UIError(FishingBuddy.NOOUTFITDEFINED);
end
return true;
end