Example #1
0
/***********************************************************
resize inventory
***********************************************************/
void ContainerBox::ResizeInventory(int newsize)
{
	if(_inventory_size == newsize)
		return;

	_inventory_size = newsize;
	for(size_t i=0; i<_inv_boxes.size(); ++i)
		_inv_boxes[i]->destroy();

	_inv_boxes.clear();


	CEGUI::Window*	pane = CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/InvScrollable");
	CEGUI::Window*	tmpwindow;
	for(int i=0; i<_inventory_size; ++i)
	{
		int x = i / 4;
		int y = i % 4;

		tmpwindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText");
		tmpwindow->setArea(CEGUI::UDim(0,5+((float)_boxsize+2)*y), CEGUI::UDim(0,5+((float)_boxsize+2.0f)*x),
							CEGUI::UDim(0, (float)_boxsize), CEGUI::UDim(0, (float)_boxsize));
		pane->addChildWindow(tmpwindow);

        tmpwindow->subscribeEvent(
					CEGUI::Window::EventDragDropItemDropped,
					CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInInventory, this));

		tmpwindow->setID(i);
		_inv_boxes.push_back(tmpwindow);
	}

	CleanInventory();
}
Example #2
0
void PromptBox::SetLabel(const CEGUI::String& text)
{
	OC_CEGUI_TRY;
	{
		CEGUI::Window* messageText = mPromptBox->getChild(mPromptBox->getName() + "/MessageText");
		CEGUI::Window* editbox = mPromptBox->getChild(mPromptBox->getName() + "/Editbox");
		const float32 offset = 10;
		float32 buttonHeight = mPromptBox->getChild(mPromptBox->getName() + "/ButtonOK")->getPixelSize().d_height;
		float32 editboxHeight = editbox->getPixelSize().d_height;
	
		messageText->setText(text);
		float32 textWidth = StringConverter::FromString<float32>(messageText->getProperty("HorzExtent").c_str());
		float32 textHeight = StringConverter::FromString<float32>(messageText->getProperty("VertExtent").c_str());

		editbox->subscribeEvent(CEGUI::Editbox::EventKeyDown, CEGUI::Event::Subscriber(&PromptBox::OnEditboxKeyDown, this));

		messageText->setArea(CEGUI::UDim(0,offset), CEGUI::UDim(0,0), CEGUI::UDim(1, -2.0f*offset), CEGUI::UDim(1, -buttonHeight-editboxHeight - offset));
		mPromptBox->setWidth(CEGUI::UDim(0, textWidth + 2.0f*offset + INNER_FRAME_OFFSET));
		mPromptBox->setHeight(CEGUI::UDim(0, textHeight + buttonHeight + editboxHeight + offset + INNER_FRAME_OFFSET));
		mPromptBox->setXPosition(CEGUI::UDim(0.5f, -0.5f*mPromptBox->getPixelSize().d_width));
		mPromptBox->setYPosition(CEGUI::UDim(0.5f, -0.5f*mPromptBox->getPixelSize().d_height));

		EnsureWindowIsWideEnough();
	}
	OC_CEGUI_CATCH;
}
Example #3
0
void MessageBox::SetText(const CEGUI::String& text)
{
	CEGUI::Window* messageText = mMessageBox->getChild(mMessageBox->getName() + "/MessageText");
	const float32 offset = 10;
	float32 buttonHeight = mMessageBox->getChild(mMessageBox->getName() + "/ButtonOK")->getPixelSize().d_height;
	messageText->setText(text);
	float32 textWidth = StringConverter::FromString<float32>(messageText->getProperty("HorzExtent").c_str());
	float32 textHeight = StringConverter::FromString<float32>(messageText->getProperty("VertExtent").c_str());

	messageText->setArea(CEGUI::UDim(0,offset), CEGUI::UDim(0,0), CEGUI::UDim(1, -2.0f*offset), CEGUI::UDim(1, -buttonHeight-offset));
	mMessageBox->setWidth(CEGUI::UDim(0, textWidth + 2.0f*offset + INNER_FRAME_OFFSET));
	mMessageBox->setHeight(CEGUI::UDim(0, textHeight + buttonHeight + offset + INNER_FRAME_OFFSET));
	mMessageBox->setXPosition(CEGUI::UDim(0.5f, -0.5f*mMessageBox->getPixelSize().d_width));
	mMessageBox->setYPosition(CEGUI::UDim(0.5f, -0.5f*mMessageBox->getPixelSize().d_height));

	EnsureWindowIsWideEnough();
}
Example #4
0
	void ArrayEditor<ElementType>::SetupWidget(Model* model)
	{
		// Set dimensions
		CEGUI::UDim dimLeft = model->IsShareable() ? cegui_absdim(16) : cegui_absdim(0);

		// Setup label widget
		CEGUI::Window* labelWidget = mHeaderWidget->getChildAtIdx(0);
		labelWidget->setArea(CEGUI::URect(dimLeft, cegui_absdim(0), CEGUI::UDim(0.5f, -2), cegui_reldim(1)));
		labelWidget->setText(utf8StringToCEGUI(model->GetName()));
		labelWidget->setTooltipText(model->GetTooltip());

		// Setup buttons
		if (model->IsReadOnly())
		{
			mButtonAddElement->setEnabled(false);
			mButtonSave->setEnabled(false);
			mButtonRevert->setEnabled(false);
		}
		else
		{
			mButtonAddElement->setEnabled(true);
			mButtonSave->setEnabled(false);
			mButtonRevert->setEnabled(false);
		}
		
		// Setup is-shared checkbox
		CEGUI::Checkbox* isSharedCheckbox = static_cast<CEGUI::Checkbox*>(mHeaderWidget->getChildAtIdx(4));
		if (model->IsShareable())
		{
			isSharedCheckbox->setVisible(true);
			isSharedCheckbox->setPosition(CEGUI::UVector2(cegui_absdim(0), cegui_absdim(0)));
			isSharedCheckbox->setSelected(model->IsShared());
		}
		else
		{
			isSharedCheckbox->setVisible(false);
		}

		// Setup body widget
		mEditorWidget->getChildAtIdx(1)->setHeight(cegui_absdim(0));
		mBodyLayout->Clear();
	}
