vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | TITAN_AMMO_ID = "Ammo"; |
2 | TITAN_AMMO_THRESHOLD_TABLE = { |
||
3 | Values = { 150, 400 }, |
||
4 | Colors = { RED_FONT_COLOR, NORMAL_FONT_COLOR, GREEN_FONT_COLOR }, |
||
5 | } |
||
6 | |||
7 | function TitanPanelAmmoButton_OnLoad() |
||
8 | this.registry = { |
||
9 | id = TITAN_AMMO_ID, |
||
10 | builtIn = 1, |
||
11 | version = TITAN_VERSION, |
||
12 | menuText = TITAN_AMMO_MENU_TEXT, |
||
13 | buttonTextFunction = "TitanPanelAmmoButton_GetButtonText", |
||
14 | tooltipTitle = TITAN_AMMO_TOOLTIP, |
||
15 | icon = TITAN_ARTWORK_PATH.."TitanThrown", |
||
16 | iconWidth = 16, |
||
17 | savedVariables = { |
||
18 | ShowIcon = 1, |
||
19 | ShowLabelText = 1, |
||
20 | ShowColoredText = 1, |
||
21 | } |
||
22 | }; |
||
23 | |||
24 | this:RegisterEvent("PLAYER_LEAVING_WORLD"); |
||
25 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
26 | end |
||
27 | |||
28 | function TitanPanelAmmoButton_OnEvent() |
||
29 | if (event == "PLAYER_LEAVING_WORLD") then |
||
30 | this:UnregisterEvent("BAG_UPDATE"); |
||
31 | this:UnregisterEvent("ITEM_LOCK_CHANGED"); |
||
32 | this:UnregisterEvent("UNIT_INVENTORY_CHANGED"); |
||
33 | end |
||
34 | |||
35 | if (event == "PLAYER_ENTERING_WORLD") then |
||
36 | this:RegisterEvent("BAG_UPDATE"); |
||
37 | this:RegisterEvent("ITEM_LOCK_CHANGED"); |
||
38 | this:RegisterEvent("UNIT_INVENTORY_CHANGED"); |
||
39 | end |
||
40 | |||
41 | TitanPanelButton_UpdateButton(TITAN_AMMO_ID); |
||
42 | end |
||
43 | |||
44 | function TitanPanelAmmoButton_GetButtonText(id) |
||
45 | local ammoSlotID = GetInventorySlotInfo("ammoSlot"); |
||
46 | local rangedSlotID = GetInventorySlotInfo("rangedSlot"); |
||
47 | |||
48 | local isThrown, isAmmo; |
||
49 | if (GetInventoryItemQuality("player", rangedSlotID) and |
||
50 | string.find(GetInventoryItemLink("player", rangedSlotID), TITAN_AMMO_THROWN_KEYWORD)) then |
||
51 | isThrown = 1; |
||
52 | end |
||
53 | if (not isThrown and GetInventoryItemQuality("player", ammoSlotID)) then |
||
54 | isAmmo = 1; |
||
55 | end |
||
56 | |||
57 | local count, labelText, ammoText, ammoRichText, color; |
||
58 | if (isThrown) then |
||
59 | count = GetInventoryItemCount("player", rangedSlotID); |
||
60 | labelText = TITAN_AMMO_BUTTON_LABEL_THROWN; |
||
61 | ammoText = format(TITAN_AMMO_FORMAT, count); |
||
62 | elseif (isAmmo) then |
||
63 | count = GetInventoryItemCount("player", ammoSlotID); |
||
64 | labelText = TITAN_AMMO_BUTTON_LABEL_AMMO; |
||
65 | ammoText = format(TITAN_AMMO_FORMAT, count); |
||
66 | else |
||
67 | count = 0; |
||
68 | labelText = TITAN_AMMO_BUTTON_LABEL_AMMO_THROWN; |
||
69 | ammoText = format(TITAN_AMMO_FORMAT, count); |
||
70 | end |
||
71 | |||
72 | if ( TitanGetVar(TITAN_AMMO_ID, "ShowColoredText") ) then |
||
73 | color = TitanUtils_GetThresholdColor(TITAN_AMMO_THRESHOLD_TABLE, count); |
||
74 | ammoRichText = TitanUtils_GetColoredText(ammoText, color); |
||
75 | else |
||
76 | ammoRichText = TitanUtils_GetHighlightText(ammoText); |
||
77 | end |
||
78 | |||
79 | return labelText, ammoRichText; |
||
80 | end |
||
81 | |||
82 | function TitanPanelRightClickMenu_PrepareAmmoMenu() |
||
83 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_AMMO_ID].menuText); |
||
84 | TitanPanelRightClickMenu_AddToggleIcon(TITAN_AMMO_ID); |
||
85 | TitanPanelRightClickMenu_AddToggleLabelText(TITAN_AMMO_ID); |
||
86 | TitanPanelRightClickMenu_AddToggleColoredText(TITAN_AMMO_ID); |
||
87 | |||
88 | TitanPanelRightClickMenu_AddSpacer(); |
||
89 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_AMMO_ID, TITAN_PANEL_MENU_FUNC_HIDE); |
||
90 | end |
||
91 |