MovableFrames.lua 13.6 KB
Newer Older
Azilroka's avatar
MF  
Azilroka committed
1 2 3 4
local PA = _G.ProjectAzilroka
local MF = PA:NewModule('MovableFrames', 'AceEvent-3.0', 'AceHook-3.0')
PA.MF, _G.MovableFrames = MF, MF

Azilroka's avatar
Azilroka committed
5 6
MF.Title = 'Movable Frames'
MF.Header = PA.ACL['|cFF16C3F2Movable|r |cFFFFFFFFFrames|r']
7
MF.Description = PA.ACL['Make Blizzard Frames Movable']
Azilroka's avatar
MF  
Azilroka committed
8
MF.Authors = 'Azilroka    Simpy'
Azilroka's avatar
Azilroka committed
9
MF.isEnabled = false
Azilroka's avatar
MF  
Azilroka committed
10

Azilroka's avatar
Azilroka committed
11 12 13
local pairs = pairs
local unpack = unpack

Azilroka's avatar
MF  
Azilroka committed
14
local _G = _G
Azilroka's avatar
1.48  
Azilroka committed
15
local IsAddOnLoaded = IsAddOnLoaded
Azilroka's avatar
Azilroka committed
16
local InCombatLockdown = InCombatLockdown
Azilroka's avatar
MF  
Azilroka committed
17 18

local Frames = {
Azilroka's avatar
Azilroka committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
	AddonList = { "CENTER", "UIParent", "CENTER", 0, 24 },
	BankFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	CharacterFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	DressUpFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 70, -104 },
	FriendsFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	FriendsFriendsFrame = { "CENTER", "UIParent", "CENTER", 0, 50 },
	GameMenuFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	GhostFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, 0 },
	GossipFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	GuildInviteFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	GuildRegistrarFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	HelpFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	InterfaceOptionsFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	ItemTextFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	LFGDungeonReadyDialog = { "TOPLEFT", _G.LFGDungeonReadyPopup, "TOPLEFT", 0, 0 },
	LootFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	LossOfControlFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	MailFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	MerchantFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	PetitionFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	PetStableFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, -104 },
	PVEFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 100, -84 },
	QuestFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	QuestLogFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	QuestLogPopupDetailFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, 0 },
	RaidBrowserFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	RaidParentFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	ReadyCheckFrame = { "CENTER", "UIParent", "CENTER", 0, -10 },
	ScrollOfResurrectionSelectionFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	SpellBookFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	SplashFrame = { "CENTER", "UIParent", "CENTER", 0, 60 },
	StaticPopup1 = { "TOP", "UIParent", "TOP", 0, -135 },
	StaticPopup2 = { "TOP", "UIParent", "TOP", 0, -135 },
	StaticPopup3 = { "TOP", "UIParent", "TOP", 0, -135 },
	StaticPopup4 = { "TOP", "UIParent", "TOP", 0, -135 },
	TabardFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	TaxiFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, -104 },
	TimeManagerFrame = { "TOPRIGHT", "UIParent", "TOPRIGHT", -10, -190 },
	TradeFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 },
	VideoOptionsFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	WorldMapFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
	WorldStateScoreFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
Azilroka's avatar
MF  
Azilroka committed
61 62 63
}

local AddOnFrames = {
Azilroka's avatar
Azilroka committed
64 65
	Blizzard_AchievementUI = {
		AchievementFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 96, -116 }
Azilroka's avatar
MF  
Azilroka committed
66
	},
67 68 69
	Blizzard_AnimaDiversionUI = {
		AnimaDiversionFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
	},
Azilroka's avatar
Azilroka committed
70 71
	Blizzard_ArchaeologyUI = {
		ArchaeologyFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
72
	},
Azilroka's avatar
Azilroka committed
73 74
	Blizzard_AuctionUI = {
		AuctionFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, -104 }
Azilroka's avatar
MF  
Azilroka committed
75
	},
Azilroka's avatar
Azilroka committed
76 77 78
	Blizzard_AuctionHouseUI = {
		AuctionHouseFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, -104 }
	},
