#pragma once

#include "dllinterface.h"
#include "menu.h"
#include "label.h"
#include "input.h"

class GAMEGUI_API Console : public Menu
{
	bool	m_bOpen;
	LList<XString> m_Commands;
	LList< ListElement<GUIElement> >  m_Lines;
	Input*	m_InputLine;
	XString	m_Tag;
	BYTE	m_Key;
	float	m_OpenSpeed;
	float	m_Height;
	int		m_OutputLines;
	int		m_CommandIndex;

	float	m_Opacity;
	D3DXCOLOR m_BackColor;

	void AlignLines(void);
	Label* AddLine(void);
	void DeleteTopLine(void);

	void ProcessInput(const XString &inp);
	void PrintLine(const XString &line);

public:
	Console(MenuManager*manager);
	virtual ~Console(void);

	void Print(XString txt);

	virtual void OnKeyPress(BYTE key);
	virtual void OnUpdate(void);
	virtual void OnDraw(void);

	virtual void OnCommand(XString Command,XString args[],int argcnt){}

	void Open(void){m_bOpen = true;}
	void Close(void){m_bOpen = false;}
	void ToggleOpen(void){m_bOpen = m_bOpen?false:true;}
	bool IsOpen(void){return m_bOpen;}

	void SetCommandTag(XString tag);
	XString GetCommandTag(void){return m_Tag;}

	void SetAccessKey(BYTE key){m_Key = key;}
	BYTE GetAccessKey(void){return m_Key;}

	void SetFont(Font*font);
	Font*GetFont(void){return m_InputLine->GetFont();}

	void SetOutputLines(int lc);
	int GetOutputLines(void){return m_OutputLines;}

	void SetOpenSpeed(float os){m_OpenSpeed = os;}
	float GetOpenSpeed(void){return m_OpenSpeed;}

	void SetHeight(float height){m_Height = height;}
	float GetHeight(void){return m_Height;}

	void SetTextColor(D3DXCOLOR color);
	D3DXCOLOR GetTextColor(void){return m_InputLine->GetTextColor();}

	void SetBackColor(D3DXCOLOR backcolor){m_BackColor = backcolor;}
	D3DXCOLOR GetBackColor(void){return m_BackColor;}

	void SetOpacity(float opacity){m_Opacity = opacity;}
	float GetOpacity(void){return m_Opacity;}
};
