vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
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("BAG_UPDATE");
25 this:RegisterEvent("ITEM_LOCK_CHANGED");
26 this:RegisterEvent("UNIT_INVENTORY_CHANGED");
27 end
28  
29 function TitanPanelAmmoButton_OnEvent()
30 TitanPanelButton_UpdateButton(TITAN_AMMO_ID);
31 end
32  
33 function TitanPanelAmmoButton_GetButtonText(id)
34 local ammoSlotID = GetInventorySlotInfo("ammoSlot");
35 local rangedSlotID = GetInventorySlotInfo("rangedSlot");
36  
37 local isThrown, isAmmo;
38 if (GetInventoryItemQuality("player", rangedSlotID) and
39 string.find(GetInventoryItemLink("player", rangedSlotID), TITAN_AMMO_THROWN_KEYWORD)) then
40 isThrown = 1;
41 end
42 if (not isThrown and GetInventoryItemQuality("player", ammoSlotID)) then
43 isAmmo = 1;
44 end
45  
46 local count, labelText, ammoText, ammoRichText, color;
47 if (isThrown) then
48 count = GetInventoryItemCount("player", rangedSlotID);
49 labelText = TITAN_AMMO_BUTTON_LABEL_THROWN;
50 ammoText = format(TITAN_AMMO_FORMAT, count);
51 elseif (isAmmo) then
52 count = GetInventoryItemCount("player", ammoSlotID);
53 labelText = TITAN_AMMO_BUTTON_LABEL_AMMO;
54 ammoText = format(TITAN_AMMO_FORMAT, count);
55 else
56 count = 0;
57 labelText = TITAN_AMMO_BUTTON_LABEL_AMMO_THROWN;
58 ammoText = format(TITAN_AMMO_FORMAT, count);
59 end
60  
61 if ( TitanGetVar(TITAN_AMMO_ID, "ShowColoredText") ) then
62 color = TitanUtils_GetThresholdColor(TITAN_AMMO_THRESHOLD_TABLE, count);
63 ammoRichText = TitanUtils_GetColoredText(ammoText, color);
64 else
65 ammoRichText = TitanUtils_GetHighlightText(ammoText);
66 end
67  
68 return labelText, ammoRichText;
69 end
70  
71 function TitanPanelRightClickMenu_PrepareAmmoMenu()
72 TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_AMMO_ID].menuText);
73 TitanPanelRightClickMenu_AddToggleIcon(TITAN_AMMO_ID);
74 TitanPanelRightClickMenu_AddToggleLabelText(TITAN_AMMO_ID);
75 TitanPanelRightClickMenu_AddToggleColoredText(TITAN_AMMO_ID);
76  
77 TitanPanelRightClickMenu_AddSpacer();
78 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_AMMO_ID, TITAN_PANEL_MENU_FUNC_HIDE);
79 end
80