diff --git a/mods/minimap-clock.lua b/mods/minimap-clock.lua index 3996b70..81a7896 100644 --- a/mods/minimap-clock.lua +++ b/mods/minimap-clock.lua @@ -1,5 +1,6 @@ local _G = ShaguTweaks.GetGlobalEnv() local T = ShaguTweaks.T +local API = ShaguTweaks.API local module = ShaguTweaks:register({ title = T["MiniMap Clock"], @@ -15,6 +16,7 @@ MinimapClock:SetFrameLevel(64) MinimapClock:SetPoint("BOTTOM", MinimapCluster, "BOTTOM", 8, 18) MinimapClock:SetWidth(50) MinimapClock:SetHeight(23) +MinimapClock:SetClampedToScreen(true) MinimapClock:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", @@ -155,6 +157,16 @@ module.enable = function(self) end local function resetposition() + -- Once the timer has been moved through Movable Unit Frames it has an + -- absolute saved position. Clearing that position restores the natural + -- Clock -> Timer relationship, so future clock moves carry it again. + local movedb = ShaguTweaks_config and ShaguTweaks_config["MoveUnitframes"] + if movedb then movedb["MinimapTimer"] = nil end + + local state = ShaguTweaks.MovableUnitFramesState + if state and state.manual then state.manual.timer = false end + if state and state.dragging then state.dragging.timer = false end + MinimapTimer:SetUserPlaced(false) MinimapTimer:ClearAllPoints() MinimapTimer:SetPoint("TOP", MinimapClock, "BOTTOM") @@ -182,8 +194,11 @@ module.enable = function(self) GameTooltip:Hide() end) + -- Keep the timer independently movable when Movable Unit Frames is disabled. + -- With the mover enabled, its Ctrl+Shift mode temporarily owns these scripts + -- and restores them afterwards. MinimapTimer:SetScript("OnDragStart", function() - if IsShiftKeyDown() and IsControlKeyDown() then + if API.IsShiftKeyDown() and API.IsControlKeyDown() then this:StartMoving() end end) @@ -203,7 +218,7 @@ module.enable = function(self) pausetimer() end elseif arg1 == "RightButton" then - if IsShiftKeyDown() and IsControlKeyDown() then + if API.IsShiftKeyDown() and API.IsControlKeyDown() then resettimer() MinimapTimer:Hide() resetposition() @@ -214,4 +229,4 @@ module.enable = function(self) end) resettimer() -end +end \ No newline at end of file diff --git a/mods/move-unitframes.lua b/mods/move-unitframes.lua index 55fd2a7..dc87b92 100644 --- a/mods/move-unitframes.lua +++ b/mods/move-unitframes.lua @@ -8,7 +8,7 @@ local API = ShaguTweaks.API local module = ShaguTweaks:register({ title = T["Movable Unit Frames"], - description = T["Player, Target, Party, Minimap, Buffs, Weapon Buffs and Debuffs can be moved while and are pressed together."], + description = T["Player, Target, Party, Minimap, Clock, Timer, Buffs, Weapon Buffs and Debuffs can be moved while and are pressed together."], expansions = { ["vanilla"] = true }, category = T["Unit Frames"], enabled = true, @@ -44,9 +44,13 @@ module.enable = function(self) sharedState.manual.buffs = movedb["BuffButton0"] ~= nil sharedState.manual.debuffs = movedb["BuffButton32"] ~= nil sharedState.manual.weapon = movedb["TempEnchant1"] ~= nil + sharedState.manual.clock = movedb["Clock"] ~= nil + sharedState.manual.timer = movedb["MinimapTimer"] ~= nil sharedState.dragging.buffs = false sharedState.dragging.debuffs = false sharedState.dragging.weapon = false + sharedState.dragging.clock = false + sharedState.dragging.timer = false local unlocked = false local states = {} @@ -63,6 +67,8 @@ module.enable = function(self) { name = "PartyMemberFrame3", persist = true }, { name = "PartyMemberFrame4", persist = true }, { name = "Minimap", moveParent = true, persist = true, clamp = true }, + { name = "MinimapClock", persist = true, clamp = true, manualGroup = "clock", suppressMouseDown = true }, + { name = "MinimapTimer", persist = true, clamp = true, manualGroup = "timer" }, { name = "BuffButton0", persist = true, manualGroup = "buffs", cursorDrag = true }, { name = "BuffButton32", persist = true, manualGroup = "debuffs", cursorDrag = true }, { name = "TempEnchant1", persist = true, manualGroup = "weapon", cursorDrag = true }, @@ -259,6 +265,10 @@ module.enable = function(self) state.moveFrame = moveFrame state.onDragStart = handle:GetScript("OnDragStart") state.onDragStop = handle:GetScript("OnDragStop") + if target.suppressMouseDown then + state.onMouseDown = handle:GetScript("OnMouseDown") + handle:SetScript("OnMouseDown", nil) + end if handle.IsMouseEnabled then state.mouseEnabled = handle:IsMouseEnabled() and true or false @@ -362,6 +372,9 @@ module.enable = function(self) if handle then handle:SetScript("OnDragStart", state.onDragStart) handle:SetScript("OnDragStop", state.onDragStop) + if target.suppressMouseDown then + handle:SetScript("OnMouseDown", state.onMouseDown) + end if state.mouseEnabled ~= nil then handle:EnableMouse(state.mouseEnabled) @@ -442,4 +455,4 @@ module.enable = function(self) end UpdateLockState() -end +end \ No newline at end of file