Beispiel #1
0
PlaceDialog::PlaceDialog(QWidget *parent, int placeID) :
    QDialog(parent),
    ui(new Ui::PlaceDialog),
    m_placeID(placeID),
    m_gc(Q_NULLPTR)
{
    ui->setupUi(this);

    if (m_placeID != -1) { // editting, fill the controls
        populateControls();
    }

    m_mapWidget = new MapWidget(this);
    m_mapWidget->setMinimumSize(QSize(300, 200));
    ui->verticalLayout->insertWidget(1, m_mapWidget, 1);
    if (m_placeID != -1) {
        updateMapCenter();
    }

    m_gc = new OsmGeoCoder(this);
    m_placeMenu = new QMenu(this);

    connect(ui->sbLat, SIGNAL(valueChanged(double)), this, SLOT(updateMapCenter()));
    connect(ui->sbLon, SIGNAL(valueChanged(double)), this, SLOT(updateMapCenter()));
    connect(ui->btnGeoCode, &QPushButton::clicked, this, &PlaceDialog::geocode);
    connect(this, &PlaceDialog::accepted, this, &PlaceDialog::save);

    qDebug() << "Editting place with ID:" << m_placeID;
}
Beispiel #2
0
void movePerso(Game *game, SDL_Keycode key)
{
	switch (key) {
		case SDL_SCANCODE_UP:
			updateMapCenter(game->map, 0, -1);
			break;
			
		case SDL_SCANCODE_DOWN :
			updateMapCenter(game->map, 0, 1);
			break;
			
		case SDL_SCANCODE_LEFT :
			updateMapCenter(game->map, -1, 0);
			break;
			
		case SDL_SCANCODE_RIGHT :
			updateMapCenter(game->map, 1, 0);
			break;
	}
	
	drawGame(game);
}