vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Wrap OutfitDisplayFrame with our "improvements" |
2 | FishingBuddy.OutfitFrame = {}; |
||
3 | |||
4 | local function StylePoints(outfit) |
||
5 | local isp = FishingBuddy.OutfitManager.ItemStylePoints; |
||
6 | local points = 0; |
||
7 | if ( outfit )then |
||
8 | for slot in outfit do |
||
9 | if ( outfit[slot].item ) then |
||
10 | local _,_,check, enchant = string.find(outfit[slot].item, |
||
11 | "^(%d+):(%d+)"); |
||
12 | points = points + isp(check, enchant); |
||
13 | end |
||
14 | end |
||
15 | end |
||
16 | return points; |
||
17 | end |
||
18 | |||
19 | local match; |
||
20 | local function ItemBonusPoints(item) |
||
21 | local points = 0; |
||
22 | if ( item and item ~= "" ) then |
||
23 | if ( not match ) then |
||
24 | match = FishingBuddy.GetFishingSkillName().." %+(%d+)"; |
||
25 | end |
||
26 | FishingOutfitTooltip:SetHyperlink("item:"..item); |
||
27 | local bodyslot = FishingOutfitTooltipTextLeft2:GetText(); |
||
28 | local textline = 2; |
||
29 | while (bodyslot) do |
||
30 | local _,_,bonus = string.find(bodyslot, match); |
||
31 | if bonus then |
||
32 | points = points + bonus; |
||
33 | end |
||
34 | textline = textline + 1; |
||
35 | bodyslot = getglobal("FishingOutfitTooltipTextLeft"..textline):GetText(); |
||
36 | end |
||
37 | -- See if the Eternium Fishing Line has been applied |
||
38 | local _,_,check, enchant = string.find(item, "^(%d+):(%d+)"); |
||
39 | if ( enchant == "2603" ) then |
||
40 | points = points + 5; |
||
41 | end |
||
42 | end |
||
43 | return points; |
||
44 | end |
||
45 | |||
46 | local function BonusPoints(outfit) |
||
47 | local points = 0; |
||
48 | if ( outfit )then |
||
49 | for slot in outfit do |
||
50 | points = points + ItemBonusPoints(outfit[slot].item); |
||
51 | end |
||
52 | end |
||
53 | return points; |
||
54 | end |
||
55 | |||
56 | local function UpdateSwitchButton(outfit) |
||
57 | if ( outfit and not OutfitDisplayFrame_SwitchWillFail(FishingOutfitFrame, outfit) ) then |
||
58 | FishingOutfitSwitchButton:Enable(); |
||
59 | else |
||
60 | FishingOutfitSwitchButton:Disable(); |
||
61 | end |
||
62 | end |
||
63 | |||
64 | FishingBuddy.OutfitFrame.OutfitChanged = function(button) |
||
65 | local outfit = OutfitDisplayFrame_GetOutfit(FishingOutfitFrame); |
||
66 | if ( outfit ) then |
||
67 | FishingBuddy.SetOutfit(outfit); |
||
68 | end |
||
69 | local points = BonusPoints(outfit); |
||
70 | if ( points >= 0 ) then |
||
71 | points = "+"..points; |
||
72 | else |
||
73 | points = 0 - points; |
||
74 | points = "-"..points; |
||
75 | end |
||
76 | FishingOutfitSkill:SetText(FishingBuddy.CONFIG_SKILL_TEXT..points); |
||
77 | points = StylePoints(outfit); |
||
78 | local pstring; |
||
79 | if ( points == 1 ) then |
||
80 | pstring = FishingBuddy.POINT; |
||
81 | else |
||
82 | pstring = FishingBuddy.POINTS; |
||
83 | end |
||
84 | FishingOutfitStyle:SetText(FishingBuddy.CONFIG_STYLISH_TEXT..points.." "..pstring); |
||
85 | UpdateSwitchButton(outfit); |
||
86 | FishingOutfitFrame.valid = true; |
||
87 | end |
||
88 | |||
89 | FishingBuddy.OutfitFrame.OnLoad = function() |
||
90 | -- Handle the override |
||
91 | if ( OutfitDisplayFrame_OnLoad ) then |
||
92 | OutfitDisplayFrame_OnLoad(); |
||
93 | FishingOutfitSkill.tooltip = FishingBuddy.CONFIG_SKILL_INFO; |
||
94 | FishingOutfitStyle.tooltip = FishingBuddy.CONFIG_STYLISH_INFO; |
||
95 | FishingOutfitSwitchButton:SetText(FishingBuddy.SWITCHOUTFIT); |
||
96 | FishingOutfitFrame.OutfitChanged = FishingBuddy.OutfitFrame.OutfitChanged; |
||
97 | else |
||
98 | FishingBuddy.DisableSubFrame("FishingOutfitFrame"); |
||
99 | end |
||
100 | end |
||
101 | |||
102 | FishingBuddy.OutfitFrame.OnShow = function() |
||
103 | if ( not this.valid ) then |
||
104 | local outfit = FishingBuddy.GetOutfit(); |
||
105 | OutfitDisplayFrame_SetOutfit(FishingOutfitFrame, outfit); |
||
106 | FishingBuddy.OutfitFrame.OutfitChanged(); |
||
107 | end |
||
108 | end |
||
109 | |||
110 | FishingBuddy.OutfitFrame.OnHide = function() |
||
111 | -- FishingOutfitFrame_OutfitChanged(); |
||
112 | end |
||
113 | |||
114 | FishingBuddy.OutfitFrame.Button_OnClick = function() |
||
115 | -- make sure we have the current state |
||
116 | FishingBuddy.SetOutfit(OutfitDisplayFrame_GetOutfit(FishingOutfitFrame)); |
||
117 | FishingBuddy.OutfitFrame.Switch(); |
||
118 | end |
||
119 | |||
120 | -- only have one outfit at the moment |
||
121 | -- don't switch if |
||
122 | -- we can't find everything in the outfit |
||
123 | -- we have saved stuff but we're not wearing everything in the outfit |
||
124 | -- We don't have the outfit display frame! |
||
125 | FishingBuddy.OutfitFrame.Switch = function() |
||
126 | if (CursorHasItem()) then |
||
127 | FishingBuddy.UIError(FishingBuddy.CURSORBUSYMSG); |
||
128 | return false; |
||
129 | end |
||
130 | if ( OutfitDisplayFrame_IsSwapping() ) then |
||
131 | FishingBuddy.UIError(OUTFITDISPLAYFRAME_TOOFASTMSG); |
||
132 | return false; |
||
133 | end |
||
134 | |||
135 | local isfishing = FishingBuddy.IsFishingPole(); |
||
136 | local outfit = FishingBuddy.GetOutfit(); |
||
137 | local waswearing = FishingBuddy.GetWasWearing(); |
||
138 | if ( waswearing ) then |
||
139 | local msg; |
||
140 | |||
141 | if ( isfishing ) then |
||
142 | msg = OutfitDisplayFrame_SwitchWillFail(FishingOutfitFrame, waswearing); |
||
143 | else |
||
144 | msg = FishingBuddy.CANTSWITCHBACK; |
||
145 | FishingBuddy.SetWasWearing(nil); |
||
146 | StartedFishing = nil; |
||
147 | end |
||
148 | |||
149 | if ( msg ) then |
||
150 | FishingBuddy.UIError(msg); |
||
151 | return false; |
||
152 | end |
||
153 | local check = OutfitDisplayFrame_SwitchOutfit(waswearing); |
||
154 | if ( check ) then |
||
155 | FishingBuddy.SetWasWearing(nil); |
||
156 | FishingBuddy.OutfitManager.CheckSwitch(false); |
||
157 | end |
||
158 | elseif ( outfit ) then |
||
159 | local msg; |
||
160 | if ( not isfishing ) then |
||
161 | msg = OutfitDisplayFrame_SwitchWillFail(FishingOutfitFrame, outfit); |
||
162 | else |
||
163 | msg = FishingBuddy.POLEALREADYEQUIPPED; |
||
164 | end |
||
165 | if ( msg ) then |
||
166 | FishingBuddy.UIError(msg); |
||
167 | return false; |
||
168 | end |
||
169 | local waswearing = OutfitDisplayFrame_SwitchOutfit(outfit); |
||
170 | if ( waswearing ) then |
||
171 | FishingBuddy.SetWasWearing(waswearing); |
||
172 | FishingBuddy.OutfitManager.CheckSwitch(true); |
||
173 | end |
||
174 | else |
||
175 | FishingBuddy.UIError(FishingBuddy.NOOUTFITDEFINED); |
||
176 | end |
||
177 | return true; |
||
178 | end |