vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | TITAN_BRL_ID = "BRL"; |
2 | PLUGIN_POSITION = 0; |
||
3 | BRL_PLAYER_INFO = ""; |
||
4 | --TITAN_BRL_ICON_PATH = "Interface\\Icons\\Ability_Hunter_Pathfinding"; |
||
5 | --TITAN_BRL_ICON_PATH = "Interface\\Icons\\INV_Misc_TheGoldenCheep"; |
||
6 | --TITAN_BRL_ICON_PATH = "Interface\\Icons\\Spell_Arcane_TeleportDarnassus"; |
||
7 | --TITAN_BRL_ICON_PATH = "Interface\\Buttons\\UI-MicroButton-World-Up"; |
||
8 | TITAN_BRL_ICON_PATH = "Interface\\Addons\\BMRecLevel\\BRL_Icon"; |
||
9 | |||
10 | function TitanPanelBRLButton_OnLoad() |
||
11 | this.registry = { |
||
12 | id = TITAN_BRL_ID, |
||
13 | menuText = BMRECLEVEL_TITLE, |
||
14 | buttonTextFunction = "TitanPanelBRLButton_GetButtonText", |
||
15 | tooltipTitle = BRL_TOOPTIP_TITLE, |
||
16 | --tooltipTextFunction = "TitanPanelBRLButton_GetTooltipText", |
||
17 | icon = TITAN_BRL_ICON_PATH, |
||
18 | iconWidth = 12, |
||
19 | savedVariables = { |
||
20 | ShowLabelText = 1, -- Default to 1 |
||
21 | ShowIcon = 1; |
||
22 | } |
||
23 | }; |
||
24 | |||
25 | this:RegisterEvent("VARIABLES_LOADED"); |
||
26 | --this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
27 | this:RegisterEvent("MINIMAP_ZONE_CHANGED"); |
||
28 | this:RegisterEvent("ZONE_CHANGED_NEW_AREA"); |
||
29 | this:RegisterEvent("PLAYER_LEVEL_UP"); |
||
30 | end |
||
31 | |||
32 | function TitanPanelBRLButton_OnEvent() |
||
33 | if (event == "VARIABLES_LOADED") then |
||
34 | TitanPanelButtonBRL_SetIcon(); |
||
35 | end |
||
36 | --[[ |
||
37 | if (event == "PLAYER_ENTERING_WORLD") then |
||
38 | BRL_PLAYER_INFO = UnitName("player") .. "@" .. GetCVar("realmName"); |
||
39 | end]] |
||
40 | TitanPanelButton_UpdateButton(TITAN_BRL_ID); |
||
41 | end |
||
42 | |||
43 | function TitanPanelBRLButton_GetButtonText(id) |
||
44 | if (TitanGetVar(TITAN_BRL_ID, "ShowLabelText")) then |
||
45 | local zonetext, levelrangetext = BMRecLevel_Update_Text(); |
||
46 | return TitanUtils_GetNormalText(zonetext), levelrangetext; |
||
47 | else |
||
48 | local __, levelrangetext = BMRecLevel_Update_Text(); |
||
49 | return levelrangetext; |
||
50 | end |
||
51 | end |
||
52 | |||
53 | function TitanPanelBRLButton_GetTooltipText() |
||
54 | return BM_REC_LEVEL_TOOLTIP_TEXT; |
||
55 | end |
||
56 | |||
57 | function TitanPanelRightClickMenu_PrepareBRLMenu() |
||
58 | local info; |
||
59 | |||
60 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_BRL_ID].menuText); |
||
61 | |||
62 | info = {}; |
||
63 | info.text = BRL_SHOW_ZONE; |
||
64 | info.func = TitanPanelBRLButton_ToggleZone; |
||
65 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_zone; |
||
66 | UIDropDownMenu_AddButton(info); |
||
67 | |||
68 | info = {}; |
||
69 | info.text = BRL_SHOW_TOOLTIP_FACTION; |
||
70 | info.func = TitanPanelBRLButton_ToggleFaction; |
||
71 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_faction; |
||
72 | UIDropDownMenu_AddButton(info); |
||
73 | |||
74 | info = {}; |
||
75 | info.text = BRL_SHOW_TOOLTIP_INSTANCE; |
||
76 | info.func = TitanPanelBRLButton_ToggleInstance; |
||
77 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_instance; |
||
78 | UIDropDownMenu_AddButton(info); |
||
79 | |||
80 | info = {}; |
||
81 | info.text = BRL_SHOW_TOOLTIP_CONTINENT; |
||
82 | info.func = TitanPanelBRLButton_ToggleContinent; |
||
83 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_continent; |
||
84 | UIDropDownMenu_AddButton(info); |
||
85 | |||
86 | TitanPanelRightClickMenu_AddSpacer(); |
||
87 | |||
88 | info = {}; |
||
89 | info.text = BRL_MOVABLE_FRAME_ENABLE; |
||
90 | info.func = TitanPanelBRLButton_ToggleMoveableFrame; |
||
91 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_moveable_frame; |
||
92 | UIDropDownMenu_AddButton(info); |
||
93 | |||
94 | info = {}; |
||
95 | info.text = BRL_MAP_TEXT_ENABLE; |
||
96 | info.func = TitanPanelBRLButton_ToggleMapText; |
||
97 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].map_text_enable; |
||
98 | UIDropDownMenu_AddButton(info); |
||
99 | |||
100 | TitanPanelRightClickMenu_AddSpacer(); |
||
101 | |||
102 | info = {}; |
||
103 | info.text = BRL_SHOW_REC_INSTANCE; |
||
104 | info.func = TitanPanelBRLButton_ToggleRecInstances; |
||
105 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_instances; |
||
106 | UIDropDownMenu_AddButton(info); |
||
107 | |||
108 | info = {}; |
||
109 | info.text = BRL_SHOW_REC_BATTLEGROUNDS; |
||
110 | info.func = TitanPanelBRLButton_ToggleRecBattlegrounds; |
||
111 | info.checked = BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_battlegrounds; |
||
112 | UIDropDownMenu_AddButton(info); |
||
113 | |||
114 | TitanPanelRightClickMenu_AddSpacer(); |
||
115 | TitanPanelRightClickMenu_AddToggleLabelText(TITAN_BRL_ID); |
||
116 | TitanPanelRightClickMenu_AddToggleIcon(TITAN_BRL_ID); |
||
117 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_BRL_ID, TITAN_PANEL_MENU_FUNC_HIDE); |
||
118 | end |
||
119 | |||
120 | function TitanPanelBRLButton_ToggleZone() |
||
121 | BRL_Show_Zone(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_zone); |
||
122 | TitanPanelButton_UpdateButton(TITAN_BRL_ID); |
||
123 | end |
||
124 | |||
125 | function TitanPanelBRLButton_ToggleMoveableFrame() |
||
126 | BRL_Show_Moveable_Frame(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_moveable_frame); |
||
127 | TitanPanelButton_UpdateButton(TITAN_BRL_ID); |
||
128 | end |
||
129 | |||
130 | function TitanPanelBRLButton_ToggleInstance() |
||
131 | BRL_Show_Tooltip_Instance(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_instance); |
||
132 | TitanPanelButton_UpdateButton(TITAN_BRL_ID); |
||
133 | end |
||
134 | |||
135 | function TitanPanelBRLButton_ToggleFaction() |
||
136 | BRL_Show_Tooltip_Faction(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_faction); |
||
137 | end |
||
138 | |||
139 | function TitanPanelBRLButton_ToggleRecInstances() |
||
140 | BRL_Toogle_RecInstances(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_instances); |
||
141 | end |
||
142 | |||
143 | function TitanPanelBRLButton_ToggleRecBattlegrounds() |
||
144 | BRL_Toogle_RecBattlegrounds(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_rec_battlegrounds); |
||
145 | end |
||
146 | |||
147 | function TitanPanelBRLButton_ToggleMapText() |
||
148 | BRL_Map_Text_Enable(not BRL_CONFIG[BM_PLAYERNAME_REALM].map_text_enable); |
||
149 | end |
||
150 | |||
151 | function TitanPanelBRLButton_ToggleContinent() |
||
152 | BRL_Show_Tooltip_Continent(not BRL_CONFIG[BM_PLAYERNAME_REALM].show_tooltip_continent); |
||
153 | end |
||
154 | |||
155 | function TitanPanelButtonBRL_SetIcon() |
||
156 | local icon1 = TitanPanelBRLButtonIcon; |
||
157 | if (TitanGetVar(TITAN_BRL_ID, "ShowIcon")) then |
||
158 | icon1:SetTexture(TITAN_BRL_ICON_PATH); |
||
159 | icon1:SetWidth(TitanPlugins[TITAN_BRL_ID].iconWidth); |
||
160 | --icon1:SetHeight(BAG_STATUS_ICON_SIZE); |
||
161 | else |
||
162 | icon1:SetTexture(""); |
||
163 | icon1:SetWidth(1); |
||
164 | end |
||
165 | end |
||
166 | |||
167 | |||
168 | --This function is in every plugin always the same except for the 2 varables |
||
169 | function TitanBRLButton_OnEnter() |
||
170 | --[[ |
||
171 | local brl_tooltip_anchor = ""; |
||
172 | local brl_tooltip_relpoint = ""; |
||
173 | local plugin_position = 0; |
||
174 | for key, value in TitanSettings["Players"][BRL_PLAYER_INFO]["Panel"]["Buttons"] do |
||
175 | plugin_position = plugin_position + 1; |
||
176 | if (value == TITAN_BRL_ID) then |
||
177 | break; |
||
178 | end |
||
179 | end |
||
180 | if (TitanSettings["Players"][BRL_PLAYER_INFO]["Panel"]["Location"][plugin_position] == "Bar") then |
||
181 | brl_tooltip_anchor = "TOP"; |
||
182 | brl_tooltip_relpoint = "BOTTOM"; |
||
183 | else |
||
184 | brl_tooltip_anchor = "BOTTOM"; |
||
185 | brl_tooltip_relpoint = "TOP"; |
||
186 | end |
||
187 | ]] |
||
188 | GameTooltip:SetOwner(this, "ANCHOR_NONE"); |
||
189 | GameTooltip:SetPoint(BRL_PositonToolTip_Anchor() .. BRL_PositonToolTip_RightLeft(), this, BRL_PositonToolTip_Relpoint() .. BRL_PositonToolTip_RightLeft(), 0, 0); |
||
190 | -- set the tool tip text |
||
191 | --only these two lines will change everything else is the same for all plugins |
||
192 | GameTooltip:SetText(TitanUtils_GetGreenText(BRL_TOOPTIP_TITLE)); -- Usually found in localization file TITAN_COMBATINFO_TOOLTIP="Combat Info" |
||
193 | GameTooltip:AddLine(BM_REC_LEVEL_TOOLTIP_TEXT); |
||
194 | --BM_Tooltip_AddTooltipText(BM_REC_LEVEL_TOOLTIP_TEXT); --The variable created by the GetTooltipText() function |
||
195 | GameTooltip:Show(); |
||
196 | end |
||
197 | |||
198 | --This function is in every plugin always the same |
||
199 | function TitanBRLButton_OnLeave() |
||
200 | -- put the tool tip in the default position |
||
201 | GameTooltip_SetDefaultAnchor(GameTooltip, UIParent); |
||
202 | GameTooltip:Hide(); |
||
203 | end |
||
204 | |||
205 | function BRL_PositonToolTip_RightLeft() |
||
206 | local tooltipleftright |
||
207 | local ui_parent_scale = UIParent:GetScale(); |
||
208 | local ui_parent_width = UIParent:GetWidth()/ui_parent_scale; |
||
209 | if (this:GetRight() >= (ui_parent_width/2)) then |
||
210 | tooltipleftright = "RIGHT"; |
||
211 | else |
||
212 | tooltipleftright = "LEFT"; |
||
213 | end |
||
214 | return tooltipleftright; |
||
215 | end |
||
216 | |||
217 | function BRL_PositonToolTip_Anchor() |
||
218 | local tooltipanchor; |
||
219 | local ui_parent_scale = UIParent:GetScale(); |
||
220 | local ui_parent_height = UIParent:GetHeight()/ui_parent_scale; |
||
221 | if (this:GetTop() >= (ui_parent_height/2)) then |
||
222 | tooltipanchor = "TOP"; |
||
223 | else |
||
224 | tooltipanchor = "BOTTOM"; |
||
225 | end |
||
226 | return tooltipanchor; |
||
227 | end |
||
228 | |||
229 | function BRL_PositonToolTip_Relpoint() |
||
230 | local tooltiprelpoint; |
||
231 | local ui_parent_scale = UIParent:GetScale(); |
||
232 | local ui_parent_height = UIParent:GetHeight()/ui_parent_scale; |
||
233 | if (this:GetTop() >= (ui_parent_height/2)) then |
||
234 | tooltiprelpoint = "BOTTOM"; |
||
235 | else |
||
236 | tooltiprelpoint = "TOP"; |
||
237 | end |
||
238 | return tooltiprelpoint; |
||
239 | end |