Beispiel #1
0
	void MessageBox::construct(Manager *pManager, uint8_t uStyle, sf::String sText, uint8_t uButtons)
	{
		//Save Currently Focused Widget - We need to grab focus to the messagebox so this is needed
		pFocusPrevious = pManager->GetFocused();

		//Setup Focus
		SetFocusable(true);
		pManager->AddFocus(this);
		pManager->SwitchFocus(this);

		//Assign Texture and Drag Area
		SetTexture("win_msgbox.bmp");
		SetDragArea(0, 0, GetWidth(), 20);

		//Now for the Buttons
		int32_t x = -4;
		if ((uButtons & MSG_CANCEL) != 0)
		{
			UI::Button *pButton = new UI::Button(MSGBOX_NBTN, x, -4);
			pButton->SetTexture("btn_cancel.bmp", pButton->INACTIVE );
			pButton->SetTexture("btn_cancel_a.bmp", pButton->ACTIVE );
			pButton->SetTexture("btn_cancel_b.bmp", pButton->PRESSED);
			pButton->SetCallback(MessageBox::SelectButton);
			pButton->SetAlign(UI::RIGHT, UI::BOTTOM);
			x -= (4 + pButton->GetWidth());
			AddChild(pButton);
		}

		if ((uButtons & MSG_OK) != 0)
		{
			UI::Button *pButton = new UI::Button(MSGBOX_PBTN, x, -4);
			pButton->SetTexture("btn_ok.bmp", pButton->INACTIVE );
			pButton->SetTexture("btn_ok_a.bmp", pButton->ACTIVE );
			pButton->SetTexture("btn_ok_b.bmp", pButton->PRESSED);
			pButton->SetCallback(MessageBox::SelectButton);
			pButton->SetAlign(UI::RIGHT, UI::BOTTOM);
			AddChild(pButton);
		}

		//Set selected as NONE - to avoid mischecks
		selected = MSG_NONE;

		//Add the Text
		sf::Vector2i vTextPos = sf::Vector2i(20, GetHeight()/2);
		SetColor(sf::Color::Blue, FOREGROUND);
		UpdateTextVA(dwFontID, sText, uStyle, dwCharSize, GetWidth(), 5, 0, vTextPos);
	}
Beispiel #2
0
	void Create(UI::Manager &mgr)
	{
		if (bLoggedIn && !bSaveUser)
		{
			userName = "";
		}
		//Window Frame
		pFrame = new UI::Frame(LV_FRAME, 0, 0);
		pFrame->SetTexture("login_interface\\win_login.bmp");
		pFrame->SetAlign(UI::CENTER, UI::MIDDLE);
		pFrame->SetDragArea(0, 0, pFrame->GetWidth(), pFrame->GetHeight());
		mgr.AddChild(pFrame);

		//Username Input
		UI::TextBox* pUser = new UI::TextBox(LV_USERIN, uStyle, 90, 29, 127, 18);
		pFrame->AddChild(pUser);
		pUser->SetColor(sf::Color::Blue, UI::FOREGROUND);
		pUser->SetFontID(dwFontID);
		pUser->SetCharSize(dwCharSize);
		pUser->SetCornerRadius(1);
		pUser->SetText(userName);
		mgr.AddFocus(pUser);

		//Password Input
		UI::TextBox* pPass = new UI::TextBox(LV_PASSIN, uStyle, 90, 61, 127, 18);
		pFrame->AddChild(pPass);
		pPass->SetColor(sf::Color::Blue, UI::FOREGROUND);
		pPass->SetFontID(dwFontID);
		pPass->SetCharSize(dwCharSize);
		pPass->SetCornerRadius(1);
		pPass->SetPassChar('*');
		mgr.AddFocus(pPass);

		//Save User CheckButton
		UI::CheckButton* pSave = new UI::CheckButton(LV_SAVECHK, pUser->GetPosition(false).x + pUser->GetWidth() + 15 , 33);
		pSave->SetTexture("login_interface\\chk_saveoff.bmp", pSave->INACTIVE);
		pSave->SetTexture("login_interface\\chk_saveon.bmp",  pSave->ACTIVE);
		pSave->SetChecked(bSaveUser);
		pFrame->AddChild(pSave);

		//OK Button
		UI::Button* pLogin   = new UI::Button(LV_LOGINBTN,   -49, -4);
		pLogin->SetAlign(UI::RIGHT, UI::BOTTOM);
		pLogin->SetTexture("login_interface\\btn_connect.bmp", pLogin->INACTIVE);
		pLogin->SetTexture("login_interface\\btn_connect_a.bmp", pLogin->ACTIVE);
		pLogin->SetTexture("login_interface\\btn_connect_b.bmp", pLogin->PRESSED);
		pLogin->SetCallback(LoginView::HandleLogin);
		pFrame->AddChild(pLogin);

		//Exit Button
		UI::Button* pExit = new UI::Button(LV_EXITBTN,  -4, -4);
		pExit->SetAlign(UI::RIGHT, UI::BOTTOM);
		pExit->SetTexture("login_interface\\btn_exit.bmp", pExit->INACTIVE);
		pExit->SetTexture("login_interface\\btn_exit_a.bmp", pExit->ACTIVE);
		pExit->SetTexture("login_interface\\btn_exit_b.bmp", pExit->PRESSED);
		pExit->SetCallback(LoginView::HandleExit);
		pFrame->AddChild(pExit);

		mgr.SwitchFocus(pUser);
		bLoggedIn = false;
		bExitGame = false;
	}