Azilroka's avatar
Azilroka committed
79 80
	Blizzard_BarbershopUI = {
		BarberShopFrame = { "RIGHT", "UIParent", "RIGHT", -18, -54 }
Azilroka's avatar
MF  
Azilroka committed
81
	},
Azilroka's avatar
Azilroka committed
82 83
	Blizzard_BindingUI = {
		KeyBindingFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
Azilroka's avatar
MF  
Azilroka committed
84
	},
Azilroka's avatar
Azilroka committed
85 86
	Blizzard_BlackMarketUI = {
		BlackMarketFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, -104 }
Azilroka's avatar
MF  
Azilroka committed
87
	},
Azilroka's avatar
Azilroka committed
88 89 90 91 92
	Blizzard_Calendar = {
		CalendarCreateEventFrame = { "TOPLEFT", _G.CalendarFrame, "TOPRIGHT", 3, -24 },
		CalendarFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -96 },
		CalendarViewEventFrame = { "TOPLEFT", _G.CalendarFrame, "TOPRIGHT", 3, -24 },
		CalendarViewHolidayFrame = { "TOPLEFT", _G.CalendarFrame, "TOPRIGHT", 3, -24 },
Azilroka's avatar
MF  
Azilroka committed
93
	},
Azilroka's avatar
Azilroka committed
94
	Blizzard_ChallengesUI = {
95
		ChallengesKeystoneFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
Azilroka's avatar
MF  
Azilroka committed
96
	},
Azilroka's avatar
Azilroka committed
97
	Blizzard_Channels = {
98
		ChannelFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -96 }
Azilroka's avatar
Azilroka committed
99
	},
Azilroka's avatar
Azilroka committed
100 101
	Blizzard_Collections = {
		CollectionsJournal = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
102
	},
Azilroka's avatar
Azilroka committed
103
	Blizzard_Communities = {
104 105 106 107 108 109 110
		CommunitiesFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
	},
	Blizzard_CovenantPreviewUI = {
		CovenantPreviewFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
	},
	Blizzard_CovenantSanctum = {
		CovenantSanctumFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
Azilroka's avatar
MF  
Azilroka committed
111
	},
Azilroka's avatar
Azilroka committed
112
	Blizzard_CraftUI = {
113
		CraftFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
Azilroka committed
114
	},
Azilroka's avatar
Azilroka committed
115 116
	Blizzard_EncounterJournal = {
		EncounterJournal = { "CENTER", "UIParent", "CENTER", 0, 0 }
Azilroka's avatar
MF  
Azilroka committed
117
	},
Azilroka's avatar
Azilroka committed
118 119 120 121 122 123 124 125
	Blizzard_GarrisonUI = {
		GarrisonBuildingFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
		GarrisonCapacitiveDisplayFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 27, -108 },
		GarrisonLandingPage = { "CENTER", "UIParent", "CENTER", 0, 0 },
		GarrisonMissionFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
		GarrisonRecruiterFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
		GarrisonRecruitSelectFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
		GarrisonShipyardFrame = { "CENTER", "UIParent", "CENTER", 0, 0 },
Azilroka's avatar
MF  
Azilroka committed
126
	},
Azilroka's avatar
Azilroka committed
127 128
	Blizzard_GuildBankUI = {
		GuildBankFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 0, -104 }
Azilroka's avatar
MF  
Azilroka committed
129
	},
Azilroka's avatar
Azilroka committed
130 131
	Blizzard_GuildControlUI = {
		GuildControlUI = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
132
	},
Azilroka's avatar
Azilroka committed
133 134
	Blizzard_InspectUI = {
		InspectFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
135
	},
Azilroka's avatar
Azilroka committed
136 137
	Blizzard_ItemSocketingUI = {
		ItemSocketingFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
138
	},
Azilroka's avatar
Azilroka committed
139 140
	Blizzard_ItemUpgradeUI = {
		ItemUpgradeFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
141
	},
