コード例 #1
0
	//! Adds a button to the tool bar
	IGUIButton* CGUIToolBar::addButton(SINT32 id, const wchar_t* text, const wchar_t* tooltiptext,
		ITexture* img, ITexture* pressed, bool isPushButton,
		bool useAlphaChannel)
	{
		ButtonX += 3;

		rect<SINT32> rectangle(ButtonX, 2, ButtonX + 1, 3);
		if (img)
		{
			const dimension2du &size = img->getOriginalSize();
			rectangle.LowerRightCorner.x = rectangle.UpperLeftCorner.x + size.Width + 8;
			rectangle.LowerRightCorner.y = rectangle.UpperLeftCorner.y + size.Height + 6;
		}

		if (text)
		{
			IGUISkin* skin = Environment->getSkin();
			IGUIFont * font = skin->getFont(EGDF_BUTTON);
			if (font)
			{
				dimension2d<UINT32> dim = font->getDimension(text);
				if ((SINT32)dim.Width > rectangle.getWidth())
					rectangle.LowerRightCorner.x = rectangle.UpperLeftCorner.x + dim.Width + 8;
				if ((SINT32)dim.Height > rectangle.getHeight())
					rectangle.LowerRightCorner.y = rectangle.UpperLeftCorner.y + dim.Height + 6;
			}
		}

		ButtonX += rectangle.getWidth();

		IGUIButton* button = new CGUIButton(Environment, this, id, rectangle);
		button->drop();

		if (text)
			button->setText(text);

		if (tooltiptext)
			button->setToolTipText(tooltiptext);

		if (img)
			button->setImage(img);

		if (pressed)
			button->setPressedImage(pressed);

		if (isPushButton)
			button->setIsPushButton(isPushButton);

		if (useAlphaChannel)
			button->setUseAlphaChannel(useAlphaChannel);

		return button;
	}
