mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-18 17:40:48 +02:00
Redering order was fixed
This commit is contained in:
parent
a63c00a90e
commit
ec2204715a
@ -105,7 +105,6 @@ MapScene::MapScene(MainWindow *parent, int l):
|
||||
main(parent),
|
||||
level(l)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapScene::updateViews()
|
||||
@ -114,6 +113,9 @@ void MapScene::updateViews()
|
||||
gridView.update();
|
||||
passabilityView.update();
|
||||
selectionTerrainView.update();
|
||||
|
||||
terrainView.show(true);
|
||||
selectionTerrainView.show(true);
|
||||
}
|
||||
|
||||
BasicView::BasicView(MainWindow * m, MapScene * s): main(m), scene(s)
|
||||
@ -129,14 +131,24 @@ void BasicView::show(bool show)
|
||||
|
||||
if(show)
|
||||
{
|
||||
if(item)
|
||||
scene->addItem(item.get());
|
||||
if(pixmap)
|
||||
{
|
||||
if(item)
|
||||
item->setPixmap(*pixmap);
|
||||
else
|
||||
item.reset(scene->addPixmap(*pixmap));
|
||||
}
|
||||
else
|
||||
item.reset(scene->addPixmap(*pixmap));
|
||||
{
|
||||
if(item)
|
||||
item->setPixmap(emptyPixmap);
|
||||
else
|
||||
item.reset(scene->addPixmap(emptyPixmap));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scene->removeItem(item.get());
|
||||
item->setPixmap(emptyPixmap);
|
||||
}
|
||||
|
||||
isShown = show;
|
||||
@ -145,11 +157,18 @@ void BasicView::show(bool show)
|
||||
void BasicView::redraw()
|
||||
{
|
||||
if(item)
|
||||
scene->removeItem(item.get());
|
||||
|
||||
if(isShown)
|
||||
{
|
||||
item.reset(scene->addPixmap(*pixmap));
|
||||
if(pixmap && isShown)
|
||||
item->setPixmap(*pixmap);
|
||||
else
|
||||
item->setPixmap(emptyPixmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pixmap && isShown)
|
||||
item.reset(scene->addPixmap(*pixmap));
|
||||
else
|
||||
item.reset(scene->addPixmap(emptyPixmap));
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,8 +182,6 @@ void GridView::update()
|
||||
if(!map)
|
||||
return;
|
||||
|
||||
show(false);
|
||||
|
||||
pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
|
||||
pixmap->fill(QColor(0, 0, 0, 0));
|
||||
QPainter painter(pixmap.get());
|
||||
@ -179,7 +196,7 @@ void GridView::update()
|
||||
painter.drawLine(i * 32, 0, i * 32, map->height * 32 - 1);
|
||||
}
|
||||
|
||||
show(isShown);
|
||||
redraw();
|
||||
}
|
||||
|
||||
PassabilityView::PassabilityView(MainWindow * m, MapScene * s): BasicView(m, s)
|
||||
@ -192,8 +209,6 @@ void PassabilityView::update()
|
||||
if(!map)
|
||||
return;
|
||||
|
||||
show(false);
|
||||
|
||||
pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
|
||||
pixmap->fill(QColor(0, 0, 0, 0));
|
||||
|
||||
@ -213,7 +228,7 @@ void PassabilityView::update()
|
||||
}
|
||||
}
|
||||
|
||||
show(isShown);
|
||||
redraw();
|
||||
}
|
||||
|
||||
SelectionTerrainView::SelectionTerrainView(MainWindow * m, MapScene * s): BasicView(m, s)
|
||||
@ -226,8 +241,6 @@ void SelectionTerrainView::update()
|
||||
if(!map)
|
||||
return;
|
||||
|
||||
show(false);
|
||||
|
||||
area.clear();
|
||||
areaAdd.clear();
|
||||
areaErase.clear();
|
||||
@ -235,7 +248,7 @@ void SelectionTerrainView::update()
|
||||
pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
|
||||
pixmap->fill(QColor(0, 0, 0, 0));
|
||||
|
||||
show(true); //always visible
|
||||
redraw();
|
||||
}
|
||||
|
||||
void SelectionTerrainView::draw()
|
||||
@ -302,12 +315,8 @@ void TerrainView::update()
|
||||
if(!map)
|
||||
return;
|
||||
|
||||
show(false);
|
||||
|
||||
pixmap.reset(new QPixmap(map->width * 32, map->height * 32));
|
||||
draw(false);
|
||||
|
||||
show(true); //always visible
|
||||
}
|
||||
|
||||
void TerrainView::setDirty(const int3 & tile)
|
||||
|
@ -25,6 +25,7 @@ protected:
|
||||
bool isShown = false;
|
||||
|
||||
std::unique_ptr<QPixmap> pixmap;
|
||||
QPixmap emptyPixmap;
|
||||
|
||||
private:
|
||||
std::unique_ptr<QGraphicsPixmapItem> item;
|
||||
|
@ -21,6 +21,13 @@ WindowNewMap::WindowNewMap(QWidget *parent) :
|
||||
setWindowModality(Qt::ApplicationModal);
|
||||
|
||||
show();
|
||||
|
||||
//setup initial parameters
|
||||
mapGenOptions.setWidth(ui->widthTxt->text().toInt());
|
||||
mapGenOptions.setHeight(ui->heightTxt->text().toInt());
|
||||
bool twoLevel = ui->twoLevelCheck->isChecked();
|
||||
mapGenOptions.setHasTwoLevels(twoLevel);
|
||||
updateTemplateList();
|
||||
}
|
||||
|
||||
WindowNewMap::~WindowNewMap()
|
||||
|
Loading…
Reference in New Issue
Block a user