Azilroka's avatar
Azilroka committed
142 143
	Blizzard_LookingForGuildUI = {
		LookingForGuildFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
144
	},
Azilroka's avatar
Azilroka committed
145 146
	Blizzard_MacroUI = {
		MacroFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
147
	},
Azilroka's avatar
Azilroka committed
148 149
	Blizzard_OrderHallUI = {
		OrderHallTalentFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 32, -116 }
Azilroka's avatar
MF  
Azilroka committed
150
	},
151 152 153
	Blizzard_PlayerChoiceUI = {
		PlayerChoiceFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
	},
Azilroka's avatar
Azilroka committed
154 155
	Blizzard_QuestChoice = {
		QuestChoiceFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
Azilroka's avatar
MF  
Azilroka committed
156
	},
Azilroka's avatar
Azilroka committed
157 158 159
	Blizzard_TalentUI = {
		PlayerTalentFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 100, -84 },
		TalentFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 100, -84 },
Azilroka's avatar
MF  
Azilroka committed
160
	},
161 162 163
	Blizzard_Soulbinds = {
		SoulbindViewer = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
	},
Azilroka's avatar
Azilroka committed
164 165
	Blizzard_ScrappingMachineUI = {
		ScrappingMachineFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
166
	},
Azilroka's avatar
Azilroka committed
167 168
	Blizzard_TalkingHeadUI = {
		TalkingHeadFrame = { "BOTTOM", "UIParent", "BOTTOM", 0, 96 }
Azilroka's avatar
MF  
Azilroka committed
169
	},
Azilroka's avatar
Azilroka committed
170 171
	Blizzard_TradeSkillUI = {
		TradeSkillFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
172
	},
Azilroka's avatar
Azilroka committed
173 174
	Blizzard_TrainerUI = {
		ClassTrainerFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
175
	},
Azilroka's avatar
Azilroka committed
176 177
	Blizzard_VoidStorageUI = {
		VoidStorageFrame = { "TOPLEFT", "UIParent", "TOPLEFT", 16, -116 }
Azilroka's avatar
MF  
Azilroka committed
178
	},
179 180 181
	Blizzard_WeeklyRewards = {
		WeeklyRewardsFrame = { "CENTER", "UIParent", "CENTER", 0, 0 }
	},
Azilroka's avatar
MF  
Azilroka committed
182 183
}

Azilroka's avatar
1.58  
Azilroka committed
184 185 186 187 188 189 190 191 192 193 194 195
function MF:LoadPosition(frame, elapsed)
	if frame.MFisMoving or InCombatLockdown() then return end

	frame.throttle = (frame.throttle or 0) + (elapsed or .01)

	if frame:IsMovable() and frame:IsUserPlaced() and (frame.throttle > .01) then
		frame:SetScript('OnMouseDown', nil)
		local a, b, c, d, e = unpack(MF.db[frame:GetName()].Points)
		frame:ClearAllPoints()
		frame:SetPoint(a, _G[b], c, d, e, true)
		frame.throttle = 0
	end
Azilroka's avatar
MF  
Azilroka committed
196 197 198
end

function MF:OnDragStart(frame)
Azilroka's avatar
1.58  
Azilroka committed
199
	frame.MFisMoving = true
Azilroka's avatar
MF  
Azilroka committed
200 201 202 203 204 205
	frame:StartMoving()
end

function MF:OnDragStop(frame)
	frame:StopMovingOrSizing()
	local Name = frame:GetName()
Azilroka's avatar
Azilroka committed
206
	if MF.db[Name].Permanent then
Azilroka's avatar
MF  
Azilroka committed
207
		local a, _, c, d, e = frame:GetPoint()
Azilroka's avatar
Fix MF  
Azilroka committed
208
		local b = frame:GetParent():GetName() or "UIParent"
Azilroka's avatar
MF  
Azilroka committed
209
		if Name == 'QuestFrame' or Name == 'GossipFrame' then
Azilroka's avatar
Azilroka committed
210 211
			MF.db.GossipFrame.Points = {a, b, c, d, e}
			MF.db.QuestFrame.Points = {a, b, c, d, e}
