Exemple #1
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();
}
Exemple #2
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;
}
Exemple #3
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));
}