Esempio n. 1
0
	void HandleExit(UI::Widget* pButton, UI::Manager* pManager)
	{
		UI::Button* pExit = (UI::Button*)pButton;
		pExit->SetCurrentState(pExit->INACTIVE);
		char *pMsg = GetMsg(17);
		new UI::MessageBox(pManager, dwFontID, uStyle, dwCharSize, LoginView::HandleExitBox, pMsg, UI::MSG_OK|UI::MSG_CANCEL, pButton->GetParent()->GetX(), pButton->GetParent()->GetY() - 120);//"Do you want to Exit the game?"
		delete[] pMsg;
		GetMouseCursor().SetState(CRS_DEFAULT);
	}
Esempio n. 2
0
void ProductView::Update() {
	if (wasInstalled_ != IsGameInstalled()) {
		CreateViews();
	}
	if (installButton_) {
		installButton_->SetEnabled(g_GameManager.GetState() == GameManagerState::IDLE);
	}
	if (cancelButton_ && g_GameManager.GetState() != GameManagerState::DOWNLOADING)
		cancelButton_->SetVisibility(UI::V_GONE);
	if (launchButton_)
		launchButton_->SetEnabled(g_GameManager.GetState() == GameManagerState::IDLE);
	View::Update();
}
Esempio n. 3
0
void ProductView::Update(const InputState &input_state) {
	if (wasInstalled_ != IsGameInstalled()) {
		CreateViews();
	}
	if (installButton_) {
		installButton_->SetEnabled(!g_GameManager.IsInstallInProgress());
	}
	View::Update(input_state);
}
Esempio n. 4
0
UI::EventReturn ProductView::OnInstall(UI::EventParams &e) {
	std::string zipUrl;
	if (entry_.downloadURL.empty()) {
		// Construct the URL, easy to predict from our server
		zipUrl = storeBaseUrl + "files/" + entry_.file + ".zip";
	} else {
		// Use the provided URL, for external hosting.
		zipUrl = entry_.downloadURL;
	}
	if (installButton_) {
		installButton_->SetEnabled(false);
	}
	if (cancelButton_) {
		cancelButton_->SetVisibility(UI::V_VISIBLE);
	}
	INFO_LOG(SYSTEM, "Triggering install of %s", zipUrl.c_str());
	g_GameManager.DownloadAndInstall(zipUrl);
	return UI::EVENT_DONE;
}
Esempio n. 5
0
void ModelViewer::SetupFilePicker()
{
	UI::Context *c = m_ui.Get();

	UI::List *list = c->List();
	UI::Button *quitButton = c->Button();
	UI::Button *loadButton = c->Button();
	quitButton->SetInnerWidget(c->Label("Quit"));
	loadButton->SetInnerWidget(c->Label("Load"));

	std::vector<std::string> models;
	collect_models(models);

	for (std::vector<std::string>::const_iterator it = models.begin(); it != models.end(); ++it) {
		list->AddOption(*it);
	}
	UI::Widget *fp =
	c->Grid(UI::CellSpec(1,3,1), UI::CellSpec(1,3,1))
		->SetCell(1,1,
			c->VBox(10)
				->PackEnd(c->Label("Select a model"))
				->PackEnd(c->Expand(UI::Expand::BOTH)->SetInnerWidget(c->Scroller()->SetInnerWidget(list)))
				->PackEnd(c->Grid(2,1)->SetRow(0, UI::WidgetSet(
					c->Align(UI::Align::LEFT)->SetInnerWidget(loadButton),
					c->Align(UI::Align::RIGHT)->SetInnerWidget(quitButton)
				)))
		);

	m_logScroller->Layout(); //issues without this
	c->SetInnerWidget(c->Grid(2,1)
		->SetRow(0, UI::WidgetSet(fp, m_logScroller.Get()))
	);

	c->Layout();

	loadButton->onClick.connect(sigc::bind(sigc::mem_fun(*this, &ModelViewer::OnPickModel), list));
	quitButton->onClick.connect(sigc::mem_fun(*this, &ModelViewer::OnQuit));
}
Esempio n. 6
0
void ProductView::CreateViews() {
	using namespace UI;
	Clear();

	if (!entry_.iconURL.empty()) {
		Add(new HttpImageFileView(&g_DownloadManager, ResolveUrl(storeBaseUrl, entry_.iconURL), IS_FIXED))->SetFixedSize(144, 88);
	}
	Add(new TextView(entry_.name));
	Add(new TextView(entry_.author));

	I18NCategory *st = GetI18NCategory("Store");
	I18NCategory *di = GetI18NCategory("Dialog");
	wasInstalled_ = IsGameInstalled();
	if (!wasInstalled_) {
		installButton_ = Add(new Button(st->T("Install")));
		installButton_->OnClick.Handle(this, &ProductView::OnInstall);
	} else {
		installButton_ = nullptr;
		Add(new TextView(st->T("Already Installed")));
		Add(new Button(st->T("Uninstall")))->OnClick.Handle(this, &ProductView::OnUninstall);
		launchButton_ = new Button(st->T("Launch Game"));
		launchButton_->OnClick.Handle(this, &ProductView::OnLaunchClick);
		Add(launchButton_);
	}

	cancelButton_ = Add(new Button(di->T("Cancel")));
	cancelButton_->OnClick.Handle(this, &ProductView::OnCancel);
	cancelButton_->SetVisibility(V_GONE);

	// Add star rating, comments etc?
	Add(new TextView(entry_.description));

	float size = entry_.size / (1024.f * 1024.f);
	char temp[256];
	sprintf(temp, "%s: %.2f %s", st->T("Size"), size, st->T("MB"));

	Add(new TextView(temp));
}
Esempio n. 7
0
void PluginLoader::ButtonCallback(UI::Button& button)
{
	m_buttonPressed = button.GetText();
}
Esempio n. 8
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);
	}
