void GameGui::LoadGui(BuildingManager& manager)
{
	// more gross allegro config file stuff
	// it might be fine to just hardcode this stuff

	auto buildingMenu = new Gwen::Controls::TabControl(m_canvas.get(), "Buildings");
	buildingMenu->SetBounds(SCREEN_WIDTH - 262 - 150,SCREEN_HEIGHT - 135,262,135);

	auto mapBox = new Gwen::Controls::ImagePanel(m_canvas.get(), "Map");
	mapBox->SetBounds(SCREEN_WIDTH - 150, SCREEN_HEIGHT - 150, 150, 150);

	ALLEGRO_CONFIG *uiConfig = al_load_config_file("ui/building_ui.cfg");

	ALLEGRO_CONFIG_SECTION *iter;
	// this first section is the 'global' section, we ignore it
	const char * cfgSection = al_get_first_config_section(uiConfig, &iter);

	const char * cfgEntry;
	ALLEGRO_CONFIG_ENTRY *eIter;

	// load tab pages from building_ui.cfg
	while(true)
	{
		cfgSection = al_get_next_config_section(&iter);

		// did we pass by the last section in the file?
		if(!cfgSection)
			break;

		auto section = std::string(cfgSection);
		Gwen::Controls::TabButton* resExtractors = buildingMenu->AddPage(section);

		cfgEntry = al_get_first_config_entry(uiConfig, cfgSection, &eIter);
		for(int i = 0; cfgEntry; i++)
		{
			auto entry = std::string(cfgEntry);
			CommandButton* but;
			if (section == "Terraform")
				but = CommandButton::CreateTerraformButton(resExtractors->GetPage());
			else if (section == "Transportation")
				but = CommandButton::CreatePathwayButton(resExtractors->GetPage());
			else
				but = CommandButton::CreateBuildingButton(resExtractors->GetPage(), manager.GetTemplateByName(entry));

			but->SetImage(al_get_config_value(uiConfig, cfgSection, cfgEntry));
			but->SetToolTip(cfgEntry);
			but->SetShouldDrawBackground(false);
			but->SetBounds((i/2) * 50, 0, 50, 50);
			but->onPress.Add(&m_iHandler, &InputHandler::OnBuildingButton);
			if(i%2)
				but->SetPos((i/2) * 50, 52);

			cfgEntry = al_get_next_config_entry(&eIter);
		}
	}

	al_destroy_config(uiConfig);
}
void	GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* renderer,float retinaScale)
{
	m_data->m_curYposition = 20;
	//m_data->m_primRenderer = new GLPrimitiveRenderer(width,height);
	m_data->pRenderer = renderer;//new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale);

	m_data->skin.SetRender( m_data->pRenderer );
	

	m_data->pCanvas= new Gwen::Controls::Canvas( &m_data->skin );
	m_data->pCanvas->SetSize( width,height);
	m_data->pCanvas->SetDrawBackground( false);
	m_data->pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
	
	
	
	MyTestMenuBar* menubar = new MyTestMenuBar(m_data->pCanvas);
	m_data->m_viewMenu = menubar->m_viewMenu;
    m_data->m_menuItems = menubar->m_menuItems;
	m_data->m_menubar = menubar;
	
	
    
	Gwen::Controls::StatusBar* bar = new Gwen::Controls::StatusBar(m_data->pCanvas);
	m_data->m_bar = bar;
	

	m_data->m_rightStatusBar = new Gwen::Controls::Label( bar );
	
	m_data->m_rightStatusBar->SetWidth(width/2);
	//m_data->m_rightStatusBar->SetText( L"Label Added to Right" );
	bar->AddControl( m_data->m_rightStatusBar, true );
	
	m_data->m_TextOutput = new Gwen::Controls::ListBox( m_data->pCanvas );
	
	m_data->m_TextOutput->Dock( Gwen::Pos::Bottom );
	m_data->m_TextOutput->SetHeight( 100 );
	
	m_data->m_leftStatusBar = new Gwen::Controls::Label( bar );
	
	//m_data->m_leftStatusBar->SetText( L"Label Added to Left" );
	m_data->m_leftStatusBar->SetWidth(width/2);
	bar->AddControl( m_data->m_leftStatusBar,false);
	
	//Gwen::KeyboardFocus
	/*Gwen::Controls::GroupBox* box = new Gwen::Controls::GroupBox(m_data->pCanvas);
	box->SetText("text");
	box->SetName("name");
	box->SetHeight(500);
	*/
	Gwen::Controls::ScrollControl* windowRight= new Gwen::Controls::ScrollControl(m_data->pCanvas);
	windowRight->Dock(Gwen::Pos::Right);
	windowRight->SetWidth(250);
	windowRight->SetHeight(250);
	windowRight->SetScroll(false,true);
	m_data->m_windowRight = windowRight;


	//windowLeft->SetSkin(
	Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowRight);
	m_data->m_tab = tab;

	

	//tab->SetHeight(300);
	tab->SetWidth(240);
	tab->SetHeight(1250);
	//tab->Dock(Gwen::Pos::Left);
	tab->Dock( Gwen::Pos::Fill );
	//tab->SetMargin( Gwen::Margin( 2, 2, 2, 2 ) );

	Gwen::UnicodeString str1(L"Params");
	m_data->m_demoPage = tab->AddPage(str1);
	
	



