Exemplo n.º 1
0
void UI::render ()
{
	std::vector<UIWindow*> renderOrder;
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		renderOrder.push_back(window);
		// we can skip here
		if (window->isFullscreen())
			break;
	}

	for (std::vector<UIWindow*>::reverse_iterator i = renderOrder.rbegin(); i != renderOrder.rend(); ++i) {
		(*i)->render(0, 0);
	}

	// TODO: move cursor and progress bar into frontend
	if (_progress.active) {
		renderProgress();
	}

	if (_cursorX != -1 && _cursorY != -1 && _cursor) {
		const int w = _mouseCursor->getWidth();
		const int h = _mouseCursor->getHeight();
		_frontend->renderImage(_mouseCursor.get(), _cursorX, _cursorY, w, h, 0, 1.0f);
	}

	const bool debug = Config.getConfigVar("debugui")->getBoolValue();
	if (debug) {
		const BitmapFontPtr& font = getFont();
		const std::string s = String::format("%i:%i", _cursorX, _cursorY);
		font->print(s, colorWhite, 0, 0);
	}
}
Exemplo n.º 2
0
void UI::onMouseButtonPress (int32_t x, int32_t y, uint8_t button)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onMouseButtonPress(_cursorX, _cursorY, button))
			break;
		if (window->isModal() || window->isFullscreen())
			break;
	}
}
Exemplo n.º 3
0
void UI::onControllerButtonPress (const std::string& button)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onControllerButtonPress(_cursorX, _cursorY, button))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "controller button " + button + " was pressed and not handled");
}
Exemplo n.º 4
0
void UI::onGestureRecord (int64_t gestureId)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onGestureRecord(gestureId))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "gesture record event was not handled");
}
Exemplo n.º 5
0
void UI::onGesture (int64_t gestureId, float error, int32_t numFingers)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onGesture(gestureId, error, numFingers))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "gesture event was not handled");
}
Exemplo n.º 6
0
void UI::onMultiGesture (float theta, float dist, int32_t numFingers)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onMultiGesture(theta, dist, numFingers))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "multi gesture event was not handled");
}
Exemplo n.º 7
0
void UI::onJoystickButtonPress (uint8_t button)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onJoystickButtonPress(_cursorX, _cursorY, button))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, String::format("joystick button %i was pressed and not handled", (int)button));
}
Exemplo n.º 8
0
bool UI::onTextInput (const std::string& text)
{
	if (_restart)
		return false;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onTextInput(text))
			return true;
		if (window->isModal() || window->isFullscreen())
			break;
	}
	return false;
}
Exemplo n.º 9
0
void UI::onMouseWheel (int32_t x, int32_t y)
{
	if (_restart)
		return;

	GETSCALE_W(x);
	GETSCALE_H(y);
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onMouseWheel(x, y))
			break;
		if (window->isModal() || window->isFullscreen())
			break;
	}
}
Exemplo n.º 10
0
bool UI::onKeyPress (int32_t key, int16_t modifier)
{
	if (_restart)
		return false;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onKeyPress(key, modifier))
			return true;
		if (window->isModal() || window->isFullscreen())
			break;
	}

	return false;
}
Exemplo n.º 11
0
bool UI::onFingerPress (int64_t finger, float x, float y)
{
	if (_restart)
		return false;

	const uint16_t _x = _frontend->getCoordinateOffsetX() + x * _frontend->getWidth();
	const uint16_t _y = _frontend->getCoordinateOffsetY() + y * _frontend->getHeight();
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onFingerPress(finger, _x, _y))
			return true;
		if (window->isModal() || window->isFullscreen())
			break;
	}
	return false;
}
Exemplo n.º 12
0
void UI::onFingerMotion (int64_t finger, float x, float y, float dx, float dy)
{
	if (_restart)
		return;

	const uint16_t _x = _frontend->getCoordinateOffsetX() + x * _frontend->getWidth();
	const uint16_t _y = _frontend->getCoordinateOffsetY() + y * _frontend->getHeight();
	const int16_t _dx = dx * _frontend->getWidth();
	const int16_t _dy = dy * _frontend->getHeight();
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onFingerMotion(finger, _x, _y, _dx, _dy))
			break;
		if (window->isModal() || window->isFullscreen())
			break;
	}
}
Exemplo n.º 13
0
void UI::onJoystickMotion (bool horizontal, int v)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onJoystickMotion(horizontal, v))
			return;
		if (window->isModal() || window->isFullscreen())
			break;
	}

	if (Config.getBindingsSpace() != BINDINGS_UI)
		return;

	if (_time - _lastJoystickMoveTime < 350 || horizontal) {
		_lastJoystickMovementValue = v;
		return;
	}

	// skip focus change if we go back to initial position
	if (v > 0 && v < _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	} else if (v < 0 && v > _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	}

	// now check whether our value is bigger than our movement delta
	const int delta = 2000;
	if (v < -delta) {
		focusPrev();
	} else if (v > delta) {
		focusNext();
	}

	_lastJoystickMoveTime = _time;
	_lastJoystickMovementValue = v;
}
Exemplo n.º 14
0
void UI::onMouseMotion (int32_t x, int32_t y, int32_t relX, int32_t relY)
{
	if (_restart)
		return;

	GETSCALE_W(relX);
	GETSCALE_H(relY);
	_frontend->setCursorPosition(_cursorX + relX, _cursorY + relY);
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		const bool focus = window->checkFocus(_cursorX, _cursorY);
		if (focus) {
			window->onMouseMotion(_cursorX, _cursorY, relX, relY);
			break;
		}
		if (window->isModal() || window->isFullscreen())
			break;
	}
}