Example #5
0
/***********************************************************
initalize the box
***********************************************************/
void ContainerBox::Initialize(CEGUI::Window* Root)
{
	try
	{
		_myBox = CEGUI::WindowManager::getSingleton().loadWindowLayout( "container.layout" );
		Root->addChildWindow(_myBox);


		CEGUI::FrameWindow * frw = static_cast<CEGUI::FrameWindow *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame"));
		frw->subscribeEvent (
			CEGUI::FrameWindow::EventCloseClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleCancel, this));


		static_cast<CEGUI::PushButton *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/OK"))->subscribeEvent (
			CEGUI::PushButton::EventClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleOk, this));

		static_cast<CEGUI::PushButton *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/TakeAll"))->subscribeEvent (
			CEGUI::PushButton::EventClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleTakeAll, this));

		static_cast<CEGUI::PushButton *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/Cancel"))->subscribeEvent (
			CEGUI::PushButton::EventClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleCancel, this));


		CEGUI::Window*	pane = CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/ConScrollable");
		CEGUI::Window*	tmpwindow;
		for(int i=0; i<_NB_BOX_CONTAINER_; ++i)
		{
			int x = i / 3;
			int y = i % 3;

			tmpwindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText");
			tmpwindow->setArea(CEGUI::UDim(0,5+((float)_boxsize+2)*y), CEGUI::UDim(0,5+((float)_boxsize+2)*x), 
								CEGUI::UDim(0, (float)_boxsize), CEGUI::UDim(0, (float)_boxsize));
			pane->addChildWindow(tmpwindow);

			tmpwindow->subscribeEvent(
						CEGUI::Window::EventDragDropItemDropped,
						CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInContainer, this));

			tmpwindow->setID(i);
			_cont_boxes.push_back(tmpwindow);
		}



		frw->show();
		_myBox->hide();

		frw->subscribeEvent(CEGUI::Window::EventKeyDown,
			CEGUI::Event::Subscriber (&ContainerBox::HandleEnterKey, this));
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init ContainerBox: ") + ex.getMessage().c_str());
	}
}
Example #6
0
/***********************************************************
add an item inside the container
***********************************************************/
std::pair<CEGUI::Window*, CEGUI::Window*> ContainerBox::AddInventoryItem(long Id, int number, 
																		 CEGUI::Window* parent, 
																		bool tocontainer)
{
	CEGUI::Window*	tmp = CEGUI::WindowManager::getSingleton().createWindow("DragContainer");
	tmp->setArea(CEGUI::UDim(0,0), CEGUI::UDim(0,0), CEGUI::UDim(1, 0), CEGUI::UDim(1, 0));
	tmp->setID(Id);

	CEGUI::Window*	tmp2 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage");
	tmp2->setArea(CEGUI::UDim(0,5.0f), CEGUI::UDim(0,12.0f), CEGUI::UDim(0, (float)_boxsize-10.0f), CEGUI::UDim(0, (float)_boxsize-20.0f));

	std::string imagesetname = ImageSetHandler::GetInstance()->GetInventoryImage(Id);
	tmp2->setProperty("Image", "set:" + imagesetname + " image:full_image");
	tmp2->setProperty("MousePassThroughEnabled", "True");



	CEGUI::Window*	tmp3 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText");
	tmp3->setArea(CEGUI::UDim(0,2), CEGUI::UDim(0,4), CEGUI::UDim(1, -1), CEGUI::UDim(0, 14));
	tmp3->setProperty("FrameEnabled", "False");
	tmp3->setProperty("BackgroundEnabled", "False");
	tmp3->setProperty("MousePassThroughEnabled", "True");
	tmp3->setAlwaysOnTop(true);
	tmp3->setProperty("Font" , "contourfont");

	std::stringstream strs;
	strs<<number;
	tmp3->setText(strs.str().c_str());
	if(tocontainer)
		tmp3->setID(3);
	else
		tmp3->setID(2);


	CEGUI::String tmpstr((const unsigned char *)InventoryHandler::getInstance()->GetItemDescription(Id).c_str());
	tmp->setProperty("Tooltip", tmpstr);
	tmp->addChildWindow(tmp2);
	tmp->addChildWindow(tmp3);
	parent->addChildWindow(tmp);


    tmp->subscribeEvent(
		CEGUI::Window::EventMouseEnters,
				CEGUI::Event::Subscriber(&ContainerBox::HandleInventoryEnter, this));


	if(tocontainer)
	{
		tmp->subscribeEvent(
					CEGUI::Window::EventDragDropItemDropped,
					CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInContainerItem, this));
	
		tmp->subscribeEvent (CEGUI::Window::EventMouseClick,
								CEGUI::Event::Subscriber (&ContainerBox::HandleContainerItemClicked, this));
	}
	else
	{
		tmp->subscribeEvent(
					CEGUI::Window::EventDragDropItemDropped,
					CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInInventoryItem, this));
	
		tmp->subscribeEvent (CEGUI::Window::EventMouseClick,
								CEGUI::Event::Subscriber (&ContainerBox::HandleInventoryItemClicked, this));
	}


	return std::make_pair<CEGUI::Window*, CEGUI::Window*>(tmp, tmp3);
}
//nikai 2010.9.3
void SelectionMover::AlignSpaceBetween(int PaddingValue, const PaddingAlign al)
{
    // Validations
    wxASSERT_MSG(m_selection != NULL, wxT("Selection member is NULL"));

    if(m_selection->Size() <= 1) 
    {
        // Should not happen because of the disabled menu/toolbar item in this case
        LogWarning(wxT("You must select more than one window to align!"));
        return;
    }
    // The first selected window is the one to match. This is for example how Visual Studio's 
    // dialog editor works as well.
    Selection::Boxes::iterator boxIt = m_selection->GetMoveableBoxes().begin();

    const CEGUI::Window *current = boxIt->GetWindow();
            
    CEGUI::Window *pParentWin = current->getParent();
    if(NULL == pParentWin)
    {
        LogWarning(wxT("You can't operate the root window!"));
        wxMessageBox(L"You can't operate the root window!");
        return;
    }
    const long ParentX = CEGUI::CoordConverter::windowToScreenX(*pParentWin,0);
    const long ParentY = CEGUI::CoordConverter::windowToScreenY(*pParentWin,0);
    const long parentWidth = pParentWin->getPixelSize().d_width;
    const long parentHeight = pParentWin->getPixelSize().d_height;

    const CEGUI::URect rect = current->getArea();
    ++boxIt;
    
    for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt) {
        // Deny when it is blocked
        if (boxIt->IsLocked())
        {
            wxMessageBox(L"all the select window ¡¯s can't be locked£¡");
            return;
        }
        CEGUI::Window* curWin = boxIt->GetWindow();
        if (pParentWin != curWin->getParent())
        {
            wxMessageBox(L"all the select window ¡¯s parent must be same£¡");
            return;
        }
    }
    //»Ö¸´µü´úÆ÷λÖÃ
    //boxIt = m_selection->GetMoveableBoxes().begin(); 
    //++boxIt;
    //float lWidth  = current->getPixelSize().d_width;
    //float lHeight = current->getPixelSize().d_height;
    //float RightPos = CEGUI::CoordConverter::windowToScreenX(*current,0)+lWidth;
    //float BottomPos = CEGUI::CoordConverter::windowToScreenY(*current,0)+lHeight;
    //
    //for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt)
    //{
    //    CEGUI::Window* curWin = boxIt->GetWindow();
    //    CEGUI::UDim xPos = curWin->getXPosition();
    //    CEGUI::UDim yPos = curWin->getYPosition();
    //    switch(al)
    //    {
    //    case HorzPadding:
    //        {
    //            float newXPixel = RightPos + PaddingValue;
    //            float xscale = (newXPixel-ParentX)/parentWidth;
    //            xPos = CEGUI::UDim(xscale,0);
    //            break;
    //        }
    //    case VertPadding:
    //        {
    //            float newYPixel = BottomPos + PaddingValue;
    //            float yscale = (newYPixel-ParentY)/parentHeight;
    //            yPos = CEGUI::UDim(yscale,0);
    //            break;
    //        }
    //    default:
    //        LogError(wxT("SelectionMover::AlignSelection - Unrecognized align option (%d)"), al);
    //        return;
    //    }
    //    curWin->setPosition(CEGUI::UVector2(xPos,yPos));
    //    lWidth  = curWin->getPixelSize().d_width;
    //    lHeight = curWin->getPixelSize().d_height;
    //    RightPos = CEGUI::CoordConverter::windowToScreenX(*curWin,0)+lWidth;
    //    BottomPos = CEGUI::CoordConverter::windowToScreenY(*curWin,0)+lHeight;
    //}
    //// Request for a repaint
    //wxGetApp().GetMainFrame()->Refresh();
    boxIt = m_selection->GetMoveableBoxes().begin(); 
    ++boxIt;
    float newPixelWidth  = current->getPixelSize().d_width;
    float newPixelHeight = current->getPixelSize().d_height;
    float RightPos = CEGUI::CoordConverter::windowToScreenX(*current,0)+newPixelWidth;
    float BottomPos = CEGUI::CoordConverter::windowToScreenY(*current,0)+newPixelHeight;

    for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt)
    {
        CEGUI::Window* curWin = boxIt->GetWindow();
        float fLeft = CEGUI::CoordConverter::windowToScreenX(*curWin,0);
        float fTop  = CEGUI::CoordConverter::windowToScreenY(*curWin,0);
        newPixelWidth  = curWin->getPixelSize().d_width;
        newPixelHeight = curWin->getPixelSize().d_height;
        float fRight  = fLeft  + newPixelWidth;
        float fBottom = fTop + newPixelHeight;

        CEGUI::URect newWindowArea = curWin->getArea();
        float sLeft = 0.0f,sTop = 0.0f,sRight = 0.0f, sBottom = 0.0f;
        switch(al)
        {
        case HorzPadding:
            {
                float newXPixel = RightPos + PaddingValue;
                sRight = sLeft = newXPixel - fLeft;
                break;
            }
        case VertPadding:
            {
                float newYPixel = BottomPos + PaddingValue;
                sBottom = sTop = newYPixel - fTop;
                break;
            }
        default:
            LogError(wxT("SelectionMover::AlignSelection - Unrecognized align option (%d)"), al);
            return;
        }

        MoveUsingScale(curWin,newWindowArea,sLeft,sTop,sRight,sBottom);
        curWin->setArea(newWindowArea);
        fLeft = CEGUI::CoordConverter::windowToScreenX(*curWin,0);
        fTop  = CEGUI::CoordConverter::windowToScreenY(*curWin,0);
        RightPos  = fLeft + newPixelWidth;
        BottomPos = fTop  + newPixelHeight;
    }
    // Request for a repaint
    wxGetApp().GetMainFrame()->Refresh();
}
Example #8
0
	void ArrayEditor<ElementType>::InitWidget()
	{
		static unsigned int editorCounter = 0;
		OC_DASSERT(mEditorWidget == 0);

		CEGUI::String editorName = "Editor/EntityWindow/ValueEditors/ArrayEditor" + string(Reflection::PropertyTypes::GetStringName(Reflection::PropertyTypes::GetTypeID<ElementType>())) +  Utils::StringConverter::ToString(editorCounter++);
		
		// Create main editor widget
		mEditorWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName);
		mMainLayout = new GUISystem::VerticalLayout(mEditorWidget, 0, true);
		
		// Create header widget
		mHeaderWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName + "/Header");
		mHeaderWidget->setHeight(CEGUI::UDim(0, GetEditboxHeight()));
		mMainLayout->AddChildWindow(mHeaderWidget);

		// Create label widget
		CEGUI::Window* labelWidget = this->CreateLabelWidget(editorName + "/Header/Label");
		labelWidget->setArea(CEGUI::URect(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0), CEGUI::UDim(0.5f, -2), CEGUI::UDim(0, GetEditboxHeight())));
		mHeaderWidget->addChildWindow(labelWidget);

		// Create add element button
		mButtonAddElement = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/AddElementButton"));
		mButtonAddElement->setProperty("NormalImage", "set:EditorToolbar image:btnAddNormal");
		mButtonAddElement->setProperty("HoverImage", "set:EditorToolbar image:btnAddHover");
		mButtonAddElement->setProperty("PushedImage", "set:EditorToolbar image:btnAddPushed");
		mButtonAddElement->setProperty("DisabledImage", "set:EditorToolbar image:btnAddDisabled");
		mButtonAddElement->setWantsMultiClickEvents(false);
		mButtonAddElement->setTooltipText(TR("entity_editor_add_hint"));
		mButtonAddElement->setVisible(true);
		mButtonAddElement->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24)));
		mButtonAddElement->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -80), CEGUI::UDim(0, 0)));
		mButtonAddElement->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonAddPressed, this));
		mHeaderWidget->addChildWindow(mButtonAddElement);

		// Create revert button
		mButtonRevert = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/RevertButton"));
		mButtonRevert->setProperty("NormalImage", "set:EditorToolbar image:btnCancelNormal");
		mButtonRevert->setProperty("HoverImage", "set:EditorToolbar image:btnCancelHover");
		mButtonRevert->setProperty("PushedImage", "set:EditorToolbar image:btnCancelPushed");
		mButtonRevert->setProperty("DisabledImage", "set:EditorToolbar image:btnCancelDisabled");
		mButtonRevert->setWantsMultiClickEvents(false);
		mButtonRevert->setTooltipText(TR("entity_editor_revert_hint"));
		mButtonRevert->setVisible(true);
		mButtonRevert->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24)));
		mButtonRevert->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -52), CEGUI::UDim(0, 0)));
		mButtonRevert->setEnabled(false);
		mButtonRevert->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonRevertPressed, this));
		mHeaderWidget->addChildWindow(mButtonRevert);

		// Create save button
		mButtonSave = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/SaveButton"));
		mButtonSave->setProperty("NormalImage", "set:EditorToolbar image:btnSaveNormal");
		mButtonSave->setProperty("HoverImage", "set:EditorToolbar image:btnSaveHover");
		mButtonSave->setProperty("PushedImage", "set:EditorToolbar image:btnSavePushed");
		mButtonSave->setProperty("DisabledImage", "set:EditorToolbar image:btnSaveDisabled");
		mButtonSave->setWantsMultiClickEvents(false);
		mButtonSave->setTooltipText(TR("entity_editor_save_hint"));
		mButtonSave->setVisible(true);
		mButtonSave->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24)));
		mButtonSave->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -24), CEGUI::UDim(0, 0)));
		mButtonSave->setEnabled(false);
		mButtonSave->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonSavePressed, this));
		mHeaderWidget->addChildWindow(mButtonSave);

		// Create is-shared checkbox
		CEGUI::Checkbox* isSharedCheckbox = CreateIsSharedCheckboxWidget(editorName + "/Header/IsSharedCheckbox");
		isSharedCheckbox->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
		isSharedCheckbox->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged, CEGUI::Event::Subscriber(&ArrayEditor::OnEventIsSharedCheckboxChanged, this));
		mHeaderWidget->addChildWindow(isSharedCheckbox);

		// Create body widget
		CEGUI::Window* bodyWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName + "/Body");
		mBodyLayout = new GUISystem::VerticalLayout(bodyWidget, 0, true);
		mMainLayout->AddChildWindow(bodyWidget);
	}