コード例 #2
0
ファイル: Universe.cpp プロジェクト: insolite/RPG
void Universe::ClientGUIInit()
{
	clientEventReceiver = new ClientEventReceiver();
	render->device->setEventReceiver((IEventReceiver*)clientEventReceiver);
	
	int btnsSize = 48;

	//Window toggle buttons
	/*
	IGUIButton* btn;
	btn = guienv->addButton(rect< s32 >(0, render->screenHeight - 32, 64, render->screenHeight), NULL, InventoryToggleButton, L"Inventory", NULL);
	btn->setIsPushButton(true);
	btn = guienv->addButton(rect< s32 >(64, render->screenHeight - 32, 64 + 64, render->screenHeight), NULL, SkillsToggleButton, L"Skills", NULL);
	btn->setIsPushButton(true);
	btn = guienv->addButton(rect< s32 >(64 + 64, render->screenHeight - 32, 64 + 64 + 64, render->screenHeight), NULL, QuestsToggleButton, L"Quests", NULL);
	btn->setIsPushButton(true);
	*/
	IGUIButton* btn;
	btn = guienv->addButton(rect< s32 >(0, render->screenHeight - btnsSize, btnsSize, render->screenHeight), NULL, InventoryToggleButton, NULL, L"Inventory");
	btn->setIsPushButton(true);
	btn->setUseAlphaChannel(true);
	btn->setImage(render->driver->getTexture("res/inventory_icon.png"));
	btn = guienv->addButton(rect< s32 >(btnsSize, render->screenHeight - btnsSize, btnsSize + btnsSize, render->screenHeight), NULL, SkillsToggleButton, NULL, L"Skills");
	btn->setIsPushButton(true);
	btn->setUseAlphaChannel(true);
	btn->setImage(render->driver->getTexture("res/skills_icon.png"));
	btn = guienv->addButton(rect< s32 >(btnsSize + btnsSize, render->screenHeight - btnsSize, btnsSize + btnsSize + btnsSize, render->screenHeight), NULL, QuestsToggleButton, NULL, L"Quests");
	btn->setIsPushButton(true);
	btn->setUseAlphaChannel(true);
	btn->setImage(render->driver->getTexture("res/quests_icon.png"));

	//Chat
	IGUIChatBox* cb = new IGUIChatBox(guienv, NULL, ChatBox, ChatEditBox, ChatInputEditBox, rect< s32 >(0, 128, 256, 128 + 256 + 24));
	guienv->getRootGUIElement()->addChild(cb);

	//Hotkey
	int slotsCount = 9;
	IGUIIconTable* tbl3 = new IGUIIconTable(guienv, NULL, HotkeyBar, rect< s32 >(320, render->screenHeight - btnsSize, 320 + slotsCount * btnsSize + (slotsCount - 1) * 2, render->screenHeight), slotsCount, 1);
	guienv->getRootGUIElement()->addChild(tbl3);
}
コード例 #3
0
bool 
ProcTitle::OnInit(irr::IrrlichtDevice& device)
{	
	device.setWindowCaption(L"Artistic Controlled Car - title");

	IGUIEnvironment* env = device.getGUIEnvironment();
	IGUIButton* pButton = env->addButton(rect<s32>(10, 240, 200, 240+100), 0, GUI_ID_START_BUTTON, L"Start", L"Start Game");
	pButton->setDrawBorder(false);
	IVideoDriver* pDriver = IrrDvc.GetDriver();
	video::ITexture* pTexture = pDriver->getTexture("Rsrc/hero.tga");	// refcount = 1
	pButton->setImage(pTexture);										// refcount += 2, means when button released refcount will be 1	
	pButton->setUseAlphaChannel(true);									// 1 will be decreased pDriver->removeAllTextures();

	{
		ITexture* pTexture = pDriver->getTexture("Rsrc/map.bmp");
		pButton->setPressedImage(pTexture);
	}

	// sound test
	IrrSnd.GetSndEngine()->play2D("Rsrc/getout.ogg", true);	

	return true;
}
コード例 #4
0
ファイル: CUIGame.cpp プロジェクト: kcuzner/irrrpgbuilder
// Set up the gameplay interface GUI
void GUIGame::setupGameplayGUI()
{

	driver=App::getInstance()->getDevice()->getVideoDriver();
	guienv=App::getInstance()->getDevice()->getGUIEnvironment();

	GUIManager::getInstance()->createConsole();

	IGUIInOutFader* fader=guienv->addInOutFader();
	fader->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT);
    fader->setVisible(false);
	fader->setID(GUIManager::ID_FADER);

	// NEW Create display size since IRRlicht return wrong values
	// Check the current screen size
	displayheight=screensize.Height;
	displaywidth=screensize.Width;

	// Create a cutscene text
	IGUIStaticText* guiCutsceneText = guienv->addStaticText(L"This is a standard cutscene text",core::rect<s32>(100,displayheight/2+(displayheight/4),displaywidth-10,displayheight-100),false,true,0,-1,false);
	guiCutsceneText->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiCutsceneText->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	guiCutsceneText->setVisible(false);
	guiCutsceneText->setID(GUIManager::ST_ID_CUTSCENE_TEXT);

	// This is called only in the PLAYER application
	#ifndef EDITOR
	// ----------------------------------------
	guienv->getSkin()->setFont(GUIManager::getInstance()->guiFontC12);
	//guienv->getSkin()->setFont(guiFontCourier12);
	// Load textures
	ITexture* imgLogo = driver->getTexture(App::getInstance()->logoimage.c_str());
	printf("Here is the logo: %s\n",App::getInstance()->logoimage.c_str());

	//LOADER WINDOW
	IGUIWindow* guiLoaderWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width/2-300, driver->getScreenSize().Height/2-200,600,400),false,L"Loading...",0,GUIManager::WIN_LOADER);
	guiLoaderWindow->setDrawTitlebar(false);
	guiLoaderWindow->getCloseButton()->setVisible(false);

	guienv->addImage(imgLogo,vector2d<s32>(5,5),true,guiLoaderWindow);
    IGUIStaticText* guiLoaderDescription = guienv->addStaticText(L"Loading fonts...",
		GUIManager::getInstance()->myRect(10,350,580,40),
		true,true,guiLoaderWindow,
		GUIManager::TXT_ID_LOADER,false);

	//Define 2 buttons to place in the loader windows (player only)
	IGUIButton* guiBtGamePlay = guienv->addButton(core::rect<s32>(400,360,580,380),guiLoaderWindow, GUIManager::BT_PLAYER_START, L"PLAY GAME NOW!");
	guiBtGamePlay->setVisible(false);

	IGUIButton* guiBtGameConfig = guienv->addButton(core::rect<s32>(20,360,200,380),guiLoaderWindow, GUIManager::BT_PLAYER_CONFIG, L"EDIT CONFIGURATION");
	guiBtGameConfig->setVisible(false);

	App::getInstance()->quickUpdate();

	GUIManager::getInstance()->loadFonts();
	guiLoaderDescription->setText(L"Loading interface graphics...");
	//printf("The GUI should display from here...\n");
	// quick update
	App::getInstance()->quickUpdate();

	// Buttons
	ITexture* imgCloseProgram = driver->getTexture("../media/art/bt_close_program.png");
	ITexture* imgAbout = driver->getTexture("../media/art/bt_about.png");
	ITexture* imgAbout1 = driver->getTexture("../media/art/bt_about_ghost.png");
	ITexture* imgHelp = driver->getTexture("../media/art/bt_help.png");
	ITexture* imgHelp1 = driver->getTexture("../media/art/bt_help_ghost.png");
	ITexture* imgConfig = driver->getTexture("../media/art/bt_config.png");
	ITexture* imgConfig1 = driver->getTexture("../media/art/bt_config_ghost.png");

	IGUIWindow* guiMainToolWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width-170,0,170,46),false,0,0,GUIManager::WIN_GAMEPLAY);
	guiMainToolWindow->setDraggable(false);
	guiMainToolWindow->setDrawTitlebar(false);
	guiMainToolWindow->getCloseButton()->setVisible(false);
	guiMainToolWindow->setVisible(false);


	//Play Game
	int x = 0;
	mainToolbarPos.Y=5;
	IGUIButton* guiPlayGame= guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_PLAY_GAME,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_play_game")).c_str());

    guiPlayGame->setImage(driver->getTexture("../media/art/bt_play_game.png"));


    //Stop Game
    IGUIButton* guiStopGame= guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_STOP_GAME,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_stop_game")).c_str());

    guiStopGame->setImage(driver->getTexture("../media/art/bt_stop_game.png"));
    guiStopGame->setVisible(false);



    //ABOUT BUTTON
	x += 42;
    IGUIButton* guiAbout = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_ABOUT,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_about")).c_str() );

    guiAbout->setImage(imgAbout);
	guiAbout->setPressedImage(imgAbout1);

	// Help Button
	x += 42;
    IGUIButton* guiHelpButton = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_HELP,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_help")).c_str() );

    guiHelpButton->setImage(imgHelp);
    guiHelpButton->setPressedImage(imgHelp1);

	// Close program
	x += 42;
	IGUIButton* guiCloseProgram = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_CLOSE_PROGRAM,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_close_program")).c_str() );

    guiCloseProgram->setImage(imgCloseProgram);

	//ABOUT WINDOW
	IGUIWindow* guiAboutWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width/2 - 300,driver->getScreenSize().Height/2 - 200,600,400),false);
    guiAboutWindow->setDraggable(false);
    guiAboutWindow->setDrawTitlebar(false);
    guiAboutWindow->getCloseButton()->setVisible(false);
    guiAboutWindow->setVisible(false);

    guienv->addImage(driver->getTexture("../media/art/logo1.png"),position2di(guiAboutWindow->getAbsoluteClippingRect().getWidth()/2-100,10),true,guiAboutWindow);

	IGUIButton* guiAboutClose = guienv->addButton(GUIManager::getInstance()->myRect(guiAboutWindow->getAbsoluteClippingRect().getWidth() - 37,guiAboutWindow->getAbsoluteClippingRect().getHeight() - 37,32,32),guiAboutWindow,GUIManager::BT_ID_ABOUT_WINDOW_CLOSE);

    guiAboutClose->setImage(driver->getTexture("../media/art/bt_yes_32.png"));

	IGUIListBox* guiAboutText = guienv ->addListBox(GUIManager::getInstance()->myRect(guiAboutWindow->getAbsoluteClippingRect().getWidth()/2-250,160,500,200),guiAboutWindow);

	// Ask the LANGManager to fill the box with the proper Language of the about text.
	LANGManager::getInstance()->setAboutText(guiAboutText);

	// Create the Configuration window (Need to be updated)
