TILE_TAXIWAY_CORNER_GRASS_3 added to accepted tiles list.
Building edition is now supported on MapEditor! LEVEL2.LVL now has some buildings laying around.
This commit is contained in:
parent
f8f976763b
commit
3de2130b60
BIN
Bin/AIRPORT.bin
BIN
Bin/AIRPORT.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1519,15 +1519,6 @@ static void GameLoadLevel(const char* path)
|
||||||
levelBuffer[k] |= (ptrBuffer[j] << 8);
|
levelBuffer[k] |= (ptrBuffer[j] << 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < (GameLevelSize * sizeof (uint16_t)); i++)
|
|
||||||
{
|
|
||||||
Serial_printf("levelBuffer[%d] = 0x%02X\n", i, levelBuffer[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ******************************************************************************************
|
/* ******************************************************************************************
|
||||||
|
@ -3308,7 +3299,8 @@ bool GamePathToTile(TYPE_PLAYER* const ptrPlayer, TYPE_FLIGHT_DATA* const ptrFli
|
||||||
TILE_TAXIWAY_4WAY_CROSSING,
|
TILE_TAXIWAY_4WAY_CROSSING,
|
||||||
TILE_PARKING_2,
|
TILE_PARKING_2,
|
||||||
TILE_RWY_HOLDING_POINT,
|
TILE_RWY_HOLDING_POINT,
|
||||||
TILE_RWY_HOLDING_POINT_2
|
TILE_RWY_HOLDING_POINT_2,
|
||||||
|
TILE_TAXIWAY_CORNER_GRASS_3
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
@ -3452,6 +3444,7 @@ bool GamePathToTile(TYPE_PLAYER* const ptrPlayer, TYPE_FLIGHT_DATA* const ptrFli
|
||||||
TILE_PARKING_2 | TILE_MIRROR_FLAG,
|
TILE_PARKING_2 | TILE_MIRROR_FLAG,
|
||||||
TILE_RWY_HOLDING_POINT | TILE_MIRROR_FLAG,
|
TILE_RWY_HOLDING_POINT | TILE_MIRROR_FLAG,
|
||||||
TILE_RWY_HOLDING_POINT_2 | TILE_MIRROR_FLAG,
|
TILE_RWY_HOLDING_POINT_2 | TILE_MIRROR_FLAG,
|
||||||
|
TILE_TAXIWAY_CORNER_GRASS_3 | TILE_MIRROR_FLAG
|
||||||
};
|
};
|
||||||
|
|
||||||
if (SystemContains_u8( levelBuffer[ptrPlayer->Waypoints[i]],
|
if (SystemContains_u8( levelBuffer[ptrPlayer->Waypoints[i]],
|
||||||
|
|
|
@ -2,3 +2,9 @@
|
||||||
path = "../../Sprites/BLDNGS1.bmp"
|
path = "../../Sprites/BLDNGS1.bmp"
|
||||||
building0 = "Nothing"
|
building0 = "Nothing"
|
||||||
building1 = "Hangar"
|
building1 = "Hangar"
|
||||||
|
building2 = "ILS"
|
||||||
|
building3 = "ATC Tower"
|
||||||
|
building4 = "ATC Localizer"
|
||||||
|
building5 = "Terminal"
|
||||||
|
building6 = "Terminal2"
|
||||||
|
building7 = "Gate"
|
||||||
|
|
|
@ -26,7 +26,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
|
||||||
connect(&gscene, SIGNAL(positionClicked(QPointF)), this, SLOT(onMapItemClicked(QPointF)));
|
connect(&gscene, SIGNAL(positionClicked(QPointF)), this, SLOT(onMapItemClicked(QPointF)));
|
||||||
connect(&gscene, SIGNAL(noItemSelected(void)), this, SLOT(onNoItemSelected(void)));
|
connect(&gscene, SIGNAL(noItemSelected(void)), this, SLOT(onNoItemSelected(void)));
|
||||||
connect(&gscene, SIGNAL(updateSelectedItem(void)), this, SLOT(onListItemSelected(void)));
|
connect(&gscene, SIGNAL(updateSelectedItem(Qt::MouseButton)), this, SLOT(onListItemSelected(Qt::MouseButton)));
|
||||||
|
|
||||||
// Configure keyboard shortcuts.
|
// Configure keyboard shortcuts.
|
||||||
connect(&tileSet, SIGNAL(activated()), this, SLOT(onListItemSelected(void)));
|
connect(&tileSet, SIGNAL(activated()), this, SLOT(onListItemSelected(void)));
|
||||||
|
@ -39,6 +39,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
foreach (QGraphicsTextItem* it, textItems)
|
foreach (QGraphicsTextItem* it, textItems)
|
||||||
{
|
{
|
||||||
if (it != nullptr)
|
if (it != nullptr)
|
||||||
|
@ -46,6 +47,7 @@ MainWindow::~MainWindow()
|
||||||
delete it;
|
delete it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadBuildingData(void)
|
void MainWindow::loadBuildingData(void)
|
||||||
|
@ -89,14 +91,14 @@ void MainWindow::onShowNumbers(int)
|
||||||
processMapFile(map_buffer);
|
processMapFile(map_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMapItemClicked(QPointF pos)
|
void MainWindow::onMapItemClicked(QPointF position)
|
||||||
{
|
{
|
||||||
QPoint realPos;
|
QPoint realPos;
|
||||||
|
|
||||||
pos.setX(pos.x() - (TILE_SIZE / 2));
|
position.setX(position.x() - (TILE_SIZE / 2));
|
||||||
|
|
||||||
realPos.setX(static_cast<int>(pos.x() + (pos.y() * 2)));
|
realPos.setX(static_cast<int>(position.x() + (position.y() * 2)));
|
||||||
realPos.setY(static_cast<int>((pos.y() * 2) - pos.x()));
|
realPos.setY(static_cast<int>((position.y() * 2) - position.x()));
|
||||||
|
|
||||||
int tile_no = 0;
|
int tile_no = 0;
|
||||||
|
|
||||||
|
@ -114,30 +116,69 @@ void MainWindow::onMapItemClicked(QPointF pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onListItemSelected(void)
|
void MainWindow::onListItemSelected(const Qt::MouseButton button)
|
||||||
{
|
{
|
||||||
foreach (const QListWidgetItem* const it, ui.tileList->selectedItems())
|
QListWidget* listWidget;
|
||||||
|
|
||||||
|
switch (button)
|
||||||
{
|
{
|
||||||
if (it != nullptr)
|
case Qt::LeftButton:
|
||||||
|
listWidget = ui.tileList;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::RightButton:
|
||||||
|
listWidget = ui.buildingList;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
listWidget = nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listWidget != nullptr)
|
||||||
|
{
|
||||||
|
foreach (const QListWidgetItem* const it, listWidget->selectedItems())
|
||||||
{
|
{
|
||||||
if (selected_item != -1)
|
if (it != nullptr)
|
||||||
{
|
{
|
||||||
const int map_buffer_pos = static_cast<int>(DATA_HEADER_SIZE
|
if (selected_item != -1)
|
||||||
+ (static_cast<unsigned long>(selected_item + 1) * sizeof(quint16)));
|
|
||||||
//map_buffer_pos++; // MSB: building data, LSB: terrain data.
|
|
||||||
|
|
||||||
if (map_buffer_pos < map_buffer.count())
|
|
||||||
{
|
{
|
||||||
const char row = static_cast<char>(ui.tileList->row(it));
|
int map_buffer_pos;
|
||||||
|
|
||||||
map_buffer[map_buffer_pos] = row;
|
// MSB: building data, LSB: terrain data.
|
||||||
|
switch (button)
|
||||||
if (ui.mirror_CheckBox->isChecked() )
|
|
||||||
{
|
{
|
||||||
map_buffer[map_buffer_pos] = map_buffer[map_buffer_pos] | TILE_MIRROR_FLAG;
|
case Qt::LeftButton:
|
||||||
|
map_buffer_pos = static_cast<int>(DATA_HEADER_SIZE
|
||||||
|
+ (static_cast<unsigned long>(selected_item + 1) * sizeof(quint16)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::RightButton:
|
||||||
|
map_buffer_pos = static_cast<int>(DATA_HEADER_SIZE
|
||||||
|
+ (static_cast<unsigned long>(selected_item + 1) * sizeof(quint16))) - 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
map_buffer_pos = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
processMapFile(map_buffer);
|
if (map_buffer_pos != -1)
|
||||||
|
{
|
||||||
|
if (map_buffer_pos < map_buffer.count())
|
||||||
|
{
|
||||||
|
const char row = static_cast<char>(listWidget->row(it));
|
||||||
|
|
||||||
|
map_buffer[map_buffer_pos] = row;
|
||||||
|
|
||||||
|
if (ui.mirror_CheckBox->isChecked() )
|
||||||
|
{
|
||||||
|
map_buffer[map_buffer_pos] = map_buffer[map_buffer_pos] | TILE_MIRROR_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
processMapFile(map_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,12 +358,6 @@ void MainWindow::parseMapData(QDataStream& ds)
|
||||||
char byte[2];
|
char byte[2];
|
||||||
ds.readRawData(byte, 2);
|
ds.readRawData(byte, 2);
|
||||||
|
|
||||||
qDebug() << "i = " + QString::number(i);
|
|
||||||
qDebug() << "j = " + QString::number(j);
|
|
||||||
qDebug() << QString::number(byte[0]);
|
|
||||||
qDebug() << QString::number(byte[1]);
|
|
||||||
qDebug() << "";
|
|
||||||
|
|
||||||
buildingData.append(static_cast<quint8>(byte[0]));
|
buildingData.append(static_cast<quint8>(byte[0]));
|
||||||
addTile(static_cast<quint8>(byte[1]), i, j);
|
addTile(static_cast<quint8>(byte[1]), i, j);
|
||||||
}
|
}
|
||||||
|
@ -489,7 +524,7 @@ void MainWindow::addBuilding(quint8 CurrentBuilding, const int i, const int j)
|
||||||
NODATA,
|
NODATA,
|
||||||
BUILDING_DATA(BUILDING_TERMINAL),
|
BUILDING_DATA(BUILDING_TERMINAL),
|
||||||
BUILDING_DATA(BUILDING_TERMINAL_2),
|
BUILDING_DATA(BUILDING_TERMINAL_2),
|
||||||
BUILDING_DATA(BUILDING_GATE),
|
BUILDING_DATA(BUILDING_GATE)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -506,18 +541,20 @@ void MainWindow::addBuilding(quint8 CurrentBuilding, const int i, const int j)
|
||||||
// Determine rendering order depending on Y value.
|
// Determine rendering order depending on Y value.
|
||||||
const short x_bldg_offset = GameBuildingData[CurrentBuildingNoMirror].IsoPos.x;
|
const short x_bldg_offset = GameBuildingData[CurrentBuildingNoMirror].IsoPos.x;
|
||||||
const short y_bldg_offset = GameBuildingData[CurrentBuildingNoMirror].IsoPos.y;
|
const short y_bldg_offset = GameBuildingData[CurrentBuildingNoMirror].IsoPos.y;
|
||||||
const short z_bldg_offset = GameBuildingData[CurrentBuildingNoMirror].IsoPos.z;
|
// Question: why is it needed to substract 16 to "z"?
|
||||||
|
const short z_bldg_offset = GameBuildingData[CurrentBuildingNoMirror].IsoPos.z - 16;
|
||||||
|
|
||||||
IsometricPos buildingIsoPos;
|
IsometricPos buildingIsoPos;
|
||||||
|
|
||||||
buildingIsoPos.x = static_cast<short>(i << TILE_SIZE_BIT_SHIFT) + x_bldg_offset;
|
buildingIsoPos.x = static_cast<short>(i << TILE_SIZE_BIT_SHIFT) + x_bldg_offset;
|
||||||
buildingIsoPos.y = static_cast<short>(j << TILE_SIZE_BIT_SHIFT) - y_bldg_offset;
|
// Question: why is it needed to substract 1 to "j"?
|
||||||
|
buildingIsoPos.y = static_cast<short>((j - 1) << TILE_SIZE_BIT_SHIFT) + y_bldg_offset;
|
||||||
buildingIsoPos.z = z_bldg_offset;
|
buildingIsoPos.z = z_bldg_offset;
|
||||||
|
|
||||||
// Isometric -> Cartesian conversion
|
// Isometric -> Cartesian conversion
|
||||||
CartesianPos buildingCartPos = isometricToCartesian(buildingIsoPos);
|
const CartesianPos buildingCartPos = isometricToCartesian(buildingIsoPos);
|
||||||
|
|
||||||
QPixmap p = QPixmap(buildingPath);
|
const QPixmap p = QPixmap(buildingPath);
|
||||||
|
|
||||||
QImage cropped = p.copy(GameBuildingData[CurrentBuildingNoMirror].u,
|
QImage cropped = p.copy(GameBuildingData[CurrentBuildingNoMirror].u,
|
||||||
GameBuildingData[CurrentBuildingNoMirror].v,
|
GameBuildingData[CurrentBuildingNoMirror].v,
|
||||||
|
@ -807,22 +844,20 @@ void MainWindow::loadTilesetData(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAirportNameModified(QString name)
|
void MainWindow::onAirportNameModified(const QString name)
|
||||||
{
|
{
|
||||||
if (map_buffer.isEmpty() )
|
if (not map_buffer.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
for (int i = 0x04, j = 0; i < 0x1C; i++)
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0x04, j = 0; i < 0x1C; i++)
|
|
||||||
{
|
|
||||||
if (j < name.count() )
|
|
||||||
{
|
{
|
||||||
map_buffer[i] = name.at(j++).toLatin1();
|
if (j < name.count())
|
||||||
}
|
{
|
||||||
else
|
map_buffer[i] = name.at(j++).toLatin1();
|
||||||
{
|
}
|
||||||
map_buffer[i] = '\0';
|
else
|
||||||
|
{
|
||||||
|
map_buffer[i] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,12 @@ private slots:
|
||||||
void loadMap(void);
|
void loadMap(void);
|
||||||
void onCreateMap(void);
|
void onCreateMap(void);
|
||||||
void processMapFile(const QByteArray &);
|
void processMapFile(const QByteArray &);
|
||||||
void onMapItemClicked(QPointF);
|
void onMapItemClicked(QPointF position);
|
||||||
void onNoItemSelected(void);
|
void onNoItemSelected(void);
|
||||||
void onListItemSelected(void);
|
void onListItemSelected(const Qt::MouseButton button);
|
||||||
void onSaveMap(void);
|
void onSaveMap(void);
|
||||||
void onShowNumbers(int);
|
void onShowNumbers(int);
|
||||||
void onAirportNameModified(QString);
|
void onAirportNameModified(const QString);
|
||||||
void showError(const QString& error);
|
void showError(const QString& error);
|
||||||
void moveUp(void);
|
void moveUp(void);
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,9 +76,6 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show numbers on map</string>
|
<string>Show numbers on map</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -11,12 +11,12 @@ MyGraphicsScene::~MyGraphicsScene()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void MyGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* const mouseEvent)
|
||||||
{
|
{
|
||||||
QGraphicsItem *it = this->itemAt(mouseEvent->scenePos(), QTransform());
|
const QGraphicsItem* const it = itemAt(mouseEvent->scenePos(), QTransform());
|
||||||
|
|
||||||
if (it != nullptr)
|
if (it != nullptr)
|
||||||
{
|
{
|
||||||
emit positionClicked(mouseEvent->scenePos());
|
emit positionClicked(mouseEvent->scenePos());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -26,7 +26,7 @@ void MyGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
|
void MyGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* const mouseEvent)
|
||||||
{
|
{
|
||||||
emit updateSelectedItem();
|
emit updateSelectedItem(mouseEvent->button());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,13 @@ public:
|
||||||
~MyGraphicsScene();
|
~MyGraphicsScene();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void positionClicked(QPointF);
|
void positionClicked(QPointF position);
|
||||||
void noItemSelected(void);
|
void noItemSelected(void);
|
||||||
void updateSelectedItem(void);
|
void updateSelectedItem(Qt::MouseButton button);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
void mousePressEvent(QGraphicsSceneMouseEvent * const mouseEvent);
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * const mouseEvent);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[app_settings]
|
[app_settings]
|
||||||
last_dir=/home/xavier/Airport/Levels/LEVEL3.LVL
|
last_dir=/home/xavier/Airport/Levels/LEVEL2.LVL
|
||||||
window_geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\0\0\0\0\0\0\0\x5U\0\0\x2\xdb\0\0\0\xa5\0\0\0\x1d\0\0\x4<\0\0\x2\xa4\0\0\0\0\x2\0\0\0\x5V\0\0\0\0\0\0\0\x1d\0\0\x5U\0\0\x2\xdb)
|
window_geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\0\0\0\0\0\0\0\x5U\0\0\x2\xdb\0\0\0\xa5\0\0\0\x1d\0\0\x4<\0\0\x2\xa4\0\0\0\0\x2\0\0\0\x5V\0\0\0\0\0\0\0\x1d\0\0\x5U\0\0\x2\xdb)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue