--[[
	Bagnon_Menu
		Functions for the dropdown menu for Bagnon_Forever
	
	Essentially the dropdown is used to switch between the inventory of other characters
	Why not use a normal dropdown?  It takes a lot of memory
--]]

local MAX_BUTTONS = 10;

--[[ Dropdown Menus --]]--

function BagnonForeverMenu_Show(frame)
	BagnonForeverMenu.frame = frame;
	
	--update button info
	local button, player;
	local index = 0;
		
	
	for player in BagnonItems[GetRealmName()] do
		index = index + 1;
			
		button = getglobal("BagnonForeverMenu" .. index);
		button:SetText(player);
			
		if(frame.player == player) then
			button:SetChecked(true);
			button:Show();
		else
			button:SetChecked(false);
		end
	end
		
	local i;
	for i = index + 1, MAX_BUTTONS, 1 do
		getglobal("BagnonForeverMenu" .. i):Hide();
	end
		
	
	--resize and position the frame
	BagnonForeverMenu:SetHeight(38 + index * 20);
	local x, y = GetCursorPosition();
	x = x / UIParent:GetScale();
	y = y / UIParent:GetScale();

	BagnonForeverMenu:ClearAllPoints();
	Infield_Place(BagnonForeverMenu, "TOPLEFT", UIParent, "BOTTOMLEFT", x, y);
	BagnonForeverMenu:Show();
	BagnonForeverMenu:SetParent(frame);
end


function BagnonForeverMenu_ChangeCharacter(character)
	local frame = this:GetParent().frame;
	local frameTitle = getglobal(frame:GetName() .. "Title");
	
	frameTitle:SetText(string.gsub(frameTitle:GetText(), frame.player, character) );
	frame.player = character
	BagnonCore_GenerateFrame(frame);
	this:GetParent():Hide();
end