-
-
Save Industrial/ced32209a12da3335998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local idTweaks = LibStub('AceAddon-3.0'):GetAddon('idTweaks') | |
local Module = idTweaks:NewModule('Minimap', 'AceConsole-3.0', 'AceHook-3.0') | |
-- TODO: Create an option (on/off) for AnchorMouse. | |
function Module:setDefaults() | |
self.defaults = { | |
profile = { | |
zoom = { | |
mouseWheel = true | |
}, | |
track = { | |
rightClickMenu = true | |
}, | |
hide = { | |
calendarButton = true, | |
timeDisplay = true, | |
trackingButton = true, | |
areaText = true, | |
worldMapButton = true, | |
voiceChatButton = true, | |
zoomButtons = true | |
} | |
} | |
} | |
end | |
function Module:setDatabase() | |
self.db = idTweaks.db:RegisterNamespace('Minimap', self.defaults) | |
end | |
function Module:setOptions() | |
self.options = { | |
name = 'Minimap', | |
handler = self, | |
type = 'group', | |
args = { | |
zoom = { | |
name = 'Zoom', | |
handler = self, | |
type = 'group', | |
args = { | |
mouseWheel = { | |
name = 'Mouse Wheel', | |
handler = self, | |
type = 'toggle', | |
get = function() | |
return self.db.profile.zoom.mouseWheel | |
end, | |
set = function(_, value) | |
self.db.profile.zoom.mouseWheel = value | |
self.zoom:checkMousewheelZooming() | |
end | |
} | |
} | |
}, | |
track = { | |
name = 'Track', | |
type = 'group', | |
args = { | |
rightClickMenu = { | |
name = 'Right Click Menu', | |
handler = self, | |
type = 'toggle', | |
get = function() | |
return self.db.profile.track.rightClickMenu | |
end, | |
set = function(_, value) | |
self.db.profile.track.rightClickMenu = value | |
self.track:checkRightClickMenu() | |
end | |
} | |
} | |
}, | |
hide = { | |
name = 'Hide', | |
type = 'group', | |
args = { | |
} | |
} | |
} | |
} | |
--[[ | |
- Mouse wheel scrolling. | |
- On right click, open the tracking menu. | |
- Hide elements: | |
- Calendar button. | |
- Clock. | |
- Tracking button. | |
- Area text. | |
- World map button. | |
- Voice Chat button. | |
- Zoom buttons. | |
]] | |
end | |
function Module:registerOptions() | |
LibStub('AceConfig-3.0'):RegisterOptionsTable('idTweaks-Minimap', self.options) | |
LibStub('AceConfigDialog-3.0'):AddToBlizOptions('idTweaks-Minimap', 'Minimap', 'idTweaks') | |
end | |
function Module:OnInitialize() | |
self:setDefaults() | |
self:setDatabase() | |
self:setOptions() | |
end | |
function Module:OnEnable() | |
self:registerOptions() | |
-- enable mousewheel scrolling? check db? | |
self.zoom:checkMousewheelZooming() | |
self.track:checkRightClickMenu() | |
-- hide minimap elements | |
GameTimeFrame:Hide() -- calendar | |
TimeManagerClockButton:Hide() | |
MiniMapTracking:Hide() | |
MinimapBorderTop:Hide() | |
MiniMapWorldMapButton:Hide() | |
MiniMapVoiceChatFrame:Hide() | |
MiniMapVoiceChatFrame:SetScript('OnShow', MiniMapVoiceChatFrame.Hide) | |
MiniMapWorldMapButton:Hide() | |
MinimapZoneTextButton:Hide() | |
MinimapZoomIn:Hide() | |
MinimapZoomOut:Hide() | |
end | |
function Module:OnDisable() | |
end | |
Module.hide = {} | |
Module.track = {} | |
function Module.track:checkRightClickMenu() | |
if Module.db.profile.track.rightClickMenu == true then | |
self:enableRightClickMenu() | |
else | |
self:disableRightClickMenu() | |
end | |
end | |
function Module.track:enableRightClickMenu() | |
Minimap:SetScript('OnMouseUp', self.openTrackingPopup) | |
end | |
function Module.track:disableRightClickMenu() | |
Minimap:SetScript('OnMouseUp', Minimap_OnClick) | |
end | |
function Module.track.openTrackingPopup(frame, button, ...) | |
if button == 'RightButton' then | |
MiniMapTrackingButton:GetScript('OnClick')() | |
else | |
Minimap_OnClick(Minimap) | |
end | |
end | |
Module.zoom = {} | |
function Module.zoom:checkMousewheelZooming() | |
if Module.db.profile.zoom.mouseWheel == true then | |
self:enableMousewheelZooming() | |
else | |
self:disableMousewheelZooming() | |
end | |
end | |
function Module.zoom:enableMousewheelZooming() | |
Minimap:EnableMouseWheel(true) | |
Minimap:SetScript('OnMouseWheel', self.handleMousewheelZoom) | |
end | |
function Module.zoom:disableMousewheelZooming() | |
Minimap:EnableMouseWheel(false) | |
Minimap:SetScript('OnMouseWheel', nil) | |
end | |
function Module.zoom.handleMousewheelZoom(frame, delta) | |
if delta > 0 and Minimap:GetZoom() < 5 then | |
Minimap:SetZoom(Minimap:GetZoom() + 1) | |
elseif delta < 0 and Minimap:GetZoom() > 0 then | |
Minimap:SetZoom(Minimap:GetZoom() - 1) | |
end | |
end | |
idTweaks.Minimap = Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment