Skip to content

Commit

Permalink
#383 - Move Minimap when in vehicle. Allow a 2nd saved location
Browse files Browse the repository at this point in the history
  • Loading branch information
Wutname1 committed Oct 7, 2024
1 parent 10e0147 commit c07c8f0
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Modules/Minimap/Minimap.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---@class SUI
local SUI = SUI
local L = SUI.L
local MoveIt = SUI.MoveIt
local module = SUI:NewModule('Minimap') ---@class SUI.Module.Minimap : SUI.Module
module.description = 'CORE: Skins, sizes, and positions the Minimap'
Expand All @@ -19,6 +20,7 @@ local BaseSettings = {
scaleWithArt = true,
UnderVehicleUI = true,
position = 'TOPRIGHT,UIParent,TOPRIGHT,-20,-20',
vehiclePosition = 'TOPRIGHT,UIParent,TOPRIGHT,-20,-20',
rotate = false,

-- Elements
Expand Down Expand Up @@ -564,6 +566,15 @@ function module:CreateMover()
MoveIt:CreateMover(SUIMinimap, 'Minimap')
end

function module:SwitchMinimapPosition(inVehicle)
local position = inVehicle and self.Settings.vehiclePosition or self.Settings.position
if not MoveIt:IsMoved('Minimap') then
local point, anchor, secondaryPoint, x, y = strsplit(',', position)
SUIMinimap:ClearAllPoints()
SUIMinimap:SetPoint(point, _G[anchor], secondaryPoint, x, y)
end
end

function module:SetupHooks()
Minimap:HookScript('OnShow', function()
SUIMinimap:Show()
Expand Down Expand Up @@ -619,7 +630,7 @@ function module:Update(fullUpdate)
if module.Settings.UnderVehicleUI and SUI.DB.Artwork.VehicleUI and not VisibilityWatcher.hooked and (not MoveIt:IsMoved('Minimap')) then
local OnHide = function(args)
if SUI:IsModuleEnabled('Minimap') and SUI.DB.Artwork.VehicleUI and not MoveIt:IsMoved('Minimap') and SUIMinimap.position then
SUIMinimap:position('TOPRIGHT', UIParent, 'TOPRIGHT', -20, -20)
SUIMinimap:position(strsplit(',', module.Settings.vehiclePosition))
end
end
local OnShow = function(args)
Expand Down
102 changes: 102 additions & 0 deletions Modules/Minimap/Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ local anchorValues = {

-- Options
function module:BuildOptions()
local anchorPoints = {
['TOPLEFT'] = 'TOP LEFT',
['TOP'] = 'TOP',
['TOPRIGHT'] = 'TOP RIGHT',
['RIGHT'] = 'RIGHT',
['CENTER'] = 'CENTER',
['LEFT'] = 'LEFT',
['BOTTOMLEFT'] = 'BOTTOM LEFT',
['BOTTOM'] = 'BOTTOM',
['BOTTOMRIGHT'] = 'BOTTOM RIGHT',
}

---@type AceConfig.OptionsTable
local options = {
type = 'group',
Expand Down Expand Up @@ -215,6 +227,96 @@ function module:BuildOptions()
module:Update(true)
end,
},
UnderVehicleUI = {
name = L['Under Vehicle UI'],
desc = L['Set to enabled if the minimap is under the Blizzard VehicleUI'],
type = 'toggle',
width = 'full',
order = 290,
get = function()
return module.Settings.UnderVehicleUI
end,
},
vehiclePosition = {
name = L['Vehicle Position'],
type = 'group',
order = 300,
inline = true,
disabled = function()
return not module.Settings.UnderVehicleUI
end,
get = function(info)
local point, anchor, secondaryPoint, x, y = strsplit(',', module.Settings.vehiclePosition)
if info[#info] == 'x' then
return tonumber(x)
elseif info[#info] == 'y' then
return tonumber(y)
elseif info[#info] == 'anchor' then
return point
elseif info[#info] == 'relativeTo' then
return anchor
elseif info[#info] == 'relativePoint' then
return secondaryPoint
end
end,
set = function(info, val)
local point, anchor, secondaryPoint, x, y = strsplit(',', module.Settings.vehiclePosition)

if info[#info] == 'x' then
x = val
elseif info[#info] == 'y' then
y = val
elseif info[#info] == 'anchor' then
point = val
elseif info[#info] == 'relativeTo' then
anchor = val
elseif info[#info] == 'relativePoint' then
secondaryPoint = val
end

module.Settings.vehiclePosition = strjoin(',', point, anchor, secondaryPoint, x, y)
module.DB.customSettings[SUI.DB.Artwork.Style].vehiclePosition = module.Settings.vehiclePosition
module:Update(true)
end,
args = {
x = {
name = L['X Axis'],
type = 'range',
order = 1,
min = -200,
max = 200,
step = 1,
},
y = {
name = L['Y Axis'],
type = 'range',
order = 2,
min = -200,
max = 200,
step = 1,
},
anchor = {
name = L['Anchor point'],
type = 'select',
order = 3,
values = anchorPoints,
},
relativeTo = {
name = 'Relative To',
type = 'select',
order = 3,
values = {
['UIParent'] = 'UIParent',
},
},
relativePoint = {
name = 'Relative Point',
type = 'select',
order = 3,
values = anchorPoints,
},
},
},
},
},
elements = {
Expand Down

0 comments on commit c07c8f0

Please sign in to comment.