Esempio n. 9
0
void MakeGUI()
{
    String DefaultScreen = "DefaultScreen";
    UI::UIManager* GUI = static_cast<UI::UIManager*>( TheEntresol->GetManager(ManagerBase::MT_UIManager) );
    Graphics::Viewport* UIViewport = static_cast<Graphics::GraphicsManager*>( TheEntresol->GetManager(ManagerBase::MT_GraphicsManager) )->GetGameWindow(0)->GetViewport(0);
    GUI->LoadMTA("EngineDemo_Menu.mta","Group1");
    GUI->AddAutoRegisterCode(Input::MetaCode(Input::BUTTON_PRESSING,Input::MOUSEBUTTON_1));
    GUI->EnableButtonAutoRegister(true);
    UI::Screen* DScreen = GUI->CreateScreen(DefaultScreen, "EngineDemo_Menu", UIViewport,0);

    ColourValue Transparent(0.0,0.0,0.0,0.0);
    ColourValue Black(0.0,0.0,0.0,1.0);
    ColourValue TransBlack(0.0,0.0,0.0,0.3);

    ColourValue ButtonColour(0.6,0.2,0.2,1.0);
    ColourValue HoveredButtonColour(0.8,0.7,0.05,1.0);
    ColourValue MenuColour(0.4,0.8,0.3,1.0);

    //Build the HUD
    UI::StackButton* MenuAccess = DScreen->CreateStackButton("D_MenuAccess",UI::UnifiedRect(0.008,0.932,0.14,0.06));
    UI::SingleImageLayer* AccessBackground = MenuAccess->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Normal,0));
    AccessBackground->SetColour(ButtonColour);
    UI::SingleImageLayer* AccessHoveredBackground = MenuAccess->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Hovered,0));
    AccessHoveredBackground->SetColour(HoveredButtonColour);
    UI::SingleLineTextLayer* AccessText = MenuAccess->CreateSingleLineTextLayer(1,1);
    AccessText->HorizontallyAlign(UI::LA_Center);
    AccessText->VerticallyAlign(UI::LA_Center);
    AccessText->SetDefaultFont("Ubuntu-14");
    AccessText->SetText("Menu");
    DScreen->AddChild(MenuAccess,1);

    UI::Widget* CurFPS = DScreen->CreateWidget("D_CurFPS",UI::UnifiedRect(0.16,0.008,0.06,0.065));
    UI::SingleLineTextLayer* CurFPSText = CurFPS->CreateSingleLineTextLayer(1,1);
    CurFPSText->HorizontallyAlign(UI::LA_TopLeft);
    CurFPSText->VerticallyAlign(UI::LA_Center);
    CurFPSText->SetDefaultFont("Ubuntu-14");
    CurFPSText->SetText("0.0");
    DScreen->AddChild(CurFPS,2);

    UI::Widget* CurFPSStat = DScreen->CreateWidget("D_CurFPSStat",UI::UnifiedRect(0.008,0.008,0.15,0.065));
    UI::SingleLineTextLayer* CurFPSStatText = CurFPSStat->CreateSingleLineTextLayer(1,1);
    CurFPSStatText->HorizontallyAlign(UI::LA_TopLeft);
    CurFPSStatText->VerticallyAlign(UI::LA_Center);
    CurFPSStatText->SetDefaultFont("Ubuntu-14");
    CurFPSStatText->SetText("Current FPS: ");
    DScreen->AddChild(CurFPSStat,3);

    UI::Widget* AvFPS = DScreen->CreateWidget("D_AvFPS",UI::UnifiedRect(0.16,0.081,0.06,0.065));
    UI::SingleLineTextLayer* AvFPSText = AvFPS->CreateSingleLineTextLayer(1,1);
    AvFPSText->HorizontallyAlign(UI::LA_TopLeft);
    AvFPSText->VerticallyAlign(UI::LA_Center);
    AvFPSText->SetDefaultFont("Ubuntu-14");
    AvFPSText->SetText("0.0");
    DScreen->AddChild(AvFPS,4);

    UI::Widget* AvFPSStat = DScreen->CreateWidget("D_AvFPSStat",UI::UnifiedRect(0.008,0.081,0.15,0.065));
    UI::SingleLineTextLayer* AvFPSStatText = AvFPSStat->CreateSingleLineTextLayer(1,1);
    AvFPSStatText->HorizontallyAlign(UI::LA_TopLeft);
    AvFPSStatText->VerticallyAlign(UI::LA_Center);
    AvFPSStatText->SetDefaultFont("Ubuntu-14");
    AvFPSStatText->SetText("Average FPS: ");
    DScreen->AddChild(AvFPSStat,5);
    //End of HUD
    //Build the Menu
    UI::MenuEntry* DemoMenu = DScreen->CreateMenuEntry("D_Menu",UI::UnifiedRect(0.35,0.27,0.3,0.45));
    UI::SingleImageLayer* DemoMenuBackground = DemoMenu->CreateSingleImageLayer(1,1);
    DemoMenuBackground->SetColour(MenuColour);
    DScreen->AddChild(DemoMenu,6);

    UI::StackButton* ReturnButton = DScreen->CreateStackButton("D_Return",UI::UnifiedRect(0.10,0.56,0.80,0.16));
    UI::SingleImageLayer* ReturnBackground = ReturnButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Normal,0));
    ReturnBackground->SetColour(ButtonColour);
    UI::SingleImageLayer* ReturnHoveredBackground = ReturnButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Hovered,0));
    ReturnHoveredBackground->SetColour(HoveredButtonColour);
    UI::SingleLineTextLayer* ReturnText = ReturnButton->CreateSingleLineTextLayer(1,1);
    ReturnText->HorizontallyAlign(UI::LA_Center);
    ReturnText->VerticallyAlign(UI::LA_Center);
    ReturnText->SetDefaultFont("Ubuntu-14");
    ReturnText->SetText("Return To Demo");
    DemoMenu->AddChild(ReturnButton,1);

    UI::Button* GameExitButton = DScreen->CreateButton("D_Exit",UI::UnifiedRect(0.10,0.78,0.80,0.16));
    UI::SingleImageLayer* GameExitBackground = GameExitButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Normal,0));
    GameExitBackground->SetColour(ButtonColour);
    UI::SingleImageLayer* GameExitHoveredBackground = GameExitButton->CreateSingleImageLayer(UI::GroupOrderEntry(UI::Widget::WG_Hovered,0));
    GameExitHoveredBackground->SetColour(HoveredButtonColour);
    UI::SingleLineTextLayer* GameExitText = GameExitButton->CreateSingleLineTextLayer(1,1);
    GameExitText->HorizontallyAlign(UI::LA_Center);
    GameExitText->VerticallyAlign(UI::LA_Center);
    GameExitText->SetDefaultFont("Ubuntu-14");
    GameExitText->SetText("Exit Demo");
    DemoMenu->AddChild(GameExitButton,2);

    DemoMenu->SetPushButton(MenuAccess);
    DemoMenu->SetPopButton(ReturnButton);
    //End of Menu
}
Esempio n. 10
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;
	}