Example #9
0
void Application::setupCEGUI(void) {

	mRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*mRenderWindow);
	CEGUI::ImageManager::setImagesetDefaultResourceGroup("Imagesets");
	CEGUI::Font::setDefaultResourceGroup("Fonts");
	CEGUI::Scheme::setDefaultResourceGroup("Schemes");
	CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
	CEGUI::WindowManager::setDefaultResourceGroup("Layouts");

	CEGUI::SchemeManager::getSingleton().createFromFile("AlfiskoSkin.scheme");
	CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("AlfiskoSkin/MouseArrow");

	CEGUI::FontManager &fmg = CEGUI::FontManager::getSingleton();
	CEGUI::Font &font = fmg.createFreeTypeFont("arial", 20, true, "arial.ttf");
	
	CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
	CEGUI::Window *sheet = wmgr.createWindow("DefaultWindow", "_MasterRoot");
	CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(sheet);

	CEGUI::Window* quitButton = wmgr.createWindow("AlfiskoSkin/Button", "QuitButton");
	quitButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.0f, 0), CEGUI::UDim(0.0f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.1f, 0), CEGUI::UDim(0.05f, 0))));
	quitButton->setText("Quit");

	ipWindow = wmgr.createWindow("AlfiskoSkin/Label", "ipWindow");
	ipWindow->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.92f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(1, 0))));
	ipWindow->setText(netManager->getIPstring());

	singlePlayerButton = wmgr.createWindow("AlfiskoSkin/Button", "SinglePlayerButton");
	singlePlayerButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.35f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(0.4f, 0))));
	singlePlayerButton->setText("Single Player");

	hostServerButton = wmgr.createWindow("AlfiskoSkin/Button", "HostButton");
	hostServerButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.4f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(0.45f, 0))));
	hostServerButton->setText("Host Game");

	ipText = wmgr.createWindow("AlfiskoSkin/Label", "Ip Label");
	ipText->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.525f, 0), CEGUI::UDim(0.45f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.725f, 0), CEGUI::UDim(0.5f, 0))));
	ipText->setText("IP Address");

	ipBox = wmgr.createWindow("AlfiskoSkin/Editbox", "Ip Box");
	ipBox->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.45f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(0.5f, 0))));

	joinServerButton = wmgr.createWindow("AlfiskoSkin/Button", "JoinButton");
	joinServerButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.5f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(0.55f, 0))));
	joinServerButton->setText("Join Game");

	howToButton = wmgr.createWindow("AlfiskoSkin/Button", "HowToButton");
	howToButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.3f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(0.35f, 0))));
	howToButton->setText("How To Play");

	howToText = wmgr.createWindow("AlfiskoSkin/MultiLineEditbox", "Instructions");
	howToText->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.125f, 0), CEGUI::UDim(0.35f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.875f, 0), CEGUI::UDim(0.75f, 0))));
	howToText->setText(instructions);
	static_cast<CEGUI::MultiLineEditbox*>(howToText)->setReadOnly(true);

	homeButton = wmgr.createWindow("AlfiskoSkin/Button", "HomeButton");
	homeButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.1f, 0), CEGUI::UDim(0.0f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.2f, 0), CEGUI::UDim(0.05f, 0))));
	homeButton->setText("Home");

	replayButton = wmgr.createWindow("AlfiskoSkin/Button", "ReplayButton");
	replayButton->setArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.3f, 0), CEGUI::UDim(0.4f, 0)),
		CEGUI::UVector2(CEGUI::UDim(0.7f, 0), CEGUI::UDim(0.45f, 0))));
	replayButton->setText("Watch Replay");

	sheet->addChild(singlePlayerButton);
	sheet->addChild(hostServerButton);
	sheet->addChild(joinServerButton);
	sheet->addChild(quitButton);
	sheet->addChild(ipBox);
	sheet->addChild(ipText);
	sheet->addChild(ipWindow);
	sheet->addChild(homeButton);
	sheet->addChild(replayButton);
	sheet->addChild(howToButton);
	sheet->addChild(howToText);

	replayButton->hide();
	howToText->hide();

	singlePlayerButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::StartSinglePlayer, this));
	hostServerButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::StartServer, this));
	joinServerButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::JoinServer, this));
	quitButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::Quit, this));
	homeButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::Home, this));
	replayButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::Replay, this));
	howToButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::HowTo, this));

}