vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | TITAN_MONEY_ID = "Money"; |
2 | TITAN_MONEY_FREQUENCY = 1; |
||
3 | |||
4 | local startMoney; |
||
5 | local startSessionTime; |
||
6 | |||
7 | function TitanPanelMoneyButton_OnLoad() |
||
8 | this.registry = { |
||
9 | id = TITAN_MONEY_ID, |
||
10 | builtIn = 1, |
||
11 | version = TITAN_VERSION, |
||
12 | menuText = TITAN_MONEY_MENU_TEXT, |
||
13 | tooltipTitle = TITAN_MONEY_TOOLTIP, |
||
14 | tooltipTextFunction = "TitanPanelMoneyButton_GetTooltipText", |
||
15 | frequency = TITAN_MONEY_FREQUENCY, |
||
16 | updateType = TITAN_PANEL_UPDATE_TOOLTIP, |
||
17 | }; |
||
18 | |||
19 | SmallMoneyFrame_OnLoad(); |
||
20 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
21 | |||
22 | WoW_OpenCoinPickupFrame = OpenCoinPickupFrame; |
||
23 | OpenCoinPickupFrame = Titan_OpenCoinPickupFrame; |
||
24 | end |
||
25 | |||
26 | function TitanPanelMoneyButton_OnEvent() |
||
27 | MoneyFrame_OnEvent() |
||
28 | if (event == "PLAYER_ENTERING_WORLD") then |
||
29 | MoneyFrame_UpdateMoney(); |
||
30 | if (not startMoney) then |
||
31 | startMoney = GetMoney(); |
||
32 | startSessionTime = 0; |
||
33 | end |
||
34 | end |
||
35 | end |
||
36 | |||
37 | function TitanPanelMoneyCopperButton_OnClick(button) |
||
38 | if (button == "LeftButton") then |
||
39 | local parent = this:GetParent(); |
||
40 | OpenCoinPickupFrame(1, MoneyTypeInfo[parent.moneyType].UpdateFunc(), parent); |
||
41 | parent.hasPickup = 1; |
||
42 | end |
||
43 | end |
||
44 | |||
45 | function TitanPanelMoneySilverButton_OnClick(button) |
||
46 | if (button == "LeftButton") then |
||
47 | local parent = this:GetParent(); |
||
48 | OpenCoinPickupFrame(COPPER_PER_SILVER, MoneyTypeInfo[parent.moneyType].UpdateFunc(), parent); |
||
49 | parent.hasPickup = 1; |
||
50 | end |
||
51 | end |
||
52 | |||
53 | function TitanPanelMoneyGoldButton_OnClick(button) |
||
54 | if (button == "LeftButton") then |
||
55 | local parent = this:GetParent(); |
||
56 | OpenCoinPickupFrame(COPPER_PER_GOLD, MoneyTypeInfo[parent.moneyType].UpdateFunc(), parent); |
||
57 | parent.hasPickup = 1; |
||
58 | end |
||
59 | end |
||
60 | |||
61 | function TitanPanelMoneyButton_GetTooltipText() |
||
62 | local sessionTime = TitanUtils_GetSessionTime() - startSessionTime; |
||
63 | local initialMoney = startMoney; |
||
64 | local fluctMoney = GetMoney() - initialMoney; |
||
65 | local fluctMoneyPerHour = TitanPanelMoneyButton_GetMoneyPerHour(fluctMoney, sessionTime); |
||
66 | |||
67 | if fluctMoneyPerHour == nil then |
||
68 | fluctMoneyPerHour = 0; |
||
69 | end |
||
70 | -- Current money Text |
||
71 | local currentMoneyRichText = TITAN_MONEY_TOOLTIP_CURRENT.."\t".. |
||
72 | TitanUtils_GetHighlightText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(GetMoney()))); |
||
73 | |||
74 | -- Initial money Text |
||
75 | local initialMoneyRichText = TITAN_MONEY_TOOLTIP_INITIAL.."\t".. |
||
76 | TitanUtils_GetHighlightText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(initialMoney))); |
||
77 | |||
78 | -- Money Fluctuation Text |
||
79 | local fluctMoneyRichText; |
||
80 | local fluctMoneyPerHourRichText; |
||
81 | if (fluctMoney < 0) then |
||
82 | fluctMoneyRichText = TITAN_MONEY_TOOLTIP_LOST.."\t".. |
||
83 | TitanUtils_GetRedText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(0 - fluctMoney))); |
||
84 | fluctMoneyPerHourRichText = TITAN_MONEY_TOOLTIP_LOST_HOUR.."\t".. |
||
85 | TitanUtils_GetRedText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(0 - fluctMoneyPerHour))); |
||
86 | elseif (fluctMoney == 0) then |
||
87 | fluctMoneyRichText = TITAN_MONEY_TOOLTIP_EARNED.."\t".. |
||
88 | TitanUtils_GetHighlightText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(0))); |
||
89 | fluctMoneyPerHourRichText = TITAN_MONEY_TOOLTIP_EARNED_HOUR.."\t".. |
||
90 | TitanUtils_GetHighlightText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(0))); |
||
91 | else |
||
92 | fluctMoneyRichText = TITAN_MONEY_TOOLTIP_EARNED.."\t".. |
||
93 | TitanUtils_GetGreenText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(fluctMoney))); |
||
94 | fluctMoneyPerHourRichText = TITAN_MONEY_TOOLTIP_EARNED_HOUR.."\t".. |
||
95 | TitanUtils_GetGreenText(format(TITAN_MONEY_FORMAT, TitanPanelMoneyButton_BreakMoney(fluctMoneyPerHour))); |
||
96 | end |
||
97 | |||
98 | return "".. |
||
99 | currentMoneyRichText.."\n".. |
||
100 | initialMoneyRichText.."\n".. |
||
101 | fluctMoneyRichText.."\n".. |
||
102 | fluctMoneyPerHourRichText.."\n".. |
||
103 | TitanUtils_GetGreenText(TITAN_MONEY_TOOLTIP_HINTS); |
||
104 | end |
||
105 | |||
106 | function TitanPanelRightClickMenu_PrepareMoneyMenu() |
||
107 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_MONEY_ID].menuText); |
||
108 | TitanPanelRightClickMenu_AddCommand(TITAN_MONEY_MENU_RESET_SESSION, TITAN_MONEY_ID, "TitanPanelMoneyButton_ResetSession"); |
||
109 | TitanPanelRightClickMenu_AddSpacer(); |
||
110 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_MONEY_ID, TITAN_PANEL_MENU_FUNC_HIDE); |
||
111 | end |
||
112 | |||
113 | function TitanPanelMoneyButton_ResetSession() |
||
114 | startMoney = GetMoney(); |
||
115 | startSessionTime = TitanUtils_GetSessionTime(); |
||
116 | end |
||
117 | |||
118 | function TitanPanelMoneyButton_GetMoneyPerHour(money, session) |
||
119 | if (money and session and session > 0) then |
||
120 | return money / session * 3600; |
||
121 | end |
||
122 | end |
||
123 | |||
124 | function TitanPanelMoneyButton_BreakMoney(money) |
||
125 | -- Non-negative money only |
||
126 | if (money >= 0) then |
||
127 | local gold = floor(money / (COPPER_PER_SILVER * SILVER_PER_GOLD)); |
||
128 | local silver = floor((money - (gold * COPPER_PER_SILVER * SILVER_PER_GOLD)) / COPPER_PER_SILVER); |
||
129 | local copper = mod(money, COPPER_PER_SILVER); |
||
130 | return gold, silver, copper; |
||
131 | end |
||
132 | end |
||
133 | |||
134 | function Titan_OpenCoinPickupFrame(multiplier, maxMoney, parent) |
||
135 | if ( CoinPickupFrame.owner ) then |
||
136 | CoinPickupFrame.owner.hasPickup = 0; |
||
137 | end |
||
138 | |||
139 | if ( GetCursorMoney() > 0 ) then |
||
140 | if ( CoinPickupFrame.owner ) then |
||
141 | MoneyTypeInfo[parent.moneyType].DropFunc(); |
||
142 | PlaySound("igBackPackCoinSelect"); |
||
143 | end |
||
144 | CoinPickupFrame:Hide(); |
||
145 | return; |
||
146 | end |
||
147 | |||
148 | CoinPickupFrame.multiplier = multiplier; |
||
149 | CoinPickupFrame.maxMoney = floor(maxMoney / multiplier); |
||
150 | if ( CoinPickupFrame.maxMoney == 0 ) then |
||
151 | CoinPickupFrame:Hide(); |
||
152 | return; |
||
153 | end |
||
154 | |||
155 | CoinPickupFrame.owner = parent; |
||
156 | CoinPickupFrame.money = 1; |
||
157 | CoinPickupFrame.typing = 0; |
||
158 | CoinPickupText:SetText(CoinPickupFrame.money); |
||
159 | CoinPickupLeftButton:Disable(); |
||
160 | CoinPickupRightButton:Enable(); |
||
161 | |||
162 | if ( multiplier == 1 ) then |
||
163 | CoinPickupCopperIcon:Show(); |
||
164 | else |
||
165 | CoinPickupCopperIcon:Hide(); |
||
166 | end |
||
167 | |||
168 | if ( multiplier == COPPER_PER_SILVER ) then |
||
169 | CoinPickupSilverIcon:Show(); |
||
170 | else |
||
171 | CoinPickupSilverIcon:Hide(); |
||
172 | end |
||
173 | |||
174 | if ( multiplier == (COPPER_PER_GOLD) ) then |
||
175 | CoinPickupGoldIcon:Show(); |
||
176 | else |
||
177 | CoinPickupGoldIcon:Hide(); |
||
178 | end |
||
179 | |||
180 | position = TitanUtils_GetRealPosition(TITAN_MONEY_ID); |
||
181 | |||
182 | |||
183 | local scale = TitanPanelGetVar("Scale"); |
||
184 | if scale == nil then scale = 1; end |
||
185 | |||
186 | if (parent:GetName() == "TitanPanelMoneyButton") then |
||
187 | if (position == TITAN_PANEL_PLACE_TOP) then |
||
188 | CoinPickupFrame:ClearAllPoints(); |
||
189 | CoinPickupFrame:SetPoint("TOPLEFT", parent:GetName(), "BOTTOMLEFT", -10, -4 * scale); |
||
190 | else |
||
191 | CoinPickupFrame:ClearAllPoints(); |
||
192 | CoinPickupFrame:SetPoint("BOTTOMLEFT", parent:GetName(), "TOPLEFT", -10, 0); |
||
193 | end |
||
194 | else |
||
195 | CoinPickupFrame:ClearAllPoints(); |
||
196 | CoinPickupFrame:SetPoint("BOTTOMRIGHT", parent:GetName(), "TOPRIGHT", 0, 0); |
||
197 | if (position == TITAN_PANEL_PLACE_TOP) then |
||
198 | CoinPickupFrame:ClearAllPoints(); |
||
199 | CoinPickupFrame:SetPoint("TOPLEFT", parent:GetName(), "BOTTOMLEFT", -10, -4 * scale); |
||
200 | else |
||
201 | CoinPickupFrame:ClearAllPoints(); |
||
202 | CoinPickupFrame:SetPoint("BOTTOMLEFT", parent:GetName(), "TOPLEFT", -10, 0); |
||
203 | end |
||
204 | end |
||
205 | CoinPickupFrame:Show(); |
||
206 | PlaySound("igBackPackCoinSelect"); |
||
207 | end |