--[[
	Bagnon
		Displays the player's inventory in a single frame
--]]

--[[ 
	Loading Functions
--]]

function Bagnon_OnLoad()
	this:RegisterEvent("ADDON_LOADED");
end

--[[
	Event Handler
--]]

function Bagnon_OnEvent(event)
	if ( event == "BANKFRAME_OPENED") then
		BagnonCore_Open("Bagnon");
	elseif ( event == "ADDON_LOADED" and arg1 == "Bagnon") then
		this:UnregisterEvent("ADDON_LOADED");
		Bagnon_Load();
	end
end

function Bagnon_Load()
	BagnonCore_LoadSettings(Bagnon, {0, 1, 2, 3, 4}, 164, "Inventory");
	this:RegisterEvent("BANKFRAME_OPENED");
end

--[[
	UI Functions
--]]

--OnShow
function Bagnon_OnShow()
	MainMenuBarBackpackButton:SetChecked(1);
	PlaySound("igBackPackOpen");
end

--OnHide
function Bagnon_OnHide()
	MainMenuBarBackpackButton:SetChecked(0);
	PlaySound("igBackPackClose");
end

--Show Bags

function Bagnon_ToggleBags()
	if( not BagnonBags:IsShown() ) then
		BagnonBags:Show();
		this:SetText("Hide Bags");
	else
		BagnonBags:Hide();
		this:SetText("Show Bags");
	end
	
	BagnonCore_TrimToSize(Bagnon);
end