vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 TITAN_COORDS_ID = "Coords";
2 TITAN_COORDS_FREQUENCY = 0.5;
3  
4 function TitanPanelCoordsButton_OnLoad()
5 this.registry = {
6 id = TITAN_COORDS_ID,
7 builtIn = 1,
8 version = TITAN_VERSION,
9 menuText = TITAN_COORDS_MENU_TEXT,
10 buttonTextFunction = "TitanPanelCoordsButton_GetButtonText",
11 tooltipTitle = TITAN_COORDS_TOOLTIP,
12 tooltipTextFunction = "TitanPanelCoordsButton_GetTooltipText",
13 frequency = TITAN_COORDS_FREQUENCY,
14 updateType = TITAN_PANEL_UPDATE_BUTTON;
15 icon = TITAN_ARTWORK_PATH.."TitanCoords",
16 iconWidth = 16,
17 savedVariables = {
18 ShowZoneText = 1,
19 ShowCoordsOnMap = 1,
20 ShowIcon = 1,
21 ShowLabelText = 1,
22 ShowColoredText = 1,
23 }
24 };
25  
26 this:RegisterEvent("ZONE_CHANGED");
27 this:RegisterEvent("ZONE_CHANGED_INDOORS");
28 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
29 this:RegisterEvent("MINIMAP_ZONE_CHANGED");
30 this:RegisterEvent("PLAYER_ENTERING_WORLD");
31 end
32  
33 function TitanPanelCoordsButton_GetButtonText(id)
34 local button, id = TitanUtils_GetButton(id, true);
35  
36 button.px, button.py = GetPlayerMapPosition("player");
37 local locationText = format(TITAN_COORDS_FORMAT, 100 * button.px, 100 * button.py);
38 if (TitanGetVar(TITAN_COORDS_ID, "ShowZoneText")) then
39 if (TitanUtils_ToString(button.subZoneText) == '') then
40 locationText = TitanUtils_ToString(button.zoneText)..' '..locationText;
41 else
42 locationText = TitanUtils_ToString(button.subZoneText)..' '..locationText;
43 end
44 end
45  
46 local locationRichText;
47 if (TitanGetVar(TITAN_COORDS_ID, "ShowColoredText")) then
48 if (this.isArena) then
49 locationRichText = TitanUtils_GetRedText(locationText);
50 elseif (this.pvpType == "friendly") then
51 locationRichText = TitanUtils_GetGreenText(locationText);
52 elseif (this.pvpType == "hostile") then
53 locationRichText = TitanUtils_GetRedText(locationText);
54 elseif (this.pvpType == "contested") then
55 locationRichText = TitanUtils_GetNormalText(locationText);
56 else
57 locationRichText = TitanUtils_GetNormalText(locationText);
58 end
59 else
60 locationRichText = TitanUtils_GetHighlightText(locationText);
61 end
62  
63 return TITAN_COORDS_BUTTON_LABEL, locationRichText;
64 end
65  
66 function TitanPanelCoordsButton_GetTooltipText()
67 local pvpInfoRichText;
68  
69 if (this.pvpType == "friendly") then
70 pvpInfoRichText = TitanUtils_GetGreenText(format(FACTION_CONTROLLED_TERRITORY, this.factionName));
71 elseif (this.pvpType == "hostile") then
72 pvpInfoRichText = TitanUtils_GetRedText(format(FACTION_CONTROLLED_TERRITORY, this.factionName));
73 elseif (this.pvpType == "contested") then
74 pvpInfoRichText = TitanUtils_GetNormalText(CONTESTED_TERRITORY);
75 else
76 pvpInfoRichText = "";
77 end
78  
79 --[[
80 local pvpArenaText;
81 if (isArena) then
82 pvpArenaText = FREE_FOR_ALL_TERRITORY;
83 this.subZoneText = TitanUtils_GetRedText(this.subZoneText);
84 else
85 pvpArenaText = "";
86 end
87 ]]--
88  
89 return ""..
90 TITAN_COORDS_TOOLTIP_ZONE.."\t"..TitanUtils_GetHighlightText(this.zoneText).."\n"..
91 TitanUtils_Ternary((this.subZoneText == ""), "", TITAN_COORDS_TOOLTIP_SUBZONE.."\t"..TitanUtils_GetHighlightText(this.subZoneText).."\n")..
92 TitanUtils_Ternary((pvpInfoRichText == ""), "", TITAN_COORDS_TOOLTIP_PVPINFO.."\t"..pvpInfoRichText.."\n")..
93 "\n"..
94 TitanUtils_GetHighlightText(TITAN_COORDS_TOOLTIP_HOMELOCATION).."\n"..
95 TITAN_COORDS_TOOLTIP_INN.."\t"..TitanUtils_GetHighlightText(GetBindLocation()).."\n"..
96 TitanUtils_GetGreenText(TITAN_COORDS_TOOLTIP_HINTS_1).."\n"..
97 TitanUtils_GetGreenText(TITAN_COORDS_TOOLTIP_HINTS_2);
98 end
99  
100 function TitanPanelCoordsButton_OnEvent()
101 if (event == "ZONE_CHANGED_NEW_AREA") then
102 SetMapToCurrentZone();
103 end
104 TitanPanelCoordsButton_UpdateZoneInfo();
105 TitanPanelButton_UpdateTooltip();
106 end
107  
108 function TitanPanelCoordsButton_OnClick(button)
109 if (button == "LeftButton" and IsShiftKeyDown()) then
110 if (ChatFrameEditBox:IsVisible()) then
111 message = TitanUtils_ToString(this.zoneText).." "..
112 format(TITAN_COORDS_FORMAT, 100 * this.px, 100 * this.py);
113 ChatFrameEditBox:Insert(message);
114 end
115 end
116 end
117  
118 function TitanPanelCoordsButton_UpdateZoneInfo()
119 this.zoneText = GetZoneText();
120 this.subZoneText = GetSubZoneText();
121 this.minimapZoneText = GetMinimapZoneText();
122 this.pvpType, this.factionName, this.isArena = GetZonePVPInfo();
123 end
124  
125 function TitanPanelRightClickMenu_PrepareCoordsMenu()
126 TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_COORDS_ID].menuText);
127  
128 local info = {};
129 info.text = TITAN_COORDS_MENU_SHOW_ZONE_ON_PANEL_TEXT;
130 info.func = TitanPanelCoordsButton_ToggleDisplay;
131 info.checked = TitanGetVar(TITAN_COORDS_ID, "ShowZoneText");
132 UIDropDownMenu_AddButton(info);
133  
134 info = {};
135 info.text = TITAN_COORDS_MENU_SHOW_COORDS_ON_MAP_TEXT;
136 info.func = TitanPanelCoordsButton_ToggleCoordsOnMap;
137 info.checked = TitanGetVar(TITAN_COORDS_ID, "ShowCoordsOnMap");
138 UIDropDownMenu_AddButton(info);
139  
140 TitanPanelRightClickMenu_AddSpacer();
141 TitanPanelRightClickMenu_AddToggleIcon(TITAN_COORDS_ID);
142 TitanPanelRightClickMenu_AddToggleLabelText(TITAN_COORDS_ID);
143 TitanPanelRightClickMenu_AddToggleColoredText(TITAN_COORDS_ID);
144  
145  
146 TitanPanelRightClickMenu_AddSpacer();
147 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_COORDS_ID, TITAN_PANEL_MENU_FUNC_HIDE);
148 end
149  
150 function TitanPanelCoordsButton_ToggleDisplay()
151 TitanToggleVar(TITAN_COORDS_ID, "ShowZoneText");
152 TitanPanelButton_UpdateButton(TITAN_COORDS_ID);
153 end
154  
155 function TitanPanelCoordsButton_ToggleCoordsOnMap()
156 TitanToggleVar(TITAN_COORDS_ID, "ShowCoordsOnMap");
157 if (TitanGetVar(TITAN_COORDS_ID, "ShowCoordsOnMap")) then
158 TitanMapCursorCoords:Show();
159 TitanMapPlayerCoords:Show();
160 else
161 TitanMapCursorCoords:Hide();
162 TitanMapPlayerCoords:Hide();
163 end
164 end
165  
166 function TitanPanelCoordsButton_ToggleColor()
167 TitanToggleVar(TITAN_COORDS_ID, "ShowColoredText");
168 TitanPanelButton_UpdateButton(TITAN_COORDS_ID);
169 end
170  
171 local OFFSET_X = 0.0022;
172 local OFFSET_Y = -0.0262;
173  
174 function TitanMapFrame_OnUpdate()
175 if (TitanGetVar(TITAN_COORDS_ID, "ShowCoordsOnMap")) then
176 local x, y = GetCursorPosition();
177 x = x / WorldMapFrame:GetScale();
178 y = y / WorldMapFrame:GetScale();
179  
180 this.px, this.py = GetPlayerMapPosition("player");
181 local centerX, centerY = WorldMapFrame:GetCenter();
182 local width = WorldMapButton:GetWidth();
183 local height = WorldMapButton:GetHeight();
184 local adjustedX = (x - (centerX - (width/2))) / width;
185 local adjustedY = (centerY + (height/2) - y ) / height;
186 local cx = (adjustedX + OFFSET_X);
187 local cy = (adjustedY + OFFSET_Y);
188  
189 local cursorCoordsText = format(TITAN_COORDS_MAP_COORDS_TEXT, 100 * cx, 100 * cy);
190 local playerCoordsText = format(TITAN_COORDS_MAP_COORDS_TEXT, 100 * this.px, 100 * this.py);
191 TitanMapCursorCoords:SetText(format(TITAN_COORDS_MAP_CURSOR_COORDS_TEXT, TitanUtils_GetHighlightText(cursorCoordsText)));
192 TitanMapPlayerCoords:SetText(format(TITAN_COORDS_MAP_PLAYER_COORDS_TEXT, TitanUtils_GetHighlightText(playerCoordsText)));
193 end
194 end