View Single Post
02-11-11, 02:42 AM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
*grrr* grumbles ..

Okay, lets do this the long way round rofl..

1. Create a folder called nUI_Plugin_CustomMovers in AddOns folder
2. Create a text file in that folder called nUI_Plugin_CustomMovers.toc and paste the following into it

Code:
## Interface: 40000
## Title: nUI: Plugin [|cffeda55fCustom Movers|r]
## Author: Tina Kirby AKA Xrystal (C) 2010/2011 All Rights Reserved
## Notes: Temporary Movers for frames that haven't been added to the nUI movers system yet.
## Version: 1.01.00
## eMail: [email protected]
## RequiredDeps: nUI
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables : MovableFrames
## SavedVariablesPerCharacter:  

nUI_Plugin_CustomMovers.lua
3. Create a text file in that folder called nUI_Plugin_CustomMovers.lua and paste the following into it

Code:
------------------------------------------------------------------------------------
-- Name : nUI_Plugin_CustomMovers                                          
-- Copyright : Tina Kirby AKA Xrystal (C) 2009/2010 All Rights Reserved      
-- Contact : [email protected]                                           
-- Download Sites :                                                          
-- Version : 1.01.00 - New
------------------------------------------------------------------------------------

--[[ Use Addon Wide Data Table ]]--
local addonName,addonData = ...

local f = CreateFrame("Frame","PCM_Frame",UIParent);
f:SetParent(UIParent);
f:SetPoint("CENTER");

-- Savable list of frames we want to be able to move within the nUI interface
MovableFrames = {
	[1] = "TutorialFrameAlertButton", 
	[2] = "PlayerPowerBarAlt",
};

-- Temporary list of frames removed from the above list
backupList = {
};

local function InitialiseList(self)
	for i,v in ipairs(MovableFrames) do
		local f = _G[v];
		local n = v.."_Mover";
		f:SetParent(nil);
		f:SetParent(self);
		f:SetPoint("CENTER");
		nUI_Movers:lockFrame(f,true,n);
	end	
end

local function AddFrameToList(f)
	-- If this isn't a valid frame then don't go any further
	local frame = _G[f];
	if ( not frame ) then return end
	
	DEFAULT_CHAT_FRAME:AddMessage("Adding ", f, " to list of controlled frames");
	tinsert(MovableFrames,f);
end

local function RemoveFrameFromList(f)

	-- Add frame to remove to backupList just in case
	tinsert(backupList,f);
	
	-- Remove frame from movable list
	tremove(MovableFrames,f);
end

local function DisplayList()
	print("Currently controlled frames")
	for i,v in ipairs(MovableFrames) do
		print(v);
	end
end

local function RefreshList()

	-- List of frames that need to be removed
	local removalList = {};
	
	-- Validate contents of list
	for i,v in ipairs(MovableFrames) do
		local f = _G[v];
		if ( not f ) then 
			tinsert(removalList,v);
		end
	end		
	
	-- Remove invalid frames from MovableFrames list
	for i,v in ipairs(removalList) do
		tremove(MovableFrames,v);
	end
	
end

local function ClearList()

	-- Fill Backup List with Movable List contents - just in case
	for i,v in ipairs(MovableFrames) do
		tinsert(backupList,v);
	end			

	-- Empty Movable Frame List
	MovableFrames = {};
	
end

local function RestoreList()

	-- Fill Movable List with Backup List contents
	for i,v in ipairs(backupList) do
		tinsert(MovableFrames,v);
	end			

	-- Empty Backup List
	backupList = {};	
end

local function ToggleMoverFrames(show)
	for i,v in ipairs(MovableFrames) do
		local f = _G[v];
		local n = _G[v.."_Mover"];
		if ( n ) then
			if ( not show ) then
				n:Hide();
			else
				n:Show();
			end
		elseif ( f ) then
			if ( not show ) then
				f:Hide();
			else
				f:Show();
			end
		else
			print(v.."_Mover"," doesn't exist at present");
		end
	end				
end

local function ListCommands()
	DEFAULT_CHAT_FRAME:AddMessage("nUI: Plugin (Custom Movers) slash commands");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm list - List frames currently controlled by this addon");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm show - Shows the display of frames currently controlled by this addon");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm hide - Hides the display of frames currently controlled by this addon");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm add FrameName - Adds FrameName to the controlled list");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm remove FrameName - Removes FrameName from the controlled list");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm clear - Empties the movable frames list entirely");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm restore - Reverts the last clear and remove actions");
	DEFAULT_CHAT_FRAME:AddMessage("/pcm refresh - Removes frames no longer in existence");
end

local function SlashCommands(msg)

	-- Separate msg into argument list
	local args = {};
	for word in string.gmatch(msg,"[^%s]+") do
		table.insert(args,word);
	end
	
	-- Turn command into lower case
	if ( args[1] ) then args[1] = string.lower(args[1]); end

	if ( args[1] == "list" ) then
		DisplayList();
	elseif ( args[1] == "toggle" ) then
		ToggleMoverFrames();
	elseif ( args[1] == "refresh" ) then
		RefreshList();
	elseif ( args[1] == "clear" ) then
		ClearList();
	elseif ( args[1] == "restore" ) then
		RestoreList();
	elseif ( args[1] == "add" and args[2] ~= nil ) then
		AddFrameToList(args[2]);
	elseif ( args[1] == "remove" and args[2] ~= nil ) then
		RemoveFrameFromList(args[2]);
	else
		ListCommands();
	end
	
end

local function InitialiseAddon(self)
	SLASH_PTMCmd1 = '/pcm';
	SlashCmdList['PCMCmd'] = SlashCommands;
	DEFAULT_CHAT_FRAME:AddMessage("nUI: Plugin (Custom Movers) loaded.  Use /pcm to list options available");
end

local function OnEvent(self,event,...)
	local arg1,arg2,arg3,arg4,arg5,arg6 = ...;
	if ( event == "ADDON_LOADED" and arg1 == addonName ) then
		InitialiseAddon(self);
	elseif ( event == "PLAYER_ENTERING_WORLD" ) then		
		InitialiseList(self);
		self:UnregisterEvent(event);
	end
end

--[[ Register the events we want to watch ]]--
f:SetScript( "OnEvent", OnEvent );
f:RegisterEvent( "ADDON_LOADED" );
f:RegisterEvent( "PLAYER_ENTERING_WORLD" );
4. Save the files if you haven't already and log into WoW. You should see the addon listed.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818