#ifndef EDITOR
	configWindow = new GUIConfigWindow(App::getInstance()->getDevice());
	configWindow->setID(GUIManager::GCW_CONFIG_WINDOW);
	// Give back to the GUI Manager since it's needed for both applications
	GUIManager::getInstance()->setConfigWindow(configWindow);
#endif

	// ---------------------------------------
	#endif

	// --- Active game menu during play

	ITexture* gameplay_bar = driver->getTexture("../media/art/gameplay_bar.png");
	ITexture* circle = driver->getTexture("../media/art/circle.png");
	ITexture* circleMana = driver->getTexture("../media/art/circlemana.png");
	ITexture* topCircle = driver->getTexture("../media/art/circle_top.png");
	IGUIImage* gameplay_bar_image = NULL;
	
	if (gameplay_bar)
	{
		gameplay_bar_image = guienv->addImage(gameplay_bar,vector2d<s32>((displaywidth/2)-(gameplay_bar->getSize().Width/2),displayheight-gameplay_bar->getSize().Height),true);
		gameplay_bar_image->setAlignment(EGUIA_CENTER,EGUIA_CENTER,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
		gameplay_bar_image->setID(GUIManager::IMG_BAR);

		// The life gauge
		CGUIGfxStatus* lifegauge = new gui::CGUIGfxStatus(guienv, gameplay_bar_image,GUIManager::getInstance()->myRect((gameplay_bar->getSize().Width/2)-60,gameplay_bar->getSize().Height-128,128,128),-1);
		lifegauge->setImage(circle);
		lifegauge->ViewHalfLeft();
		lifegauge->setID(GUIManager::IMG_LIFEGAUGE);

		// The mana gauge
		CGUIGfxStatus* managauge = new gui::CGUIGfxStatus(guienv, gameplay_bar_image,GUIManager::getInstance()->myRect((gameplay_bar->getSize().Width/2)-60,gameplay_bar->getSize().Height-128,128,128),-1);
		managauge->setImage(circleMana);
		managauge->ViewHalfRight();
		managauge->setID(GUIManager::IMG_MANAGAUGE);

		// The image over the circle
		IGUIImage* circle_overlay =	guienv->addImage(topCircle,vector2d<s32>((gameplay_bar->getSize().Width/2)-64,gameplay_bar->getSize().Height-128),true,gameplay_bar_image);
	}	

	gameplay_bar_image->setVisible(false);

    ///DIALOG
	guiDialogImgYes = driver->getTexture("../media/art/img_yes.png");
    guiDialogImgYes_s = driver->getTexture("../media/art/img_yes_s.png");
    guiDialogImgNo = driver->getTexture("../media/art/img_no.png");
    guiDialogImgNo_s = driver->getTexture("../media/art/img_no_s.png");


    //view items
	if (gameplay_bar_image)
	{
		core::stringw text=LANGManager::getInstance()->getText("bt_view_items");
		IGUIButton* guiBtViewItems = guienv->addButton(GUIManager::getInstance()->myRect(465,85,48,48),
		//displaywidth/2 + 80,displayheight - 57,48,48),
                                     gameplay_bar_image,
									 GUIManager::BT_ID_VIEW_ITEMS,L"",
									 text.c_str());

		guiBtViewItems->setImage(driver->getTexture("../media/art/bt_view_items.png"));
		guiBtViewItems->setVisible(true);
		
	}

	

    //Items window

	IGUIWindow* guiWindowItems = guienv->addWindow(GUIManager::getInstance()->myRect(100,100,displaywidth-200,displayheight-150),false,L"",0,GUIManager::GCW_GAMEPLAY_ITEMS);
    guiWindowItems->getCloseButton()->setVisible(false);
    guiWindowItems->setDrawTitlebar(false);
    guiWindowItems->setDraggable(false);
	guiWindowItems->setAlignment(EGUIA_CENTER,EGUIA_CENTER,EGUIA_CENTER,EGUIA_CENTER);
    IGUITabControl * gameTabCtrl = guienv->addTabControl(core::rect<s32>(10,30,displaywidth-240,displayheight-200),guiWindowItems,false,true,-1);
	IGUITab * tab1 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_stats_title").c_str());
	IGUITab * tab2 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_inventory_title").c_str());
	IGUITab * tab3 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_skills_title").c_str());
	IGUITab * tab4 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_quests_title").c_str());


	nodepreview = new NodePreview(guienv,tab1,rect<s32>(440,40,740,370),-1);
	nodepreview->drawBackground(false);

	//DynamicObjectsManager::getInstance()->setActiveObject("player_template");

	//guiPlayerNodePreview->setNode(DynamicObjectsManager::getInstance()->getActiveObject()->getNode());
	//guiPlayerNodePreview->setNode(Player::getInstance()->getNodeRef());
	//DynamicObjectsManager::getInstance()->setActiveObject("Archer");
	//printf("This is the node name: %s\n",DynamicObjectsManager::getInstance()->getActiveObject()->getName());
	nodepreview->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);

	IGUIListBox* guiPlayerItems = guienv->addListBox(GUIManager::getInstance()->myRect(10,30,200,displayheight-340),tab2,GUIManager::LB_ID_PLAYER_ITEMS,true);

	ITexture* info_none = driver->getTexture("../media/editor/info_none.jpg");

	IGUIImage* guiPlayerLootImage = NULL;

	if (info_none)
		guiPlayerLootImage = guienv->addImage(info_none,vector2d<s32>(220,30),true,tab2,GUIManager::IMG_LOOT);

	guienv->addStaticText(L"",core::rect<s32>(220,250,520,410),true,true,tab2,GUIManager::TXT_ID_LOOT_DESCRIPTION,true);

	//guienv->addImage(info_none,vector2d<s32>(5,5),true,tab2);
	core::stringc filename = "../media/dynamic_objects/";

	IGUIButton* guiBtUseItem = guienv->addButton(GUIManager::getInstance()->myRect(10,displayheight-300,32,32),
                                         tab2,
										 GUIManager::BT_ID_USE_ITEM,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_use_item")).c_str());
    guiBtUseItem->setImage(driver->getTexture("../media/art/bt_yes_32.png"));

    IGUIButton* guiBtDropItem = guienv->addButton(GUIManager::getInstance()->myRect(52,displayheight-300,32,32),
                                         tab2,
										 GUIManager::BT_ID_DROP_ITEM,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_drop_item")).c_str());
    guiBtDropItem->setImage(driver->getTexture("../media/art/bt_no_32.png"));


    IGUIButton* guiBtCloseItemsWindow = guienv->addButton(GUIManager::getInstance()->myRect(displaywidth-210-32,displayheight-160 - 32,32,32),
                                         guiWindowItems,
										 GUIManager::BT_ID_CLOSE_ITEMS_WINDOW,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_close_items_window")).c_str());
    guiBtCloseItemsWindow->setImage(driver->getTexture("../media/art/bt_arrow_32.png"));
	guiWindowItems->setVisible(false);



	// TExt GUI for player stats

	IGUIStaticText* guiPlayerMoney = guienv->addStaticText(L"GOLD:129",GUIManager::getInstance()->myRect(15,displayheight-300,300,32),false,false,tab1, GUIManager::ST_ID_PLAYER_MONEY);
	guiPlayerMoney->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
    guiPlayerMoney->setOverrideColor(SColor(255,255,255,255));

	stringc playerLifeText = LANGManager::getInstance()->getText("txt_player_life");


	IGUIStaticText* guiPlayerLife=guienv->addStaticText(stringw(playerLifeText).c_str(),GUIManager::getInstance()->myRect(15,6,600,30),false,false,tab1,-1,false);
    guiPlayerLife->setOverrideColor(SColor(255,255,255,100));
    guiPlayerLife->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiPlayerLife->setID(GUIManager::ST_ID_PLAYER_LIFE);

	//Have to rework this. Currently hidden.
	IGUIStaticText* guiPlayerLife_Shadow=guienv->addStaticText(stringw(playerLifeText).c_str(),GUIManager::getInstance()->myRect(14,5,600,30),false,false,tab1,-1,false);
    guiPlayerLife_Shadow->setOverrideColor(SColor(255,30,30,30));
	guiPlayerLife_Shadow->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiPlayerLife_Shadow->setVisible(false);
	
	GUIManager::getInstance()->setElementVisible(GUIManager::ST_ID_PLAYER_LIFE, false);


	////// --------------------------------
	///    Define the Dialogs used in the game
	//////

	IGUIWindow* guidialog = guienv->addWindow(GUIManager::getInstance()->myRect(10,displayheight-200,displaywidth-20,190),true,L"",0,GUIManager::GCW_DIALOG);
	guidialog->getCloseButton()->setVisible(false);
	guidialog->setDrawTitlebar(false);
	guidialog->setDraggable(false);
	guidialog->setDrawBackground(false);
	guidialog->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	// Panel background is done with pictures
	IGUIImage* img1 = guienv->addImage(driver->getTexture("../media/art/panel_left.png"),vector2d<s32>(0,0),true,guidialog);
	IGUIImage* img2 = guienv->addImage(driver->getTexture("../media/art/panel_middle.png"),vector2d<s32>(51,0),true,guidialog);
	IGUIImage* img3 = guienv->addImage(driver->getTexture("../media/art/panel_right.png"),vector2d<s32>(581,0),true,guidialog);
	img2->setScaleImage(true);
	img2->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	img3->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	// Text display of the panel
	rect<s32> textRect = rect<s32>(30,25,600,170);
	IGUIStaticText* txt_dialog = guienv->addStaticText(L"Hello! This is a simple test to see how the text is flowing inside the box. There is a test, test, and test of text we need to make to be sure the flowing is ok",textRect,false,false,guidialog,GUIManager::TXT_ID_DIALOG,false);
	txt_dialog->setOverrideFont(GUIManager::getInstance()->guiFontDialog);
	txt_dialog->setOverrideColor(SColor(255,255,255,255));
	txt_dialog->setWordWrap(true);
	txt_dialog->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	IGUIButton* guiBtDialogYes = guienv->addButton(GUIManager::getInstance()->myRect(640,30,52,52),
                                         guidialog,
										 GUIManager::BT_ID_DIALOG_YES,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_dialog_yes")).c_str());
    guiBtDialogYes->setImage(guiDialogImgYes);
	guiBtDialogYes->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	IGUIButton* guiBtDialogCancel = guienv->addButton(GUIManager::getInstance()->myRect(640,110,52,52),
                                         guidialog,
										 GUIManager::BT_ID_DIALOG_CANCEL,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_dialog_no")).c_str());
    guiBtDialogCancel->setImage(guiDialogImgNo);
	guiBtDialogCancel->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	guidialog->setVisible(false);

}
コード例 #5
0
ファイル: ribbon_widget.cpp プロジェクト: Elderme/stk-code
// ----------------------------------------------------------------------------
void RibbonWidget::add()
{
    assert(m_magic_number == 0xCAFEC001);
    assert(m_x > -10.0f);
    assert(m_y > -10.0f);
    assert(m_w > 0.0f);
    assert(m_h > 0.0f);


    m_labels.clearWithoutDeleting();

    rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);

    int id = (m_reserved_id == -1 ? getNewID() : m_reserved_id);

    IGUIButton * btn = GUIEngine::getGUIEnv()->addButton(widget_size,
                                                         m_parent, id, L"");
    m_element = btn;

    m_active_children.clearWithoutDeleting(); // Is just a copy of m_children without the deactivated children. m_children takes care of memory.
    for (unsigned int i=0; i<m_children.size(); i++)
    {
        if (m_children[i].isVisible())
        {
            m_active_children.push_back(m_children.get(i));
        }
    }
    const int subbuttons_amount = m_active_children.size();

    // For some ribbon types, we can have unequal sizes depending on whether
    // items have labels or not
    int with_label = 0;
    int without_label = 0;

    // ---- check how much space each child button will take and fit
    // them within available space
    int total_needed_space = 0;
    for (int i=0; i<subbuttons_amount; i++)
    {
        // FIXME: why do I manually invoke the Layout Manager here?
        LayoutManager::readCoords(m_active_children.get(i));
        LayoutManager::applyCoords(m_active_children.get(i), NULL, this);

        if (m_active_children[i].m_type != WTYPE_ICON_BUTTON &&
            m_active_children[i].m_type != WTYPE_BUTTON)
        {
            Log::warn("RiggonWidget", "Ribbon widgets can only have "
                            "(icon)button widgets as children");
            continue;
        }

        // ribbon children must not be keyboard navigatable, the parent
        // ribbon takes care of that
        if (m_active_children[i].m_type == WTYPE_ICON_BUTTON)
        {
            IconButtonWidget* icon = ((IconButtonWidget*)m_active_children.get(i));
            icon->m_tab_stop = false;
        }


        bool has_label_underneath = m_active_children[i].m_text.size() > 0;
        if (m_active_children[i].m_properties[PROP_LABELS_LOCATION].size() > 0)
        {
            has_label_underneath = false;
        }

        if (has_label_underneath) with_label++;
        else                      without_label++;

        total_needed_space += m_active_children[i].m_w;
    }

    //int biggest_y = 0;
    const int button_y = 10;

    const int one_button_space =
        int(roundf((float)m_w / (float)subbuttons_amount));

    int widget_x = -1;

    // ---- add children
    for (int i=0; i<subbuttons_amount; i++)
    {
        // ---- tab ribbons
        if (getRibbonType() == RIBBON_TABS)
        {
            const int large_tab = (int)((with_label + without_label)
                                        *one_button_space
                                        / (with_label + without_label/2.0f));
            const int small_tab = large_tab/2;

            stringw& message = m_active_children[i].m_text;


            if (message.size() == 0)
            {
                if (widget_x == -1) widget_x = small_tab/2;
                else widget_x += small_tab/2;
            }
            else
            {
                if (widget_x == -1) widget_x = large_tab/2;
                else widget_x += large_tab/2;
            }

            IGUIButton * subbtn = NULL;
            rect<s32> subsize = rect<s32>(widget_x - large_tab/2+2,  0,
                                          widget_x + large_tab/2-2,  m_h);

            if (message.size() == 0)
            {
                subsize = rect<s32>(widget_x - small_tab/2+2,  0,
                                    widget_x + small_tab/2-2,  m_h);
            }

            if (m_active_children[i].m_type == WTYPE_BUTTON)
            {
                subbtn = GUIEngine::getGUIEnv()
                       ->addButton(subsize, btn, getNewNoFocusID(),
                                   message.c_str(), L"");
                subbtn->setTabStop(false);
                subbtn->setTabGroup(false);

                if ((int)GUIEngine::getFont()->getDimension(message.c_str())
                                              .Width > subsize.getWidth()  &&
                    message.findFirst(L' ') == -1                          &&
                    message.findFirst(L'\u00AD') == -1                        )
                {
                    // if message too long and contains no space and no soft
                    // hyphen, make the font smaller
                    subbtn->setOverrideFont(GUIEngine::getSmallFont());
                }
            }
            else if (m_active_children[i].m_type == WTYPE_ICON_BUTTON)
            {
                rect<s32> icon_part = rect<s32>(15,
                                                0,
                                                subsize.getHeight()+15,
                                                subsize.getHeight());

                if (message.size() == 0)
                {
                    const int x = subsize.getWidth()/2 - subsize.getHeight()/2;
                    // no label, only icon, so center the icon
                    icon_part = rect<s32>(x,
                                          0,
                                          x + subsize.getHeight(),
                                          subsize.getHeight());
                }

                // label at the *right* of the icon (for tabs)
                rect<s32> label_part = rect<s32>(subsize.getHeight()+15,
                                                 0,
                                                 subsize.getWidth()-15,
                                                 subsize.getHeight());

                // use the same ID for all subcomponents; since event handling
                // is done per-ID, no matter which one your hover, this
                // widget will get it
                int same_id = getNewNoFocusID();
                subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn,
                                                           same_id, L"", L"");

                IGUIButton* icon =
                    GUIEngine::getGUIEnv()->addButton(icon_part, subbtn,
                                                      same_id, L"");
                icon->setScaleImage(true);
                std::string filename = file_manager->getAsset(
                                     m_active_children[i].m_properties[PROP_ICON]);
                icon->setImage( irr_driver->getTexture(filename.c_str()) );
                icon->setUseAlphaChannel(true);
                icon->setDrawBorder(false);
                icon->setTabStop(false);

                IGUIStaticText* label =
                    GUIEngine::getGUIEnv()->addStaticText(message.c_str(),
                                                          label_part,
                                                          false /* border */,
                                                          true /* word wrap */,
                                                          subbtn, same_id);

                if ((int)GUIEngine::getFont()->getDimension(message.c_str())
                                              .Width > label_part.getWidth()&&
                    message.findFirst(L' ') == -1                           &&
                    message.findFirst(L'\u00AD') == -1                        )
                {
                    // if message too long and contains no space and no soft
                    // hyphen, make the font smaller
                    label->setOverrideFont(GUIEngine::getSmallFont());
                }
                label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
                label->setTabStop(false);
                label->setNotClipped(true);
                label->setRightToLeft(translations->isRTLText(message));
                m_labels.push_back(label);

                subbtn->setTabStop(false);
                subbtn->setTabGroup(false);
            }
            else
            {
                Log::error("RibbonWidget", "Invalid tab bar contents");
            }

            m_active_children[i].m_element = subbtn;

            if (message.size() == 0) widget_x += small_tab/2;
            else                     widget_x += large_tab/2;
        }
        // ---- icon ribbons
        else if (m_active_children[i].m_type == WTYPE_ICON_BUTTON)
        {
            if (widget_x == -1) widget_x = one_button_space/2;

            // find how much space to keep for the label under the button.
            // consider font size, whether the label is multiline, etc...
            bool has_label = m_active_children[i].m_text.size() > 0;

            if (m_active_children[i].m_properties[PROP_LABELS_LOCATION].size() > 0)
            {
                has_label = false;
            }

            const int needed_space_under_button = has_label
                                                ? GUIEngine::getFontHeight()
                                                : 10;

            float imageRatio =
                (float)m_active_children[i].m_w / (float)m_active_children[i].m_h;

            // calculate the size of the image
            std::string filename =
                file_manager->getAsset(m_active_children[i].m_properties[PROP_ICON]);
            video::ITexture* image =
                irr_driver->getTexture((filename).c_str());
            if(!image)
            {
                std::string file = file_manager->getAsset(FileManager::GUI,"main_help.png");
                image = irr_driver->getTexture(file);
                if(!image)
                    Log::fatal("RibbonWidget",
                        "Can't find fallback texture 'gui/main_help.png, aborting.");
            }

            float image_h = (float)image->getSize().Height;
            float image_w = image_h*imageRatio;
            float zoom = (float) (m_h - button_y - needed_space_under_button) / image_h;
            float zoom_x = (float) one_button_space / image_w;
            if(zoom_x < zoom)
                zoom = zoom_x;

            // ---- add bitmap button part
            // backup and restore position in case the same object is added
            // multiple times (FIXME: unclean)
            int old_x = m_active_children[i].m_x;
            int old_y = m_active_children[i].m_y;
            int old_w = m_active_children[i].m_w;
            int old_h = m_active_children[i].m_h;

            m_active_children[i].m_x = widget_x - int(image_w*zoom/2.0f);
            m_active_children[i].m_y = button_y;
            m_active_children[i].m_w = int(image_w*zoom);
            m_active_children[i].m_h = int(image_h*zoom);

            IconButtonWidget* icon = ((IconButtonWidget*)m_active_children.get(i));

            if (icon->m_properties[PROP_EXTEND_LABEL].size() == 0)
            {
                icon->m_properties[PROP_EXTEND_LABEL] =
                    StringUtils::toString(one_button_space - icon->m_w);
            }

            m_active_children.get(i)->m_parent = btn;
            m_active_children.get(i)->add();

            // restore backuped size and location (see above for more info)
            m_active_children[i].m_x = old_x;
            m_active_children[i].m_y = old_y;
            m_active_children[i].m_w = old_w;
            m_active_children[i].m_h = old_h;

            // the label itself will be added by the icon widget. since it
            // adds the label outside of the widget area it is assigned to,
            // the label will appear in the area we want at the bottom

            widget_x += one_button_space;
        }
        else
        {
            Log::warn("RiggonWidget", "Invalid contents type in ribbon");
        }


        //m_children[i].id = subbtn->getID();
        m_active_children[i].m_event_handler = this;
    }// next sub-button

    id = m_element->getID();
    m_element->setTabOrder(id);
    m_element->setTabGroup(false);
    updateSelection();

    if (!m_is_visible)
        setVisible(false);
}   // add
コード例 #6
0
void RibbonWidget::add()
{
    m_labels.clearWithoutDeleting();
    
    
    rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
    
    int id = (m_reserved_id == -1 ? getNewID() : m_reserved_id);
    
    IGUIButton * btn = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, id, L"");
    m_element = btn;
    
    const int subbuttons_amount = m_children.size();
    
    // ---- check how much space each child button will take and fit them within available space
    int total_needed_space = 0;
    for (int i=0; i<subbuttons_amount; i++)
    {
        // FIXME: a little unclean to invoke layout code here?
        LayoutManager::readCoords(m_children.get(i), NULL, this);
        
        if (m_children[i].m_type != WTYPE_ICON_BUTTON && m_children[i].m_type != WTYPE_BUTTON)
        {
            std::cerr << "/!\\ Warning /!\\ : ribbon widgets can only have (icon)button widgets as children "
                      << std::endl;
            continue;
        }
        
        // ribbon children must not be keyboard navigatable, the parent ribbon takes care of that
        if (m_children[i].m_type == WTYPE_ICON_BUTTON)
        {
            IconButtonWidget* icon = ((IconButtonWidget*)m_children.get(i));
            icon->m_tab_stop = false;
        }
        
        total_needed_space += m_children[i].m_w;
    }
    
    int free_w_space = m_w - total_needed_space;
    
    //int biggest_y = 0;
    const int button_y = 10;
    float global_zoom = 1;
    
    const int min_free_space = 50;
    global_zoom = (float)m_w / (float)( m_w - free_w_space + min_free_space );
    //free_w_space = (int)(m_w - total_needed_space*global_zoom);
    
    const int one_button_space = (int)round((float)m_w / (float)subbuttons_amount);
    
    // ---- add children
    for (int i=0; i<subbuttons_amount; i++)
    {
        
        const int widget_x = one_button_space*(i+1) - one_button_space/2;
        
        // ---- tab ribbons
        if (getRibbonType() == RIBBON_TABS)
        {
            IGUIButton * subbtn = NULL;
            rect<s32> subsize = rect<s32>(widget_x - one_button_space/2+2,  0,
                                          widget_x + one_button_space/2-2,  m_h);
            
            stringw& message = m_children[i].m_text;
            
            if (m_children[i].m_type == WTYPE_BUTTON)
            {
                subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, getNewNoFocusID(), message.c_str(), L"");
                subbtn->setTabStop(false);
                subbtn->setTabGroup(false);
            }
            else if (m_children[i].m_type == WTYPE_ICON_BUTTON)
            {
                rect<s32> icon_part = rect<s32>(15,
                                                0,
                                                subsize.getHeight()+15,
                                                subsize.getHeight());
                // label at the *right* of the icon (for tabs)
                rect<s32> label_part = rect<s32>(subsize.getHeight()+15,
                                                 0,
                                                 subsize.getWidth()-15,
                                                 subsize.getHeight());
                
                // use the same ID for all subcomponents; since event handling is done per-ID, no matter
                // which one your hover, this widget will get it
                int same_id = getNewNoFocusID();
                subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, same_id, L"", L"");
                
                //MyGUIButton* icon = new MyGUIButton(GUIEngine::getGUIEnv(), subbtn, same_id, icon_part, true);
                IGUIButton* icon = GUIEngine::getGUIEnv()->addButton(icon_part, subbtn, same_id, L"");
                icon->setScaleImage(true);
                icon->setImage( irr_driver->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()) );
                icon->setUseAlphaChannel(true);
                icon->setDrawBorder(false);
                icon->setTabStop(false);
                
                IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), label_part,
                                                                              false /* border */,
                                                                              true /* word wrap */,
                                                                              subbtn, same_id);
                label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
                label->setTabStop(false);
                label->setNotClipped(true);
                m_labels.push_back(label);
                
                subbtn->setTabStop(false);
                subbtn->setTabGroup(false);
                
            }
            else
            {
                std::cerr << "Invalid tab bar contents\n";
            }
            
            m_children[i].m_element = subbtn;
        }
        // ---- icon ribbons
        else if (m_children[i].m_type == WTYPE_ICON_BUTTON)
        {
            // find how much space to keep for the label under the button.
            // consider font size, whether the label is multiline, etc...
            const bool has_label = m_children[i].m_text.size() > 0;
            
            const int needed_space_under_button = has_label ? GUIEngine::getFontHeight() : 10;
            
            float imageRatio = (float)m_children[i].m_w / (float)m_children[i].m_h;
            
            // calculate the size of the image
            video::ITexture* image = irr_driver->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str());
            float image_h = (float)image->getSize().Height;
            float image_w = image_h*imageRatio;

            // scale to fit (FIXME: calculate the right value directly...)
            float zoom = global_zoom;
            
            if (button_y + image_h*zoom + needed_space_under_button > m_h)
            {
                // scale down
                while (button_y + image_h*zoom + needed_space_under_button > m_h) zoom -= 0.01f;
            }
            else
            {
                // scale up
                while (button_y + image_h*zoom + needed_space_under_button < m_h) zoom += 0.01f;
            }
            
            // ---- add bitmap button part
            // backup and restore position in case the same object is added multiple times (FIXME: unclean)
            int old_x = m_children[i].m_x;
            int old_y = m_children[i].m_y;
            int old_w = m_children[i].m_w;
            int old_h = m_children[i].m_h;
            
            m_children[i].m_x = widget_x - (int)(image_w*zoom/2.0f);
            m_children[i].m_y = button_y;
            m_children[i].m_w = (int)(image_w*zoom);
            m_children[i].m_h = (int)(image_h*zoom);
            
            IconButtonWidget* icon = ((IconButtonWidget*)m_children.get(i));
            icon->m_properties[PROP_EXTEND_LABEL] = StringUtils::toString(one_button_space - icon->m_w);

            m_children.get(i)->m_parent = btn;
            m_children.get(i)->add();

            // restore backuped size and location (see above for more info)
            m_children[i].m_x = old_x;
            m_children[i].m_y = old_y;
            m_children[i].m_w = old_w;
            m_children[i].m_h = old_h;
            
            // the label itself will be added by the icon widget. since it adds the label outside of the
            // widget area it is assigned to, the label will appear in the area we want at the bottom
        }
        else
        {
            std::cerr << "/!\\ Warning /!\\ : Invalid contents type in ribbon" << std::endl;
        }
        
        
        //m_children[i].id = subbtn->getID();
        m_children[i].m_event_handler = this;
    }// next sub-button
    
    id = m_element->getID();
    m_element->setTabOrder(id);
    m_element->setTabGroup(false);
    updateSelection();
}
コード例 #7
0
bool 
ProcTitle::OnInit(irr::IrrlichtDevice& device)
{	
	device.setWindowCaption(L"Pair - title");
	//device.getCursorControl()->setVisible(false);

	u32 width = IrrDvc.GetDriver()->getScreenSize().Width;
	u32 height = IrrDvc.GetDriver()->getScreenSize().Height;

	scene::ISceneManager* pSmgr = IrrDvc.GetSmgr();
	IVideoDriver* pDriver = IrrDvc.GetDriver();

	// camera setting 
	{		
		irr::scene::ICameraSceneNode* pCamera = pSmgr->addCameraSceneNode(0, core::vector3df(0,0,-100), core::vector3df(0,0,0));		
		//f32 zNear = 1;
		//f32 zFar = 3000;
		//f32 zNear = pCamera->getNearValue();
		//f32 zFar = pCamera->getFarValue();
#if 0
		CMatrix4<f32> matOrtho;				
		matOrtho.buildProjectionMatrixOrthoLH(width, height, zNear, zFar);
		pCamera->setProjectionMatrix(matOrtho, true);
#else
		//CMatrix4<f32> matPerspective;
		//matPerspective.buildProjectionMatrixPerspectiveLH((f32)width, (f32)height, zNear, zFar);
		//pCamera->setProjectionMatrix(matPerspective, false);
#endif
	}

	// title
	{		
		m_p2DSprite = pSmgr->addBillboardSceneNode();
		video::ITexture* pTexture = pDriver->getTexture("Rsrc/title.png");		
		m_p2DSprite->setMaterialTexture(0, pTexture);
		m_p2DSprite->setMaterialFlag(video::EMF_LIGHTING, false);
		m_p2DSprite->setMaterialFlag(video::EMF_ZBUFFER, true);
		m_p2DSprite->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
		m_p2DSprite->setMaterialFlag(video::EMF_ANTI_ALIASING, true);
		m_p2DSprite->setMaterialFlag(video::EMF_BILINEAR_FILTER, true);
		m_p2DSprite->setSize(dimension2df((f32)width, (f32)height));
		m_p2DSprite->setPosition(vector3df(0.f, 0.f, 300.f));
		m_p2DSprite->setID(1004);
		m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(1.0f, 1.0f);

		// animation test
		//scene::ISceneNodeAnimator* pAni = pSmgr->createFlyCircleAnimator(core::vector3df(0,0,200), 20.0f);
		//m_p2DSprite->addAnimator(pAni);
	}

	// card
	{
		for (int i = 0; i < 3; i++)
		{
			IMeshSceneNode* pCard = pSmgr->addCubeSceneNode();
			char buff[20];
			sprintf_s(buff, 20, "Rsrc/card%d.png", i);
			video::ITexture* pTexture = pDriver->getTexture(buff);			
			pCard->setMaterialTexture(0, pTexture);
			pCard->setScale(vector3df(4.f, 4.f * 1.618f, 0.1f));
			pCard->setPosition(vector3df(-60.f + 60.f * i, 0.f, 0.f));
			pCard->setMaterialFlag(video::EMF_LIGHTING, false);

			// animation test
			scene::ISceneNodeAnimator* pAni = pSmgr->createRotationAnimator(vector3df(0.f, 1.f, 0.f));
			pCard->addAnimator(pAni);
			pAni->drop();
		}
	}

	// mesh
	{
		IAnimatedMesh* mesh = pSmgr->getMesh("Rsrc/sydney.md2");
		IAnimatedMeshSceneNode* pNode = pSmgr->addAnimatedMeshSceneNode(mesh);
		if (pNode)
		{
			//pNode->setScale(vector3df(10.f, 10.f, 10.f));
			pNode->setMaterialFlag(EMF_LIGHTING, false);
			//pNode->setMaterialFlag(EMF_ZBUFFER, false);
			pNode->setMD2Animation(scene::EMAT_STAND);
			pNode->setMaterialTexture( 0, pDriver->getTexture("Rsrc/sydney.bmp") );
			pNode->setPosition(vector3df(0.0f, -5.f, -55.f));
		}
	}

	// button 
	{
		IGUIEnvironment* env = device.getGUIEnvironment();
		
		video::ITexture* pTexture = pDriver->getTexture("Rsrc/new_game_btn_normal.PNG");	// refcount = 1
		dimension2d<u32> dim = pTexture->getOriginalSize();
		s32 offsetX = width / 2 - dim.Width / 2;
		s32 offsetY = height - dim.Height * 3;
		IGUIButton* pButton = env->addButton(rect<s32>(offsetX, offsetY, offsetX + dim.Width, offsetY + dim.Height), 0, GUI_ID_START_BUTTON);
		pButton->setDrawBorder(false);		
		pButton->setImage(pTexture);										// refcount += 2, means when button released refcount will be 1	
		pButton->setUseAlphaChannel(true);									// 1 will be decreased pDriver->removeAllTextures();

		{
			ITexture* pTexture = pDriver->getTexture("Rsrc/new_game_btn_pressed.PNG");
			pButton->setPressedImage(pTexture);
		}
	}

	// sound test
	IrrSnd.GetSndEngine()->play2D("Rsrc/getout.ogg", true);

	return true;
}
コード例 #8
0
ファイル: LunaLobby.cpp プロジェクト: tecan/Luna
int Luna::lobby() {
   // #ifndef NDEBUG
	// falsify the quit flags
	events.quit = false;
	events.login = false;
	// Flush the gui factory
	guienv->clear();
	smgr->clear();
    device->setEventReceiver ( &events );



	smgr->loadScene ( "./data/models/maps/lobby.irr" );
	//smgr->addCameraSceneNode(0, vector3df(20,100, 0), vector3df(0,100,0), -1);
	//smgr->addCameraSceneNodeFPS();

	ITexture *loginWindow = driver->getTexture ( "./data/textures/lobby/loginBg.png" );

	int buttonPosX = ( resolution[0] / 2 ) - 60;
	int buttonPosY = ( resolution[1] / 100 ) * 80;

	IGUIEditBox *uname = guienv->addEditBox ( L"", rect<s32> ( buttonPosX - 30, buttonPosY - 100, buttonPosX + 150, buttonPosY - 80 ), true, 0, -1 );
	IGUIEditBox *pword = guienv->addEditBox ( L"", rect<s32> ( buttonPosX - 30, buttonPosY - 60, buttonPosX + 150, buttonPosY - 40 ), true, 0, -1 );

	pword->setPasswordBox ( true, L'*' );

	// Load the button textures
	ITexture *menuButtonNormal = driver->getTexture ( "./data/textures/lobby/lobbyButtonNormal.png" );
	ITexture *menuButtonDepressed = driver->getTexture ( "./data/textures/lobby/lobbyButtonDepressed.png" );

	IGUIButton *exitButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY + 50, buttonPosX + 120, buttonPosY + 70 ), 0, 101, L"Exit" );
	exitButton->setImage ( menuButtonNormal );
	exitButton->setPressedImage ( menuButtonDepressed );

	IGUIButton *loginButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY + 0, buttonPosX + 120, buttonPosY + 20 ), 0, 102, L"Login" );
	loginButton->setImage ( menuButtonNormal );
	loginButton->setPressedImage ( menuButtonDepressed );

	IGUIButton *optionsButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY + 25, buttonPosX + 120, buttonPosY + 45 ), 0, 103, L"Options" );
	optionsButton->setImage ( menuButtonNormal );
	optionsButton->setPressedImage ( menuButtonDepressed );

	// Developers login box