Azilroka's avatar
MF  
Azilroka committed
212 213 214
		else
			MF.db[Name].Points = {a, b, c, d, e}
		end
Azilroka's avatar
Azilroka committed
215
		frame:SetUserPlaced(true)
Azilroka's avatar
1.58  
Azilroka committed
216 217
		frame:ClearAllPoints()
		frame:SetPoint(a, _G[b], c, d, e, true)
Azilroka's avatar
1.53  
Azilroka committed
218
	elseif frame:IsUserPlaced() then
Azilroka's avatar
MF  
Azilroka committed
219 220
		frame:SetUserPlaced(false)
	end
Azilroka's avatar
1.58  
Azilroka committed
221
	frame.MFisMoving = false
Azilroka's avatar
Azilroka committed
222 223 224
end

function MF:SetUIPanelAttribute(frame, name, value)
Azilroka's avatar
Azilroka committed
225
	local info = _G.UIPanelWindows[frame:GetName()];
Azilroka's avatar
Azilroka committed
226 227 228 229
	if ( not info ) then
		return;
	end

Azilroka's avatar
Azilroka committed
230
	_G.SetUIPanelAttribute(frame, name, value)
Azilroka's avatar
Azilroka committed
231 232
end

Azilroka's avatar
MF  
Azilroka committed
233 234 235 236 237 238 239
function MF:MakeMovable(Name)
	if not _G[Name] then
		return
	end

	local Frame = _G[Name]

Azilroka's avatar
1.58  
Azilroka committed
240 241 242
	if Name == 'AchievementFrame' then
		_G.AchievementFrameHeader:EnableMouse(false)
	end
Azilroka's avatar
MF  
Azilroka committed
243

Azilroka's avatar
1.58  
Azilroka committed
244 245 246
	if Name == 'WorldMapFrame' then
		if PA.Classic then
			MF:SetUIPanelAttribute(_G.WorldMapFrame, 'maximizePoint', nil)
Azilroka's avatar
Azilroka committed
247

Azilroka's avatar
1.58  
Azilroka committed
248 249 250 251 252 253
			function ToggleWorldMap()
				if _G.WorldMapFrame:IsShown() then
					_G.HideUIPanel(_G.WorldMapFrame)
				else
					_G.ShowUIPanel(_G.WorldMapFrame)
				end
Azilroka's avatar
Azilroka committed
254 255
			end

Azilroka's avatar
1.58  
Azilroka committed
256 257 258
			function OpenWorldMap()
				_G.ShowUIPanel(_G.WorldMapFrame)
			end
Azilroka's avatar
Azilroka committed
259

Azilroka's avatar
Azilroka committed
260 261 262
			_G.ToggleWorldMap()
			_G.ToggleWorldMap()
		end
Azilroka's avatar
Azilroka committed
263 264
	end

Azilroka's avatar
MF  
Azilroka committed
265 266 267 268
	Frame:EnableMouse(true)
	Frame:SetMovable(true)
	Frame:RegisterForDrag('LeftButton')
	Frame:SetClampedToScreen(true)
Azilroka's avatar
1.39  
Azilroka committed
269

Azilroka's avatar
Azilroka committed
270 271 272 273
	MF:HookScript(Frame, 'OnUpdate', 'LoadPosition')
	MF:HookScript(Frame, 'OnDragStart', 'OnDragStart')
	MF:HookScript(Frame, 'OnDragStop', 'OnDragStop')
	MF:HookScript(Frame, 'OnHide', 'OnDragStop')
Azilroka's avatar
1.39  
Azilroka committed
274

Azilroka's avatar
Azilroka committed
275
	MF:SecureHook(Frame, 'SetPoint', function(_, _, _, _, _, locked)
Azilroka's avatar
1.39  
Azilroka committed
276
		if not locked then
Azilroka's avatar
Azilroka committed
277
			MF:LoadPosition(Frame)
Azilroka's avatar
1.39  
Azilroka committed
278 279
		end
	end)
