mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
Fix compilation with latest develop
This commit is contained in:
parent
4cb31ea912
commit
6d92a66fea
@ -371,7 +371,7 @@ void MainWindow::on_actionSave_triggered()
|
|||||||
saveMap();
|
saveMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::terrainButtonClicked(Terrain terrain)
|
void MainWindow::terrainButtonClicked(TerrainId terrain)
|
||||||
{
|
{
|
||||||
controller.commitTerrainChange(mapLevel, terrain);
|
controller.commitTerrainChange(mapLevel, terrain);
|
||||||
}
|
}
|
||||||
@ -484,11 +484,11 @@ void MainWindow::loadObjectsTree()
|
|||||||
{
|
{
|
||||||
ui->terrainFilterCombo->addItem("");
|
ui->terrainFilterCombo->addItem("");
|
||||||
//adding terrains
|
//adding terrains
|
||||||
for(auto & terrain : Terrain::Manager::terrains())
|
for(auto & terrain : VLC->terrainTypeHandler->terrains())
|
||||||
{
|
{
|
||||||
QPushButton *b = new QPushButton(QString::fromStdString(terrain));
|
QPushButton *b = new QPushButton(QString::fromStdString(terrain.name));
|
||||||
ui->terrainLayout->addWidget(b);
|
ui->terrainLayout->addWidget(b);
|
||||||
connect(b, &QPushButton::clicked, this, [this, terrain]{ terrainButtonClicked(terrain); });
|
connect(b, &QPushButton::clicked, this, [this, terrain]{ terrainButtonClicked(terrain.id); });
|
||||||
|
|
||||||
//filter
|
//filter
|
||||||
ui->terrainFilterCombo->addItem(QString::fromStdString(terrain));
|
ui->terrainFilterCombo->addItem(QString::fromStdString(terrain));
|
||||||
@ -496,20 +496,20 @@ void MainWindow::loadObjectsTree()
|
|||||||
//add spacer to keep terrain button on the top
|
//add spacer to keep terrain button on the top
|
||||||
ui->terrainLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
ui->terrainLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
//adding roads
|
//adding roads
|
||||||
for(auto & road : ROAD_NAMES)
|
for(auto & road : VLC->terrainTypeHandler->roads())
|
||||||
{
|
{
|
||||||
QPushButton *b = new QPushButton(QString::fromStdString(road));
|
QPushButton *b = new QPushButton(QString::fromStdString(road.fileName));
|
||||||
ui->roadLayout->addWidget(b);
|
ui->roadLayout->addWidget(b);
|
||||||
connect(b, &QPushButton::clicked, this, [this, road]{ roadOrRiverButtonClicked(road, true); });
|
connect(b, &QPushButton::clicked, this, [this, road]{ roadOrRiverButtonClicked(road.code, true); });
|
||||||
}
|
}
|
||||||
//add spacer to keep terrain button on the top
|
//add spacer to keep terrain button on the top
|
||||||
ui->roadLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
ui->roadLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
//adding rivers
|
//adding rivers
|
||||||
for(auto & river : RIVER_NAMES)
|
for(auto & river : VLC->terrainTypeHandler->rivers())
|
||||||
{
|
{
|
||||||
QPushButton *b = new QPushButton(QString::fromStdString(river));
|
QPushButton *b = new QPushButton(QString::fromStdString(river.fileName));
|
||||||
ui->riverLayout->addWidget(b);
|
ui->riverLayout->addWidget(b);
|
||||||
connect(b, &QPushButton::clicked, this, [this, river]{ roadOrRiverButtonClicked(river, false); });
|
connect(b, &QPushButton::clicked, this, [this, river]{ roadOrRiverButtonClicked(river.code, false); });
|
||||||
}
|
}
|
||||||
//add spacer to keep terrain button on the top
|
//add spacer to keep terrain button on the top
|
||||||
ui->riverLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
ui->riverLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
@ -875,7 +875,7 @@ void MainWindow::on_terrainFilterCombo_currentTextChanged(const QString &arg1)
|
|||||||
if(!objectBrowser)
|
if(!objectBrowser)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
objectBrowser->terrain = arg1.isEmpty() ? Terrain::ANY : Terrain(arg1.toStdString());
|
objectBrowser->terrain = arg1.isEmpty() ? Terrain::ANY_TERRAIN : VLC->terrainTypeHandler->getInfoByName(arg1.toStdString())->id;
|
||||||
objectBrowser->invalidate();
|
objectBrowser->invalidate();
|
||||||
objectBrowser->sort(0);
|
objectBrowser->sort(0);
|
||||||
}
|
}
|
||||||
@ -1062,12 +1062,12 @@ void MainWindow::on_actionUpdate_appearance_triggered()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto terrain = controller.map()->getTile(obj->visitablePos()).terType;
|
auto * terrain = controller.map()->getTile(obj->visitablePos()).terType;
|
||||||
|
|
||||||
if(handler->isStaticObject())
|
if(handler->isStaticObject())
|
||||||
{
|
{
|
||||||
staticObjects.insert(obj);
|
staticObjects.insert(obj);
|
||||||
if(obj->appearance->canBePlacedAt(terrain))
|
if(obj->appearance->canBePlacedAt(terrain->id))
|
||||||
{
|
{
|
||||||
controller.scene(mapLevel)->selectionObjectsView.deselectObject(obj);
|
controller.scene(mapLevel)->selectionObjectsView.deselectObject(obj);
|
||||||
continue;
|
continue;
|
||||||
@ -1078,13 +1078,13 @@ void MainWindow::on_actionUpdate_appearance_triggered()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto app = handler->getOverride(terrain, obj);
|
auto app = handler->getOverride(terrain->id, obj);
|
||||||
if(!app)
|
if(!app)
|
||||||
{
|
{
|
||||||
if(obj->appearance->canBePlacedAt(terrain))
|
if(obj->appearance->canBePlacedAt(terrain->id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto templates = handler->getTemplates(terrain);
|
auto templates = handler->getTemplates(terrain->id);
|
||||||
if(templates.empty())
|
if(templates.empty())
|
||||||
{
|
{
|
||||||
++errors;
|
++errors;
|
||||||
|
@ -69,7 +69,7 @@ private slots:
|
|||||||
|
|
||||||
void on_toolArea_clicked(bool checked);
|
void on_toolArea_clicked(bool checked);
|
||||||
|
|
||||||
void terrainButtonClicked(Terrain terrain);
|
void terrainButtonClicked(TerrainId terrain);
|
||||||
void roadOrRiverButtonClicked(std::string type, bool isRoad);
|
void roadOrRiverButtonClicked(std::string type, bool isRoad);
|
||||||
|
|
||||||
void on_toolErase_clicked();
|
void on_toolErase_clicked();
|
||||||
|
@ -236,7 +236,7 @@ void MapController::resetMapHandler()
|
|||||||
_miniscenes[1]->initialize(*this);
|
_miniscenes[1]->initialize(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapController::commitTerrainChange(int level, const Terrain & terrain)
|
void MapController::commitTerrainChange(int level, const TerrainId & terrain)
|
||||||
{
|
{
|
||||||
std::vector<int3> v(_scenes[level]->selectionTerrainView.selection().begin(),
|
std::vector<int3> v(_scenes[level]->selectionTerrainView.selection().begin(),
|
||||||
_scenes[level]->selectionTerrainView.selection().end());
|
_scenes[level]->selectionTerrainView.selection().end());
|
||||||
@ -269,9 +269,9 @@ void MapController::commitRoadOrRiverChange(int level, const std::string & type,
|
|||||||
|
|
||||||
_map->getEditManager()->getTerrainSelection().setSelection(v);
|
_map->getEditManager()->getTerrainSelection().setSelection(v);
|
||||||
if(isRoad)
|
if(isRoad)
|
||||||
_map->getEditManager()->drawRoad(type, &CRandomGenerator::getDefault());
|
_map->getEditManager()->drawRoad(VLC->terrainTypeHandler->getRoadByName(type)->id, &CRandomGenerator::getDefault());
|
||||||
else
|
else
|
||||||
_map->getEditManager()->drawRiver(type, &CRandomGenerator::getDefault());
|
_map->getEditManager()->drawRiver(VLC->terrainTypeHandler->getRiverByName(type)->id, &CRandomGenerator::getDefault());
|
||||||
|
|
||||||
for(auto & t : v)
|
for(auto & t : v)
|
||||||
_scenes[level]->terrainView.setDirty(t);
|
_scenes[level]->terrainView.setDirty(t);
|
||||||
@ -342,14 +342,14 @@ void MapController::commitObstacleFill(int level)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//split by zones
|
//split by zones
|
||||||
std::map<Terrain, ObstacleProxy> terrainSelected;
|
std::map<TerrainId, ObstacleProxy> terrainSelected;
|
||||||
for(auto & t : selection)
|
for(auto & t : selection)
|
||||||
{
|
{
|
||||||
auto tl = _map->getTile(t);
|
auto tl = _map->getTile(t);
|
||||||
if(tl.blocked || tl.visitable)
|
if(tl.blocked || tl.visitable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
terrainSelected[tl.terType].blockedArea.add(t);
|
terrainSelected[tl.terType->id].blockedArea.add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto & sel : terrainSelected)
|
for(auto & sel : terrainSelected)
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
void sceneForceUpdate();
|
void sceneForceUpdate();
|
||||||
void sceneForceUpdate(int level);
|
void sceneForceUpdate(int level);
|
||||||
|
|
||||||
void commitTerrainChange(int level, const Terrain & terrain);
|
void commitTerrainChange(int level, const TerrainId & terrain);
|
||||||
void commitRoadOrRiverChange(int level, const std::string & type, bool isRoad);
|
void commitRoadOrRiverChange(int level, const std::string & type, bool isRoad);
|
||||||
void commitObjectErase(const CGObjectInstance* obj);
|
void commitObjectErase(const CGObjectInstance* obj);
|
||||||
void commitObjectErase(int level);
|
void commitObjectErase(int level);
|
||||||
|
@ -50,22 +50,6 @@ void MapHandler::reset(const CMap * Map)
|
|||||||
|
|
||||||
void MapHandler::initTerrainGraphics()
|
void MapHandler::initTerrainGraphics()
|
||||||
{
|
{
|
||||||
static const std::map<std::string, std::string> ROAD_FILES =
|
|
||||||
{
|
|
||||||
{ROAD_NAMES[1], "dirtrd"},
|
|
||||||
{ROAD_NAMES[2], "gravrd"},
|
|
||||||
{ROAD_NAMES[3], "cobbrd"}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const std::map<std::string, std::string> RIVER_FILES =
|
|
||||||
{
|
|
||||||
{RIVER_NAMES[1], "clrrvr"},
|
|
||||||
{RIVER_NAMES[2], "icyrvr"},
|
|
||||||
{RIVER_NAMES[3], "mudrvr"},
|
|
||||||
{RIVER_NAMES[4], "lavrvr"}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
auto loadFlipped = [](TFlippedAnimations & animation, TFlippedCache & cache, const std::map<std::string, std::string> & files)
|
auto loadFlipped = [](TFlippedAnimations & animation, TFlippedCache & cache, const std::map<std::string, std::string> & files)
|
||||||
{
|
{
|
||||||
for(auto & type : files)
|
for(auto & type : files)
|
||||||
@ -81,14 +65,24 @@ void MapHandler::initTerrainGraphics()
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::map<std::string, std::string> terrainFiles;
|
std::map<std::string, std::string> terrainFiles;
|
||||||
for(auto & terrain : Terrain::Manager::terrains())
|
std::map<std::string, std::string> roadFiles;
|
||||||
|
std::map<std::string, std::string> riverFiles;
|
||||||
|
for(const auto & terrain : VLC->terrainTypeHandler->terrains())
|
||||||
{
|
{
|
||||||
terrainFiles[terrain] = Terrain::Manager::getInfo(terrain).tilesFilename;
|
terrainFiles[terrain.name] = terrain.tilesFilename;
|
||||||
|
}
|
||||||
|
for(const auto & river : VLC->terrainTypeHandler->rivers())
|
||||||
|
{
|
||||||
|
riverFiles[river.fileName] = river.fileName;
|
||||||
|
}
|
||||||
|
for(const auto & road : VLC->terrainTypeHandler->roads())
|
||||||
|
{
|
||||||
|
roadFiles[road.fileName] = road.fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadFlipped(terrainAnimations, terrainImages, terrainFiles);
|
loadFlipped(terrainAnimations, terrainImages, terrainFiles);
|
||||||
loadFlipped(roadAnimations, roadImages, ROAD_FILES);
|
loadFlipped(riverAnimations, riverImages, riverFiles);
|
||||||
loadFlipped(riverAnimations, riverImages, RIVER_FILES);
|
loadFlipped(roadAnimations, roadImages, roadFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapHandler::drawTerrainTile(QPainter & painter, int x, int y, int z)
|
void MapHandler::drawTerrainTile(QPainter & painter, int x, int y, int z)
|
||||||
@ -96,37 +90,43 @@ void MapHandler::drawTerrainTile(QPainter & painter, int x, int y, int z)
|
|||||||
auto & tinfo = map->getTile(int3(x, y, z));
|
auto & tinfo = map->getTile(int3(x, y, z));
|
||||||
ui8 rotation = tinfo.extTileFlags % 4;
|
ui8 rotation = tinfo.extTileFlags % 4;
|
||||||
|
|
||||||
if(terrainImages.at(tinfo.terType).size() <= tinfo.terView)
|
//TODO: use ui8 instead of string key
|
||||||
|
auto terrainName = tinfo.terType->name;
|
||||||
|
|
||||||
|
if(terrainImages.at(terrainName).size() <= tinfo.terView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||||
painter.drawImage(x * tileSize, y * tileSize, terrainImages.at(tinfo.terType)[tinfo.terView]->mirrored(hflip, vflip));
|
painter.drawImage(x * tileSize, y * tileSize, terrainImages.at(terrainName)[tinfo.terView]->mirrored(hflip, vflip));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapHandler::drawRoad(QPainter & painter, int x, int y, int z)
|
void MapHandler::drawRoad(QPainter & painter, int x, int y, int z)
|
||||||
{
|
{
|
||||||
auto & tinfo = map->getTile(int3(x, y, z));
|
auto & tinfo = map->getTile(int3(x, y, z));
|
||||||
auto * tinfoUpper = map->isInTheMap(int3(x, y - 1, z)) ? &map->getTile(int3(x, y - 1, z)) : nullptr;
|
auto * tinfoUpper = map->isInTheMap(int3(x, y - 1, z)) ? &map->getTile(int3(x, y - 1, z)) : nullptr;
|
||||||
|
|
||||||
if (tinfoUpper && tinfoUpper->roadType != ROAD_NAMES[0])
|
//TODO: use ui8 instead of string key
|
||||||
|
auto roadName = tinfo.terType->name;
|
||||||
|
|
||||||
|
if (tinfoUpper && tinfoUpper->roadType->id != Road::NO_ROAD)
|
||||||
{
|
{
|
||||||
QRect source(0, tileSize / 2, tileSize, tileSize / 2);
|
QRect source(0, tileSize / 2, tileSize, tileSize / 2);
|
||||||
ui8 rotation = (tinfoUpper->extTileFlags >> 4) % 4;
|
ui8 rotation = (tinfoUpper->extTileFlags >> 4) % 4;
|
||||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||||
if(roadImages.at(tinfoUpper->roadType).size() > tinfoUpper->roadDir)
|
if(roadImages.at(roadName).size() > tinfoUpper->roadDir)
|
||||||
{
|
{
|
||||||
painter.drawImage(QPoint(x * tileSize, y * tileSize), roadImages.at(tinfoUpper->roadType)[tinfoUpper->roadDir]->mirrored(hflip, vflip), source);
|
painter.drawImage(QPoint(x * tileSize, y * tileSize), roadImages.at(roadName)[tinfoUpper->roadDir]->mirrored(hflip, vflip), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinfo.roadType != ROAD_NAMES[0]) //print road from this tile
|
if(tinfo.roadType->id != Road::NO_ROAD) //print road from this tile
|
||||||
{
|
{
|
||||||
QRect source(0, 0, tileSize, tileSize / 2);
|
QRect source(0, 0, tileSize, tileSize / 2);
|
||||||
ui8 rotation = (tinfo.extTileFlags >> 4) % 4;
|
ui8 rotation = (tinfo.extTileFlags >> 4) % 4;
|
||||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||||
if(roadImages.at(tinfo.roadType).size() > tinfo.roadDir)
|
if(roadImages.at(roadName).size() > tinfo.roadDir)
|
||||||
{
|
{
|
||||||
painter.drawImage(QPoint(x * tileSize, y * tileSize + tileSize / 2), roadImages.at(tinfo.roadType)[tinfo.roadDir]->mirrored(hflip, vflip), source);
|
painter.drawImage(QPoint(x * tileSize, y * tileSize + tileSize / 2), roadImages.at(roadName)[tinfo.roadDir]->mirrored(hflip, vflip), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,16 +135,19 @@ void MapHandler::drawRiver(QPainter & painter, int x, int y, int z)
|
|||||||
{
|
{
|
||||||
auto & tinfo = map->getTile(int3(x, y, z));
|
auto & tinfo = map->getTile(int3(x, y, z));
|
||||||
|
|
||||||
if(tinfo.riverType == RIVER_NAMES[0])
|
if(tinfo.riverType->id == River::NO_RIVER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//TODO: use ui8 instead of string key
|
||||||
|
auto riverName = tinfo.terType->name;
|
||||||
|
|
||||||
if(riverImages.at(tinfo.riverType).size() <= tinfo.riverDir)
|
if(riverImages.at(riverName).size() <= tinfo.riverDir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ui8 rotation = (tinfo.extTileFlags >> 2) % 4;
|
ui8 rotation = (tinfo.extTileFlags >> 2) % 4;
|
||||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||||
|
|
||||||
painter.drawImage(x * tileSize, y * tileSize, riverImages.at(tinfo.riverType)[tinfo.riverDir]->mirrored(hflip, vflip));
|
painter.drawImage(x * tileSize, y * tileSize, riverImages.at(riverName)[tinfo.riverDir]->mirrored(hflip, vflip));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPlayerColor(QImage * sur, PlayerColor player)
|
void setPlayerColor(QImage * sur, PlayerColor player)
|
||||||
@ -411,10 +414,12 @@ QRgb MapHandler::getTileColor(int x, int y, int z)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// else - use terrain color (blocked version or normal)
|
// else - use terrain color (blocked version or normal)
|
||||||
|
|
||||||
auto & tile = map->getTile(int3(x, y, z));
|
auto & tile = map->getTile(int3(x, y, z));
|
||||||
auto color = Terrain::Manager::getInfo(tile.terType).minimapUnblocked;
|
|
||||||
|
auto color = tile.terType->minimapUnblocked;
|
||||||
if (tile.blocked && (!tile.visitable))
|
if (tile.blocked && (!tile.visitable))
|
||||||
color = Terrain::Manager::getInfo(tile.terType).minimapBlocked;
|
color = tile.terType->minimapBlocked;
|
||||||
|
|
||||||
return qRgb(color[0], color[1], color[2]);
|
return qRgb(color[0], color[1], color[2]);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "../lib/mapObjects/CObjectClassesHandler.h"
|
#include "../lib/mapObjects/CObjectClassesHandler.h"
|
||||||
|
|
||||||
ObjectBrowser::ObjectBrowser(QObject *parent)
|
ObjectBrowser::ObjectBrowser(QObject *parent)
|
||||||
: QSortFilterProxyModel{parent}, terrain(Terrain::ANY)
|
: QSortFilterProxyModel{parent}, terrain(Terrain::ANY_TERRAIN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ bool ObjectBrowser::filterAcceptsRow(int source_row, const QModelIndex & source_
|
|||||||
if(!filterAcceptsRowText(source_row, source_parent))
|
if(!filterAcceptsRowText(source_row, source_parent))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(terrain == Terrain::ANY)
|
if(terrain == Terrain::ANY_TERRAIN)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
auto data = item->data().toJsonObject();
|
auto data = item->data().toJsonObject();
|
||||||
|
@ -8,7 +8,7 @@ class ObjectBrowser : public QSortFilterProxyModel
|
|||||||
public:
|
public:
|
||||||
explicit ObjectBrowser(QObject *parent = nullptr);
|
explicit ObjectBrowser(QObject *parent = nullptr);
|
||||||
|
|
||||||
Terrain terrain;
|
TerrainId terrain;
|
||||||
QString filter;
|
QString filter;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user