//	Gwen::UnicodeString str2(L"OpenCL");
//	tab->AddPage(str2);
	//Gwen::UnicodeString str3(L"page3");
//	tab->AddPage(str3);



	//but->onPress.Add(handler, &MyHander::onButtonA);



	//box->Dock(Gwen::Pos::Left);

	/*Gwen::Controls::WindowControl* windowBottom = new Gwen::Controls::WindowControl(m_data->pCanvas);
	windowBottom->SetHeight(100);
	windowBottom->Dock(Gwen::Pos::Bottom);
	windowBottom->SetTitle("bottom");
	*/
//	Gwen::Controls::Property::Text* prop = new Gwen::Controls::Property::Text(m_data->pCanvas);
	//prop->Dock(Gwen::Pos::Bottom);
	/*Gwen::Controls::SplitterBar* split = new Gwen::Controls::SplitterBar(m_data->pCanvas);
	split->Dock(Gwen::Pos::Center);
	split->SetHeight(300);
	split->SetWidth(300);
	*/
	/*


	*/

	Gwen::Controls::ScrollControl* windowLeft = new Gwen::Controls::ScrollControl(m_data->pCanvas);
	windowLeft->Dock(Gwen::Pos::Left);
	//	windowLeft->SetTitle("title");
	windowLeft->SetScroll(false, false);
	windowLeft->SetWidth(250);
	windowLeft->SetPos(50, 50);
	windowLeft->SetHeight(500);
	//windowLeft->SetClosable(false);
	//	windowLeft->SetShouldDrawBackground(true);
	windowLeft->SetTabable(true);
	
	Gwen::Controls::TabControl* explorerTab = new Gwen::Controls::TabControl(windowLeft);

	//tab->SetHeight(300);
//	explorerTab->SetWidth(230);
	explorerTab->SetHeight(250);
	//tab->Dock(Gwen::Pos::Left);
	explorerTab->Dock(Gwen::Pos::Fill);

	



	//m_data->m_exampleInfoTextOutput->SetBounds(2, 10, 236, 400);

	//windowRight

	Gwen::UnicodeString explorerStr1(L"Explorer");
	m_data->m_explorerPage = explorerTab->AddPage(explorerStr1);
	Gwen::UnicodeString shapesStr1(L"Test");
	Gwen::Controls::TabButton* shapes = explorerTab->AddPage(shapesStr1);

	///todo(erwincoumans) figure out why the HSV color picker is extremely slow
	//Gwen::Controls::HSVColorPicker* color = new Gwen::Controls::HSVColorPicker(shapes->GetPage());
	Gwen::Controls::ColorPicker* color = new Gwen::Controls::ColorPicker(shapes->GetPage());
	color->SetKeyboardInputEnabled(true);
	
	Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(m_data->m_explorerPage->GetPage());
	m_data->m_explorerTreeCtrl = ctrl;
	ctrl->SetKeyboardInputEnabled(true);
	ctrl->Focus();
	ctrl->SetBounds(2, 10, 236, 300);

	m_data->m_exampleInfoGroupBox = new Gwen::Controls::Label( m_data->m_explorerPage->GetPage() );
	m_data->m_exampleInfoGroupBox->SetPos(2, 314);
	m_data->m_exampleInfoGroupBox->SetHeight( 15 );
	m_data->m_exampleInfoGroupBox->SetWidth(234);
	m_data->m_exampleInfoGroupBox->SetText("Example Description");

	m_data->m_exampleInfoTextOutput = new Gwen::Controls::ListBox(m_data->m_explorerPage->GetPage());

	//m_data->m_exampleInfoTextOutput->Dock( Gwen::Pos::Bottom );
	m_data->m_exampleInfoTextOutput->SetPos(2, 332);
	m_data->m_exampleInfoTextOutput->SetHeight( 150 );
	m_data->m_exampleInfoTextOutput->SetWidth(233);
	

   
}