示例#1
0
UINodeLabel* UIHelpWindow::addString (const std::string& string, const std::string& font)
{
	const UINode *node = _nodes.empty() ? nullptr : _nodes.back();
	const float pos = (node != nullptr ? node->getRight() : 0.0f) + _iconGap;

	UINodeLabel *labelNode = new UINodeLabel(_frontend, string, getFont(font));
	labelNode->setPos(pos, _currentY + (node != nullptr ? node->getHeight() / 2.0f : 0.0f) - labelNode->getHeight() / 2.0f);
	add(labelNode);
	return labelNode;
}
示例#2
0
IntroTypeDescription::IntroTypeDescription(UINode* parent, IFrontend* frontend, const EntityType& type, const Animation& animation, const std::string& text) :
		UINode(frontend) {
	setLayout(new UIHBoxLayout(0.01f, false, NODE_ALIGN_MIDDLE));
	UINodeSprite* sprite = new UINodeSprite(frontend, type, animation);
	const float wp = parent->getWidth() / 5.0f;
	sprite->setAspectRatioSize(wp, wp);
	add(sprite);
	UINodeLabel* label = new UINodeLabel(frontend, text, getFont(HUGE_FONT));
	label->setColor(colorBlack);
	add(label);
}
void UIGameHelpWindow::addOuyaButton (UINode *panel, const std::string& texture, const std::string& title)
{
	UINode* hbox = createHPanel();
	UINode* imageNode = new UINode(_frontend);
	imageNode->setImage(texture);
	hbox->add(imageNode);
	UINodeLabel *label = new UINodeLabel(_frontend, title);
	label->setColor(colorWhite);
	label->setPos(0.0f, imageNode->getHeight() / 2.0f - label->getHeight() / 2.0f);
	hbox->add(label);
	panel->add(hbox);
}
示例#4
0
IntroBarDescription::IntroBarDescription(IFrontend* frontend, const std::string& text) :
		UINode(frontend) {
	setLayout(new UIHBoxLayout(0.01f, false, NODE_ALIGN_MIDDLE));
	const float barHeight = 12.0f / _frontend->getHeight();
	const float barWidth = 102.0f / _frontend->getWidth();
	UINodeBar* timeBar = new UINodeBar(_frontend);
	timeBar->setMax(100);
	timeBar->setCurrent(100);
	timeBar->setBorder(true);
	timeBar->setBorderColor(colorWhite);
	timeBar->setSize(barWidth, barHeight);
	add(timeBar);
	UINodeLabel* label = new UINodeLabel(frontend, text, getFont(HUGE_FONT));
	label->setColor(colorBlack);
	add(label);
}
UIGameFinishedWindow::UIGameFinishedWindow (IFrontend *frontend) :
		UIWindow(UI_WINDOW_GAMEFINISHED, frontend)
{
	_musicFile = "music-win";
	setInactiveAfterPush();

	UINodeBackground *background = new UINodeBackground(frontend, "", false);
	if (System.hasTouch() && !wantBackButton())
		background->setOnActivate(CMD_UI_POP);
	add(background);

	UINodeLabel *won = new UINodeLabel(frontend, tr("You won!"));
	won->setAlignment(NODE_ALIGN_MIDDLE | NODE_ALIGN_CENTER);
	won->setFont(LARGE_FONT);
	won->setColor(colorWhite);
	add(won);

	// TODO:

	if (!wantBackButton())
		return;

	add(new UINodeBackButton(frontend, background));
}
示例#6
0
UIMainWindow::UIMainWindow (IFrontend *frontend, ServiceProvider& serviceProvider) :
		UIWindow(UI_WINDOW_MAIN, frontend, WINDOW_FLAG_ROOT)
{
	add(new UINodeMainBackground(frontend, false));
	const SpritePtr& mammutSprite = UI::get().loadSprite("ui-npc-mammut");
	_mammut = new UINodeSprite(frontend, mammutSprite->getMaxWidth(), mammutSprite->getMaxHeight());
	_mammut->addSprite(mammutSprite);

	const SpritePtr& grandPaSprite = UI::get().loadSprite("ui-npc-grandpa");
	_grandpa = new UINodeSprite(frontend, grandPaSprite->getMaxWidth(), grandPaSprite->getMaxHeight());
	_grandpa->addSprite(grandPaSprite);

	const SpritePtr& playerSprite = UI::get().loadSprite("ui-player");
	_player = new UINodeSprite(frontend, playerSprite->getMaxWidth(), playerSprite->getMaxHeight());
	_player->addSprite(playerSprite);

	add(_mammut);
	add(_grandpa);
	add(_player);

	const float padding = 10.0f / static_cast<float>(_frontend->getHeight());
	UINode *panel = new UINode(_frontend, "panelMain");
	UIVBoxLayout *layout = new UIVBoxLayout(padding, true);
	panel->setLayout(layout);
	panel->setAlignment(NODE_ALIGN_MIDDLE | NODE_ALIGN_CENTER);
	panel->setPadding(padding);

	UINodeMainButton *campaign = new UINodeMainButton(_frontend, tr("Campaign"));
	campaign->addListener(UINodeListenerPtr(new OpenWindowListener(UI_WINDOW_CAMPAIGN)));
	panel->add(campaign);

#ifndef NONETWORK
	if (Config.isNetwork()) {
		UINodeMainButton *multiplayer = new UINodeMainButton(_frontend, tr("Multiplayer"));
		multiplayer->addListener(UINodeListenerPtr(new OpenWindowListener(UI_WINDOW_MULTIPLAYER)));
		panel->add(multiplayer);
	}
#endif

	UINodeMainButton *settings = new UINodeMainButton(_frontend, tr("Settings"));
	settings->addListener(UINodeListenerPtr(new OpenWindowListener(UI_WINDOW_SETTINGS)));
	panel->add(settings);

	if (System.supportPayment()) {
		UINodeMainButton *payment = new UINodeMainButton(_frontend, tr("Extras"));
		payment->addListener(UINodeListenerPtr(new OpenWindowListener(UI_WINDOW_PAYMENT)));
		panel->add(payment);
	}

	if (System.supportGooglePlay()) {
		UINodeButtonImage *googlePlay = new UINodeGooglePlayButton(_frontend);
		googlePlay->setPadding(padding);
		add(googlePlay);
	}

#ifndef STEAMLINK
	if (System.supportsUserContent()) {
		UINodeMainButton *editor = new UINodeMainButton(_frontend, tr("Editor"));
		editor->addListener(UINodeListenerPtr(new OpenWindowListener(UI_WINDOW_EDITOR)));
		panel->add(editor);
	}

	UINodeMainButton *twitter = new UINodeMainButton(_frontend, tr("Twitter"));
	twitter->addListener(UINodeListenerPtr(new OpenURLListener(_frontend, "https://twitter.com/MartinGerhardy")));
	panel->add(twitter);

	UINodeMainButton *homepage = new UINodeMainButton(_frontend, tr("Homepage"));
	homepage->addListener(UINodeListenerPtr(new OpenURLListener(_frontend, "http://caveproductions.org/")));
	panel->add(homepage);
#endif

	UINodeMainButton *help = new UINodeMainButton(_frontend, tr("Help"));
	help->addListener(UINodeListenerPtr(new OpenWindowListener(UI_WINDOW_HELP)));
	panel->add(help);

#if 0
#ifdef __EMSCRIPTEN__
	UINodeMainButton *fullscreen = new UINodeMainButton(_frontend, tr("Fullscreen"));
	fullscreen->addListener(UINodeListenerPtr(new EmscriptenFullscreenListener()));
	panel->add(fullscreen);
#endif
#endif

	UINodeMainButton *quit = new UINodeMainButton(_frontend, tr("Quit"));
#ifdef __EMSCRIPTEN__
	quit->addListener(UINodeListenerPtr(new OpenURLListener(_frontend, "http://caveproductions.org/", false)));
#else
	quit->addListener(UINodeListenerPtr(new QuitListener()));
#endif
	panel->add(quit);

	add(panel);

	Application& app = Singleton<Application>::getInstance();
	UINodeLabel *versionLabel = new UINodeLabel(_frontend, app.getPackageName() + " " + app.getVersion());
	versionLabel->setAlignment(NODE_ALIGN_BOTTOM|NODE_ALIGN_RIGHT);
	versionLabel->setColor(colorWhite);
	versionLabel->setPadding(getScreenPadding());
	add(versionLabel);
}