vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | BIB_BRL_ID = "BRL"; |
2 | BIB_BRL_ICON_PATH = "Interface\\Addons\\BMRecLevel\\BRL_Icon"; |
||
3 | BIB_BRL_ICON_SIZE = 12; |
||
4 | |||
5 | function BIB_BRLButton_OnLoad() |
||
6 | this:RegisterEvent("VARIABLES_LOADED"); |
||
7 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
8 | this:RegisterEvent("MINIMAP_ZONE_CHANGED"); |
||
9 | this:RegisterEvent("ZONE_CHANGED_NEW_AREA"); |
||
10 | this:RegisterEvent("PLAYER_LEVEL_UP"); |
||
11 | |||
12 | PLUG_IN_FRAME = "BIB_BRLButton"; |
||
13 | PLUG_IN_NAME = "Recommended Level"; |
||
14 | BM_ICON_SIZE = BIB_BRL_ICON_SIZE; |
||
15 | BM_Plugin(PLUG_IN_FRAME, PLUG_IN_NAME,BM_ICON_SIZE, BIB_BRL_ID); |
||
16 | end |
||
17 | |||
18 | function BIB_BRLButton_OnEvent() |
||
19 | if (event == "VARIABLES_LOADED") then |
||
20 | BIB_BRLButton_Initialize(); |
||
21 | --TitanPanelButtonBRL_SetIcon(); |
||
22 | end |
||
23 | if (event == "MINIMAP_ZONE_CHANGED" or event == "ZONE_CHANGED_NEW_AREA" or event == "PLAYER_LEVEL_UP") then |
||
24 | BIB_BRLButton_GetButtonText(); |
||
25 | end |
||
26 | end |
||
27 | |||
28 | function BIB_BRLButton_GetButtonText() |
||
29 | if (BM_REC_LEVEL_BUTTON_TEXT ~= nil) then |
||
30 | if (TitanGetVar(BIB_BRL_ID, "ShowLabelText")) then |
||
31 | local zonetext, levelrangetext = BMRecLevel_Update_Text(); |
||
32 | BIB_BRLButtonText:SetText(zonetext .. ": " .. levelrangetext); |
||
33 | else |
||
34 | local __, levelrangetext = BMRecLevel_Update_Text(); |
||
35 | BIB_BRLButtonText:SetText(levelrangetext); |
||
36 | end |
||
37 | end |
||
38 | end |
||
39 | |||
40 | function BIB_BRLButton_GetTooltipText() |
||
41 | return BM_REC_LEVEL_TOOLTIP_TEXT; |
||
42 | end |
||
43 | |||
44 | function BIB_RightClickMenu_PrepareBRLMenu() |
||
45 | local info; |
||
46 | |||
47 | TitanPanelRightClickMenu_AddTitle(BMRECLEVEL_TITLE); |
||
48 | |||
49 | info = {}; |
||
50 | info.text = BRL_SHOW_ZONE; |
||
51 | info.func = BIB_BRLButton_ToggleZone; |
||
52 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_zone; |
||
53 | UIDropDownMenu_AddButton(info); |
||
54 | |||
55 | info = {}; |
||
56 | info.text = BRL_SHOW_TOOLTIP_FACTION; |
||
57 | info.func = BIB_BRLButton_ToggleFaction; |
||
58 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_faction; |
||
59 | UIDropDownMenu_AddButton(info); |
||
60 | |||
61 | info = {}; |
||
62 | info.text = BRL_SHOW_TOOLTIP_INSTANCE; |
||
63 | info.func = BIB_BRLButton_ToggleInstance; |
||
64 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_instance; |
||
65 | UIDropDownMenu_AddButton(info); |
||
66 | |||
67 | info = {}; |
||
68 | info.text = BRL_SHOW_TOOLTIP_CONTINENT; |
||
69 | info.func = BIB_BRLButton_ToggleContinent; |
||
70 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_continent; |
||
71 | UIDropDownMenu_AddButton(info); |
||
72 | |||
73 | TitanPanelRightClickMenu_AddSpacer(); |
||
74 | |||
75 | info = {}; |
||
76 | info.text = BRL_MOVABLE_FRAME_ENABLE; |
||
77 | info.func = BIB_BRLButton_ToggleMoveableFrame; |
||
78 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_moveable_frame; |
||
79 | UIDropDownMenu_AddButton(info); |
||
80 | |||
81 | info = {}; |
||
82 | info.text = BRL_MAP_TEXT_ENABLE; |
||
83 | info.func = BIB_BRLButton_ToggleMapText; |
||
84 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].map_text_enable; |
||
85 | UIDropDownMenu_AddButton(info); |
||
86 | |||
87 | TitanPanelRightClickMenu_AddSpacer(); |
||
88 | |||
89 | info = {}; |
||
90 | info.text = BRL_SHOW_REC_INSTANCE; |
||
91 | info.func = BIB_BRLButton_ToggleRecInstances; |
||
92 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_instances; |
||
93 | UIDropDownMenu_AddButton(info); |
||
94 | |||
95 | info = {}; |
||
96 | info.text = BRL_SHOW_REC_BATTLEGROUNDS; |
||
97 | info.func = BIB_BRLButton_ToggleRecBattlegrounds; |
||
98 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_battlegrounds; |
||
99 | UIDropDownMenu_AddButton(info); |
||
100 | |||
101 | TitanPanelRightClickMenu_AddSpacer(); |
||
102 | |||
103 | TitanPanelRightClickMenu_AddToggleLabelText(BIB_BRL_ID); |
||
104 | |||
105 | info = {}; |
||
106 | info.text = BM_SHOW_ICON; |
||
107 | info.func = BIB_BRLButton_ToggleIcon; |
||
108 | info.checked = TitanGetVar(BIB_BRL_ID, "ShowIcon"); |
||
109 | UIDropDownMenu_AddButton(info); |
||
110 | end |
||
111 | |||
112 | function BIB_BRLButton_ToggleZone() |
||
113 | BRL_Show_Zone(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_zone); |
||
114 | BIB_BRLButton_GetButtonText(); |
||
115 | BIB_BRLButton_GetTooltipText(); |
||
116 | end |
||
117 | |||
118 | function BIB_BRLButton_ToggleMoveableFrame() |
||
119 | BRL_Show_Moveable_Frame(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_moveable_frame); |
||
120 | BIB_BRLButton_GetButtonText(); |
||
121 | BIB_BRLButton_GetTooltipText(); |
||
122 | end |
||
123 | |||
124 | function BIB_BRLButton_ToggleInstance() |
||
125 | BRL_Show_Tooltip_Instance(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_instance); |
||
126 | BIB_BRLButton_GetButtonText(); |
||
127 | BIB_BRLButton_GetTooltipText(); |
||
128 | end |
||
129 | |||
130 | function BIB_BRLButton_ToggleFaction() |
||
131 | BRL_Show_Tooltip_Faction(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_faction); |
||
132 | BIB_BRLButton_GetButtonText(); |
||
133 | BIB_BRLButton_GetTooltipText(); |
||
134 | end |
||
135 | |||
136 | function BIB_BRLButton_ToggleRecInstances() |
||
137 | BRL_Toogle_RecInstances(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_instances); |
||
138 | BIB_BRLButton_GetButtonText(); |
||
139 | BIB_BRLButton_GetTooltipText(); |
||
140 | end |
||
141 | |||
142 | function BIB_BRLButton_ToggleRecBattlegrounds() |
||
143 | BRL_Toogle_RecBattlegrounds(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_battlegrounds); |
||
144 | BIB_BRLButton_GetButtonText(); |
||
145 | BIB_BRLButton_GetTooltipText(); |
||
146 | end |
||
147 | |||
148 | function BIB_BRLButton_ToggleContinent() |
||
149 | BRL_Show_Tooltip_Continent(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_continent); |
||
150 | BIB_BRLButton_GetButtonText(); |
||
151 | BIB_BRLButton_GetTooltipText(); |
||
152 | end |
||
153 | |||
154 | function BIB_BRLButton_ToggleMapText() |
||
155 | BRL_Map_Text_Enable(not BRL_CONFIG[BM_PLAYERNAME_REALM].map_text_enable); |
||
156 | end |
||
157 | |||
158 | function BIB_BRLButton_ToggleIcon() |
||
159 | TitanToggleVar(BIB_BRL_ID, "ShowIcon"); |
||
160 | BIB_BRLButton_SetIcon(); |
||
161 | end |
||
162 | |||
163 | |||
164 | function BIB_BRLButton_Initialize() |
||
165 | -- This is the list of the saved vars used, values can be true, false, number, text whatever you want to save. |
||
166 | savedVariables = { |
||
167 | [1] = {name = "ShowIcon", value = true}, |
||
168 | [2] = {name = "ShowLabelText", value = true}, |
||
169 | } |
||
170 | -- Function to Initialize the saved vars if they don't exisit create them if they do exisits SWEET!! |
||
171 | for key, value in savedVariables do |
||
172 | BM_Initialize_Variables(BIB_BRL_ID, value.name, value.value); |
||
173 | end |
||
174 | -- Creates the Dropdown menu |
||
175 | UIDropDownMenu_Initialize(BIB_BRLButtonRightClickMenu, BIB_RightClickMenu_PrepareBRLMenu, "Menu"); |
||
176 | -- Initialize the icon |
||
177 | BIB_BRLButton_SetIcon(); |
||
178 | end |
||
179 | |||
180 | --Sets the icon to where its suppose to be if no icon skips this function |
||
181 | function BIB_BRLButton_SetIcon() |
||
182 | local icon1 = BIB_BRLButtonIcon; |
||
183 | if (TitanGetVar(TITAN_BRL_ID, "ShowIcon")) then |
||
184 | icon1:SetTexture(BIB_BRL_ICON_PATH); |
||
185 | icon1:SetWidth(BIB_BRL_ICON_SIZE); |
||
186 | icon1:SetHeight(BIB_BRL_ICON_SIZE); |
||
187 | else |
||
188 | icon1:SetTexture(""); |
||
189 | icon1:SetWidth(1); |
||
190 | end |
||
191 | end |
||
192 | |||
193 | --This function is in every plugin always the same except for the 2 varables |
||
194 | function BIB_BRLButton_OnEnter() |
||
195 | GameTooltip:SetOwner(this, "ANCHOR_NONE"); |
||
196 | GameTooltip:SetPoint(BM_TOOLTIP_ANCHOR .. BM_PositonToolTip_RightLeft(), this, BM_TOOLTIP_RELPOINT .. BM_PositonToolTip_RightLeft(), 0, 0); |
||
197 | -- set the tool tip text |
||
198 | --only these two lines will change everything else is the same for all plugins |
||
199 | GameTooltip:SetText(TitanUtils_GetGreenText(BRL_TOOPTIP_TITLE)); -- Usually found in localization file TITAN_COMBATINFO_TOOLTIP="Combat Info" |
||
200 | GameTooltip:AddLine(BM_REC_LEVEL_TOOLTIP_TEXT); |
||
201 | --BM_Tooltip_AddTooltipText(BM_REC_LEVEL_TOOLTIP_TEXT); --The variable created by the GetTooltipText() function |
||
202 | GameTooltip:Show(); |
||
203 | end |
||
204 | |||
205 | --This function is in every plugin always the same |
||
206 | function BIB_BRLButton_OnLeave() |
||
207 | -- put the tool tip in the default position |
||
208 | GameTooltip_SetDefaultAnchor(GameTooltip, UIParent); |
||
209 | GameTooltip:Hide(); |
||
210 | end |
||
211 | |||
212 | --This function is in every plugin always the same |
||
213 | function BIB_BRLButton_OnRightClick(button) |
||
214 | if (button == "RightButton") then |
||
215 | ToggleDropDownMenu(1, nil, getglobal(this:GetName().."RightClickMenu"), this:GetName(), 0, 0); |
||
216 | GameTooltip_SetDefaultAnchor(GameTooltip, UIParent); |
||
217 | GameTooltip:Hide(); |
||
218 | end |
||
219 | end |