#ifdef NDEBUG
	IGUIButton *devButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY - 25, buttonPosX + 120, buttonPosY-10 ), 0, 901, L"Dev Login" );
	devButton->setImage ( menuButtonNormal );
	devButton->setPressedImage ( menuButtonDepressed );
#endif

	// Do the text
	guienv->addStaticText ( L"Account Login.", rect<s32> ( buttonPosX - 60, buttonPosY - 148, buttonPosX + 120, buttonPosY - 138 ) );
	guienv->addStaticText ( L"Username:"******"Password:"******"returned -1\n");
                events.quit=true;
			//    break;
			return 1;
			}
			else if ( ret == 1 ) {
						printf ("returned 1\n");

				wrongPWMessage = guienv->addStaticText ( L"Incorrect username or password.", rect<s32> ( 0, 0, 130, 10 ) );
				wrongPWOK = guienv->addButton ( rect<s32> ( buttonPosX, resolution[1] / 2, buttonPosX + 120, ( resolution[1]/2 ) + 20 ), 0, 105, L"Wrong Password" );
				wrongPWOK->setImage ( menuButtonNormal );
				wrongPWOK->setPressedImage ( menuButtonDepressed );

				loginButton->setEnabled ( false );
				optionsButton->setEnabled ( false );
				exitButton->setEnabled ( false );

				uname->setEnabled ( false );    pword->setEnabled ( false );

				events.login = false;
				wrongPassOK = true;
			}
			else if ( ret == 0 ) {
						printf ("returned 0\n");

				conMessage = guienv->addStaticText ( L"Could not connect to the server, please see the status page", rect<s32> ( 0, 0, 130, 10 ) );
				conOK = guienv->addButton ( rect<s32> ( buttonPosX, resolution[1] / 2, buttonPosX + 120, ( resolution[1]/2 ) + 20 ), 0, 104, L"no server connection" );
				conOK->setImage ( menuButtonNormal );
				conOK->setPressedImage ( menuButtonDepressed );
				loginButton->setEnabled ( false );
				optionsButton->setEnabled ( false );
				exitButton->setEnabled ( false );
				uname->setEnabled ( false );
				pword->setEnabled ( false );
				events.login = false;
				//conRefOK = true;
			}

		}


		driver->beginScene ( true, true, SColor ( 0, 0, 0, 0 ) );
		smgr->drawAll();
            driver->draw2DImage ( loginWindow, core::position2d<s32> ( buttonPosX - 65, buttonPosY - 150 ) );
		guienv->drawAll();
		driver->endScene();

        device->sleep ( 10, true );


	}

	return 0;
//	#endif
}