vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- TitanWardrobe 1.0 |
2 | |||
3 | local function TEXT(key) return Localization.GetString("Wardrobe", key) end |
||
4 | |||
5 | WARDROBE_TITAN_ID = "Wardrobe"; |
||
6 | |||
7 | function Wardrobe.TitanPanelButton_OnLoad() |
||
8 | |||
9 | if ( IsAddOnLoaded("Titan") ) then |
||
10 | -- register the plugin |
||
11 | this.registry = { |
||
12 | id = WARDROBE_TITAN_ID, |
||
13 | menuText = WARDROBE_TITAN_ID, |
||
14 | buttonTextFunction = "Wardrobe_TitanPanelButton_GetButtonText", |
||
15 | --tooltipTitle = TEXT("TITAN_BUTTON_TEXT"), |
||
16 | --tooltipTextFunction = "Wardrobe_TitanPanelButton_GetTooltipText", |
||
17 | icon = "Interface\\AddOns\\Wardrobe\\Images\\WardrobeTitan", |
||
18 | iconWidth = 16, |
||
19 | savedVariables = { |
||
20 | ShowMinimapIcon = 1, |
||
21 | ShowIcon = 1, |
||
22 | ShowLabelText = TITAN_NIL, |
||
23 | } |
||
24 | }; |
||
25 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
26 | if (Chronos) then |
||
27 | this:RegisterEvent("UNIT_INVENTORY_CHANGED"); |
||
28 | else |
||
29 | this.registry.frequency = 1; |
||
30 | end |
||
31 | |||
32 | TitanPanelButton_OnLoad(); |
||
33 | end |
||
34 | end |
||
35 | |||
36 | function Wardrobe.TitanPanelButton_OnEvent(event) |
||
37 | if (event == "UNIT_INVENTORY_CHANGED") then |
||
38 | Chronos.scheduleByName("WardrobeTitanUpdate", .2, function() TitanPanelButton_UpdateButton(WARDROBE_TITAN_ID) end); |
||
39 | elseif (event == "PLAYER_ENTERING_WORLD") then |
||
40 | Wardrobe.enteredWorld = true; |
||
41 | Wardrobe.CheckForOurWardrobeID(); |
||
42 | Wardrobe.TitanUpdateMinimapStatus(); |
||
43 | end |
||
44 | end |
||
45 | |||
46 | function Wardrobe.TitanPanelButton_GetButtonText(id) |
||
47 | |||
48 | local labelText = nil; |
||
49 | |||
50 | -- display the label if the user has selected |
||
51 | if (TitanGetVar(WARDROBE_TITAN_ID, "ShowLabelText")) then |
||
52 | labelText = TEXT("TITAN_BUTTON_TEXT"); |
||
53 | end |
||
54 | |||
55 | -- get any active outfits |
||
56 | local outfitText = Wardrobe.GetActiveOutfitsTextList(); |
||
57 | |||
58 | -- show / hide the minimap icon |
||
59 | if (Wardrobe.enteredWorld) then |
||
60 | Wardrobe.TitanUpdateMinimapStatus(); |
||
61 | end |
||
62 | |||
63 | return labelText, outfitText; |
||
64 | end |
||
65 | Wardrobe_TitanPanelButton_GetButtonText = Wardrobe.TitanPanelButton_GetButtonText; |
||
66 | |||
67 | function Wardrobe.TitanUpdateMinimapStatus(elseShow) |
||
68 | if (TitanGetVar) then |
||
69 | if (TitanGetVar(WARDROBE_TITAN_ID, "ShowMinimapIcon")) then |
||
70 | Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible = 1; |
||
71 | Wardrobe.IconFrame:Show(); |
||
72 | else |
||
73 | Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible = 0; |
||
74 | Wardrobe.IconFrame:Hide(); |
||
75 | end |
||
76 | else |
||
77 | if (elseShow) then |
||
78 | Wardrobe.IconFrame:Show(); |
||
79 | else |
||
80 | Wardrobe.IconFrame:Hide(); |
||
81 | end |
||
82 | end |
||
83 | end |
||
84 | |||
85 | function Wardrobe.TitanPanelButton_GetTooltipText() |
||
86 | return TEXT("TITAN_TOOLTIP_TEXT"); |
||
87 | end |
||
88 | Wardrobe_TitanPanelButton_GetTooltipText = Wardrobe.TitanPanelButton_GetTooltipText; |
||
89 | |||
90 | function TitanPanelRightClickMenu_PrepareWardrobeMenu() |
||
91 | |||
92 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[WARDROBE_TITAN_ID].menuText); |
||
93 | |||
94 | -- show the "hide minimap icon" |
||
95 | TitanPanelRightClickMenu_AddToggleVar(TEXT("TITAN_MENU_SHOW_MINIMAP_ICON"), WARDROBE_TITAN_ID, "ShowMinimapIcon"); |
||
96 | |||
97 | TitanPanelRightClickMenu_AddSpacer(); |
||
98 | |||
99 | TitanPanelRightClickMenu_AddToggleIcon(WARDROBE_TITAN_ID); |
||
100 | TitanPanelRightClickMenu_AddToggleLabelText(WARDROBE_TITAN_ID); |
||
101 | |||
102 | TitanPanelRightClickMenu_AddSpacer(); |
||
103 | |||
104 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, WARDROBE_TITAN_ID, TITAN_PANEL_MENU_FUNC_HIDE); |
||
105 | end |
||
106 | |||
107 | function Wardrobe.TitanPanelButton_OnClick(button) |
||
108 | -- show the wardrobe menu on left clicks, options on right clicks |
||
109 | if ( button == "LeftButton" ) then |
||
110 | local position = TitanUtils_GetRealPosition(WARDROBE_TITAN_ID); |
||
111 | --local horizOffset = -( DropDownList1:GetWidth()-TitanPanelWardrobeButton:GetWidth() )/2; |
||
112 | if (position == TITAN_PANEL_PLACE_TOP) then |
||
113 | ToggleDropDownMenu(1, nil, WardrobeDropDown, "TitanPanelWardrobeButton", -15, 0, "TOPLEFT"); |
||
114 | else |
||
115 | ToggleDropDownMenu(1, nil, WardrobeDropDown, "TitanPanelWardrobeButton", -15, 0, "BOTTOMLEFT"); |
||
116 | end |
||
117 | else |
||
118 | TitanPanelButton_OnClick(button, 1); |
||
119 | end |
||
120 | end |
||
121 | |||
122 | function Wardrobe.TitanPanelButton_OnEnter() |
||
123 | if (Wardrobe_Config.MustClickUIButton) then |
||
124 | TitanPanelButton_OnEnter(); |
||
125 | else |
||
126 | if (not DropDownList1:IsVisible()) then |
||
127 | Wardrobe.TitanPanelButton_OnClick("LeftButton"); |
||
128 | end |
||
129 | end |
||
130 | end |
||
131 |