Advertisement
Guest User

Minimap.lua

a guest
Apr 27th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. local MODULE_NAME = "Minimap"
  2. local ADDON_NAME = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  3. local MODULE = ADDON_NAME:NewModule(MODULE_NAME, "AceEvent-3.0")
  4. local L = setmetatable({}, { __index = function(t,k)
  5. local v = tostring(k)
  6. rawset(t, k, v)
  7. return v
  8. end })
  9.  
  10. ------------------------------------------------------------------------
  11. -- Module Database
  12. ------------------------------------------------------------------------
  13.  
  14. local db
  15. local defaults = {
  16. profile = {
  17. enable = true,
  18. gameclock = true,
  19. farm = false,
  20. farmscale = 1.15,
  21. coords = true,
  22. }
  23. }
  24.  
  25. ------------------------------------------------------------------------
  26. -- Module Functions
  27. ------------------------------------------------------------------------
  28.  
  29. function MODULE:OnInitialize()
  30. self.db = ADDON_NAME.db:RegisterNamespace(MODULE_NAME, defaults)
  31. db = self.db.profile
  32.  
  33. local _, class = UnitClass("player")
  34. classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  35.  
  36. self:SetEnabledState(ADDON_NAME:GetModuleEnabled(MODULE_NAME))
  37. end
  38.  
  39.  
  40. function MODULE:OnEnable()
  41. --[[
  42.  
  43. All Credit for Minimap.lua goes to Neal and ballagarba.
  44. Neav UI = http://www.wowinterface.com/downloads/info13981-NeavUI.html.
  45. Edited by Cokedriver.
  46.  
  47. ]]
  48.  
  49. if db.enable ~= true then return end
  50.  
  51.  
  52. -- Minimap tweaks:
  53.  
  54. -- Hide Zoom In/ Zoom Out buttons:
  55. MinimapZoomIn:Hide()
  56. MinimapZoomOut:Hide()
  57.  
  58. -- Mouse wheel Zom In/ Zoom out:
  59. Minimap:EnableMouseWheel(true)
  60. Minimap:SetScript('OnMouseWheel', function(self, delta)
  61. if delta > 0 then
  62. Minimap_ZoomIn()
  63. else
  64. Minimap_ZoomOut()
  65. end
  66. end)
  67.  
  68. -- Modify Minimap Tracker:
  69. MiniMapTracking:UnregisterAllEvents()
  70. MiniMapTracking:Hide()
  71.  
  72. Minimap:SetScript('OnMouseDown', function(self, button)
  73. if (button == 'RightButton') then
  74. ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, self, - (Minimap:GetWidth() * 0.7), -3)
  75. else
  76. Minimap_OnClick(self)
  77. end
  78. end)
  79.  
  80. Minimap:SetScript('OnEnter', function()
  81. if InCombatLockdown() then return end
  82. GameTooltip:SetOwner(Minimap, "ANCHOR_BOTTOM")
  83. GameTooltip:ClearLines()
  84. GameTooltip:AddLine("Minimap Options")
  85. GameTooltip:AddLine("|cffeda55fRight Click|r for Menu")
  86. GameTooltip:AddLine("|cffeda55fScroll|r for Zoom")
  87. GameTooltip:Show()
  88. end)
  89. Minimap:SetScript('OnLeave', function() GameTooltip:Hide() end)
  90.  
  91. -- Coords on World Map
  92. if db.coords then
  93. local coordsFrame = CreateFrame('Frame', nil, WorldMapFrame)
  94. coordsFrame:SetParent(WorldMapButton)
  95.  
  96. coordsFrame.Player = coordsFrame:CreateFontString(nil, 'OVERLAY')
  97. coordsFrame.Player:SetFont(ADDON_NAME.db.profile.media.fontNormal, 26)
  98. coordsFrame.Player:SetShadowOffset(1, -1)
  99. coordsFrame.Player:SetJustifyH('LEFT')
  100. coordsFrame.Player:SetPoint('BOTTOMLEFT', WorldMapButton, 7, 4)
  101. coordsFrame.Player:SetTextColor(1, 0.82, 0)
  102.  
  103. coordsFrame.Cursor = coordsFrame:CreateFontString(nil, 'OVERLAY')
  104. coordsFrame.Cursor:SetFont(ADDON_NAME.db.profile.media.fontNormal, 26)
  105. coordsFrame.Cursor:SetShadowOffset(1, -1)
  106. coordsFrame.Cursor:SetJustifyH('LEFT')
  107. coordsFrame.Cursor:SetPoint('BOTTOMLEFT', coordsFrame.Player, 'TOPLEFT')
  108. coordsFrame.Cursor:SetTextColor(1, 0.82, 0)
  109.  
  110. coordsFrame:SetScript('OnUpdate', function(self, elapsed)
  111. local width = WorldMapDetailFrame:GetWidth()
  112. local height = WorldMapDetailFrame:GetHeight()
  113. local mx, my = WorldMapDetailFrame:GetCenter()
  114. local px, py = GetPlayerMapPosition('player')
  115. local cx, cy = GetCursorPosition()
  116.  
  117. mx = ((cx / WorldMapDetailFrame:GetEffectiveScale()) - (mx - width / 2)) / width
  118. my = ((my + height / 2) - (cy / WorldMapDetailFrame:GetEffectiveScale())) / height
  119.  
  120. if (mx >= 0 and my >= 0 and mx <= 1 and my <= 1) then
  121. coordsFrame.Cursor:SetText(MOUSE_LABEL..format(': %.0f x %.0f', mx * 100, my * 100))
  122. else
  123. coordsFrame.Cursor:SetText('')
  124. end
  125.  
  126. if (px ~= 0 and py ~= 0) then
  127. coordsFrame.Player:SetText(PLAYER..format(': %.0f x %.0f', px * 100, py * 100))
  128. else
  129. coordsFrame.Player:SetText('')
  130. end
  131. end)
  132. end
  133.  
  134. self:Refresh()
  135. end
  136.  
  137. function MODULE:Refresh()
  138. -- Hide Minimap Clock
  139. if db.gameclock == true then
  140. TimeManagerClockButton:Show()
  141. else
  142. TimeManagerClockButton:Hide()
  143. end
  144.  
  145. -- Bigger minimap
  146. if db.farm == true then
  147. MinimapCluster:SetScale(db.farmscale)
  148. MinimapCluster:EnableMouse(false)
  149. else
  150. MinimapCluster:SetScale(1.1)
  151. MinimapCluster:EnableMouse(false)
  152. end
  153. end
  154.  
  155. ------------------------------------------------------------------------
  156. -- Module Options
  157. ------------------------------------------------------------------------
  158.  
  159. local options
  160. function MODULE:GetOptions()
  161. if options then
  162. return options
  163. end
  164.  
  165. local function isModuleDisabled()
  166. return not ADDON_NAME:GetModuleEnabled(MODULE_NAME)
  167. end
  168.  
  169. options = {
  170. type = "group",
  171. name = L[MODULE_NAME],
  172. get = function(info) return db[ info[#info] ] end,
  173. set = function(info, value) db[ info[#info] ] = value; self:Refresh() end,
  174. args = {
  175. ---------------------------
  176. --Option Type Seperators
  177. sep1 = {
  178. type = "description",
  179. order = 2,
  180. name = " ",
  181. },
  182. sep2 = {
  183. type = "description",
  184. order = 3,
  185. name = " ",
  186. },
  187. sep3 = {
  188. type = "description",
  189. order = 4,
  190. name = " ",
  191. },
  192. sep4 = {
  193. type = "description",
  194. order = 5,
  195. name = " ",
  196. },
  197. ---------------------------
  198. reloadUI = {
  199. type = "execute",
  200. name = "Reload UI",
  201. desc = " ",
  202. order = 0,
  203. func = function()
  204. ReloadUI()
  205. end,
  206. },
  207. Text = {
  208. type = "description",
  209. order = 0,
  210. name = "When changes are made a reload of the UI is needed.",
  211. width = "full",
  212. },
  213. Text1 = {
  214. type = "description",
  215. order = 1,
  216. name = " ",
  217. width = "full",
  218. },
  219. enable = {
  220. type = "toggle",
  221. order = 1,
  222. name = L["Enable Minimap Module"],
  223. width = "full"
  224. },
  225. farm = {
  226. type = "toggle",
  227. order = 2,
  228. name = L["Farming"],
  229. desc = L["Enlarges the Minimap when Farming."],
  230. disabled = function() return isModuleDisabled() or not db.enable end,
  231. },
  232. farmscale = {
  233. type = "range",
  234. order = 5,
  235. name = L["Farming Map Scale"],
  236. desc = L["Controls the Size of the Farming Map"],
  237. disabled = function() return isModuleDisabled() or not db.enable end,
  238. min = 1, max = 5, step = 0.1,
  239. },
  240. gameclock = {
  241. type = "toggle",
  242. order = 2,
  243. name = L["Game Clock"],
  244. desc = L["Enable the Clock Frame on Minimap."],
  245. disabled = function() return isModuleDisabled() or not db.enable end,
  246. },
  247. },
  248. }
  249. return options
  250. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement