Ejemplo n.º 1
0
void StackedInputWidget::gotPasswordInput()
{
    m_passwordWidget->selectAll();
    QString input = m_passwordWidget->text() + "\n";
    m_passwordWidget->clear();
    emit sendUserInput(input);
}
Ejemplo n.º 2
0
void StackedInputWidget::gotMultiLineInput(const QString &input)
{
    QString str = QString(input).append("\n");
    emit sendUserInput(str);
    // REVISIT: Make color configurable
    QString displayStr = QString("\033[0;33m").append(input).append("\033[0m\n");
    emit displayMessage(displayStr);
}
Ejemplo n.º 3
0
void Client::handleReadInput(const boost::system::error_code& error, const size_t bytes_transferred) {
    if(error) {
        // std::cout << boost::system::system_error(error).what() << std::endl;
        return;
    }
    std::istream stringCreator(&buffer);
    char bufferData[1024];

    stringCreator.getline(bufferData, bytes_transferred);

    std::string message(bufferData);

    buffer.consume(bytes_transferred);

    sendUserInput(message);
    readInput();
}
Ejemplo n.º 4
0
void CGame::run() {

	// Init window
	SCREEN_HEIGHT = sf::VideoMode::getDesktopMode().height;
	SCREEN_WIDTH = sf::VideoMode::getDesktopMode().width;
	// Set window fullscreen
	if (config.isFullScreen()) {
		window.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Asteroids",
				sf::Style::Fullscreen);
	} else {
		window.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Asteroids",
				sf::Style::Close);
	}
	window.setIcon(96, 96,
			ResourceHandler.loadImage("images/icon.png")->getPixelsPtr());
	// This will regulate the draw rate and the amount of the time the thread sleeps
	window.setFramerateLimit(FRAMES_PER_SECOND);
	gameView.setSize(800, 600);
	gameView.setCenter(400, 300);
	window.setView(gameView);

	// Game speed control
	int loops;
	sf::Clock gameClock;
	float nextTick = gameClock.getElapsedTime().asMilliseconds();
	float sendAc = 0;
	float sendRate = 30;
	sf::Clock delta;

	while (window.isOpen()) {
		sf::Event event;
		while (window.pollEvent(event)) {
			if (event.type == sf::Event::Closed)
				window.close();
		}

		switch (getState()) {
		case INIT:
			// Error message here.
			break;
		case MENU:

			// Draw the background.
			window.clear();
			window.draw(background);
			// Draw menu buttons.
			handleButton(
					gameMenu.update(
							window.mapPixelToCoords(
									sf::Mouse::getPosition(window)), event));

			gameMenu.draw(&window);
			break;

		case LOGIN:
			window.clear();
			window.draw(background);
			handleButton(
					loginMenu.update(
							window.mapPixelToCoords(
									sf::Mouse::getPosition(window)), event));

			loginMenu.draw(&window);
			break;

		case PLAYING:
			loops = 0;
			while (gameClock.getElapsedTime().asMilliseconds() > nextTick
					&& loops < MAX_FRAMESKIP) {
				receiveServerUpdate();
				sendUserInput();
				//sendHeartbeat();
				gameClient.update(1.0f/TICKS_PER_SECOND);
				//gameClient.printStats();
				nextTick += SKIP_TICKS;
				loops++;
			}
			window.clear();
			window.draw(background);
			gameWorld.draw(&window,
					((gameClock.getElapsedTime().asMilliseconds() + SKIP_TICKS
							- nextTick) / ( SKIP_TICKS)));
			break;
		case PAUSE:
			break;
		case QUIT:
			return;
			break;
		default:
			// Error message here.
			break;
		}

		window.display();

	}

}