Azilroka's avatar
MF  
Azilroka committed
280 281 282 283 284
end

function MF:ADDON_LOADED(_, addon)
	if AddOnFrames[addon] then
		for Frame in pairs(AddOnFrames[addon]) do
Azilroka's avatar
Azilroka committed
285
			MF:MakeMovable(Frame)
Azilroka's avatar
MF  
Azilroka committed
286 287 288 289 290
		end
	end
end

function MF:GetOptions()
Azilroka's avatar
Azilroka committed
291 292 293 294 295 296 297 298 299
	PA.Options.args.MovableFrames = PA.ACH:Group(MF.Title, MF.Description, nil, nil, function(info) return MF.db[info[#info]] end, function(info, value) MF.db[info[#info]] = value MF:Update() end)
	PA.Options.args.MovableFrames.args.Header = PA.ACH:Header(MF.Header, 0)
	PA.Options.args.MovableFrames.args.Enable = PA.ACH:Toggle(PA.ACL['Enable'], nil, 1, nil, nil, nil, nil, function(info, value) MF.db[info[#info]] = value if (not MF.isEnabled) then MF:Initialize() else _G.StaticPopup_Show('PROJECTAZILROKA_RL') end end)
	PA.Options.args.MovableFrames.args.General = PA.ACH:Group(PA.ACL['General'], nil, 2)
	PA.Options.args.MovableFrames.args.General.inline = true

	PA.Options.args.MovableFrames.args.General.args.Permanent = PA.ACH:MultiSelect(PA.ACL['Permanent Moving'], nil, 1, {}, nil, nil, function(_, key) return MF.db[key].Permanent end, function(_, key, value) MF.db[key].Permanent = value end)
	PA.Options.args.MovableFrames.args.General.args.Reset = PA.ACH:Group(PA.ACL['Reset Moving'], nil, 2)
	PA.Options.args.MovableFrames.args.General.args.Reset.inline = true
Azilroka's avatar
MF  
Azilroka committed
300

Azilroka's avatar
1.58  
Azilroka committed
301
	for Frame in pairs(Frames) do
Azilroka's avatar
Azilroka committed
302
		PA.Options.args.MovableFrames.args.General.args.Permanent.values[Frame] = Frame
Azilroka's avatar
Azilroka committed
303
		PA.Options.args.MovableFrames.args.General.args.Reset.args[Frame] = PA.ACH:Execute(Frame, nil, nil, function(info) _G.HideUIPanel(_G[info[#info]]) end, nil, nil, nil, nil, nil, function(info) return not MF.db[info[#info]].Permanent end)
Azilroka's avatar
MF  
Azilroka committed
304
	end
Azilroka's avatar
1.58  
Azilroka committed
305 306 307

	for _, Table in pairs(AddOnFrames) do
		for Frame in pairs(Table) do
Azilroka's avatar
Azilroka committed
308 309
			PA.Options.args.MovableFrames.args.General.args.Permanent.values[Frame] = Frame
			PA.Options.args.MovableFrames.args.General.args.Reset.args[Frame] = PA.ACH:Execute(Frame, nil, nil, function(info) _G.HideUIPanel(_G[info[#info]]) end, nil, nil, nil, nil, nil, function(info) return not MF.db[info[#info]].Permanent end)
Azilroka's avatar
1.58  
Azilroka committed
310 311
		end
	end
Azilroka's avatar
Azilroka committed
312 313 314

	PA.Options.args.MovableFrames.args.AuthorHeader = PA.ACH:Header(PA.ACL['Authors:'], -2)
	PA.Options.args.MovableFrames.args.Authors = PA.ACH:Description(MF.Authors, -1, 'large')
Azilroka's avatar
MF  
Azilroka committed
315 316 317
end

function MF:BuildProfile()
Azilroka's avatar
Azilroka committed
318
	PA.Defaults.profile.MovableFrames = { Enable = true }
Azilroka's avatar
Azilroka committed
319

Azilroka's avatar
Azilroka committed
320
	if PA.Tukui then
Azilroka's avatar
Azilroka committed
321
		Frames.LossOfControlFrame = { "CENTER", "UIParent", "CENTER", 0, 60 }
Azilroka's avatar
Azilroka committed
322 323
	end

Azilroka's avatar
MF  
Azilroka committed
324
	for Frame, DefaultPoints in pairs(Frames) do
Azilroka's avatar
Azilroka committed
325
		PA.Defaults.profile.MovableFrames[Frame] = { Permanent = true, Points = DefaultPoints }
Azilroka's avatar
MF  
Azilroka committed
326 327 328 329
	end

	for _, Table in pairs(AddOnFrames) do
		for Frame, DefaultPoints in pairs(Table) do
Azilroka's avatar
Azilroka committed
330
			PA.Defaults.profile.MovableFrames[Frame] = { Permanent = true, Points = DefaultPoints }
Azilroka's avatar
MF  
Azilroka committed
331 332 333 334
		end
	end
end

Azilroka's avatar
Azilroka committed
335
function MF:UpdateSettings()
Azilroka's avatar
Azilroka committed
336
	MF.db = PA.db.MovableFrames
Azilroka's avatar
Azilroka committed
337 338 339 340
end

function MF:Initialize()
	MF:UpdateSettings()
Azilroka's avatar
MF  
Azilroka committed
341

Azilroka's avatar
Azilroka committed
342 343 344 345
	if MF.db.Enable ~= true then
		return
	end

Azilroka's avatar
Azilroka committed
346 347 348 349 350 351 352 353 354 355 356 357
	if PA.ElvUI and PA.SLE then
		if (not _G.ElvUI[1].private.sle.module) or (_G.ElvUI[1].private.sle.module.blizzmove and _G.ElvUI[1].private.sle.module.blizzmove.enable) then
			_G.StaticPopupDialogs.PROJECTAZILROKA.text = 'Shadow & Light Blizz Move and Movable Frames will not work together. Which one do you want to disable?'
			_G.StaticPopupDialogs.PROJECTAZILROKA.button1 = 'S&L Blizz Move'
			_G.StaticPopupDialogs.PROJECTAZILROKA.button2 = 'Movable Frames'
			_G.StaticPopupDialogs.PROJECTAZILROKA.OnAccept = function()
				_G.ElvUI[1].private.sle.module.blizzmove.enable = false
				_G.ReloadUI()
			end
			_G.StaticPopupDialogs.PROJECTAZILROKA.OnCancel = function() MF.db.Enable = false end
			_G.StaticPopup_Show("PROJECTAZILROKA")
			return
Azilroka's avatar
Azilroka committed
358 359
		end
	end
Azilroka's avatar
Azilroka committed
360

Azilroka's avatar
Azilroka committed
361
	MF.isEnabled = true
Azilroka's avatar
MF  
Azilroka committed
362

363
	if PA:IsAddOnEnabled('WorldQuestTracker') or PA:IsAddOnEnabled('Leatrix_Maps') then
Azilroka's avatar
Azilroka committed
364
		Frames.WorldMapFrame = nil
Azilroka's avatar
Azilroka committed
365 366
	end

Azilroka's avatar
Azilroka committed
367
	if PA.ElvUI then
Azilroka's avatar
Azilroka committed
368 369
		AddOnFrames.LossOfControlFrame = nil
		AddOnFrames.Blizzard_TalkingHeadUI = nil
Azilroka's avatar
MF  
Azilroka committed
370 371
	end

Azilroka's avatar
1.45  
Azilroka committed
372 373 374 375
	for Frame, _ in pairs(Frames) do
		MF:MakeMovable(Frame)
	end

Azilroka's avatar
MF  
Azilroka committed
376 377 378 379 380 381 382 383 384 385
	-- Check Forced Loaded AddOns
	for AddOn, Table in pairs(AddOnFrames) do
		if IsAddOnLoaded(AddOn) then
			for Frame in pairs(Table) do
				MF:MakeMovable(Frame)
			end
		end
	end

	MF:RegisterEvent('ADDON_LOADED')
386
end