
--===================================================
--									
--										GHI Main
--									ghi_main.lua
--
--								Main setup file
--	
-- 						(c)2011 The Gryphonheart Team
--								All rights reservated
--===================================================	

local slashCmd,ghiPing,trade;

local function SetUpOnGHILoaded()

	-- remember, only set up the classes that are really needed to run all the time

	slashCmd = GHI_SlashCmd("GHI"); -- need to run to listen for chat commands
	ghiPing = GHI_Ping(); -- needs to run to reply to other pings
	
	slashCmd.SetDefaultFunc(function(x) GHI_ToggleBackpack(); end);
	slashCmd.RegisterSubPrefix("ping",ghiPing.SendPing);
	slashCmd.RegisterSubPrefix("reload",function(x) GHI_ReloadUI() end);
	
end

local function SetUpOnTradeFrameShown()
	trade = GHI_Trade();
end


-- Let SetUp run when GHI is loaded
local f = CreateFrame("frame");
f:SetScript("OnEvent",function(self,event,addon) -- These events should later on be set up by calling an event handler class
	if event == "ADDON_LOADED" then
		if addon == "GHI" then SetUpOnGHILoaded(); end
	elseif event == "TRADE_SHOW" then
		SetUpOnTradeFrameShown()
	end
end);
f:RegisterEvent("ADDON_LOADED");
f:RegisterEvent("TRADE_SHOW");









