mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Merge pull request #3106 from Nordsoft91/editor-improvements-1.4
Fixes for map editor
This commit is contained in:
@@ -336,7 +336,8 @@ void CGameStateCampaign::replaceHeroesPlaceholders(const std::vector<CampaignHer
|
|||||||
|
|
||||||
CGHeroInstance *heroToPlace = campaignHeroReplacement.hero;
|
CGHeroInstance *heroToPlace = campaignHeroReplacement.hero;
|
||||||
heroToPlace->id = campaignHeroReplacement.heroPlaceholderId;
|
heroToPlace->id = campaignHeroReplacement.heroPlaceholderId;
|
||||||
heroToPlace->tempOwner = heroPlaceholder->tempOwner;
|
if(heroPlaceholder->tempOwner.isValidPlayer())
|
||||||
|
heroToPlace->tempOwner = heroPlaceholder->tempOwner;
|
||||||
heroToPlace->pos = heroPlaceholder->pos;
|
heroToPlace->pos = heroPlaceholder->pos;
|
||||||
heroToPlace->type = VLC->heroh->objects[heroToPlace->subID];
|
heroToPlace->type = VLC->heroh->objects[heroToPlace->subID];
|
||||||
heroToPlace->appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, heroToPlace->type->heroClass->getIndex())->getTemplates().front();
|
heroToPlace->appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, heroToPlace->type->heroClass->getIndex())->getTemplates().front();
|
||||||
|
@@ -42,6 +42,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
void CGHeroPlaceholder::serializeJsonOptions(JsonSerializeFormat & handler)
|
void CGHeroPlaceholder::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||||
{
|
{
|
||||||
|
serializeJsonOwner(handler);
|
||||||
|
|
||||||
bool isHeroType = heroType.has_value();
|
bool isHeroType = heroType.has_value();
|
||||||
handler.serializeBool("placeholderType", isHeroType, false);
|
handler.serializeBool("placeholderType", isHeroType, false);
|
||||||
|
|
||||||
|
@@ -123,6 +123,8 @@ void Initializer::initialize(CGHeroPlaceholder * o)
|
|||||||
{
|
{
|
||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
|
o->tempOwner = defaultPlayer;
|
||||||
|
|
||||||
if(!o->powerRank.has_value() && !o->heroType.has_value())
|
if(!o->powerRank.has_value() && !o->heroType.has_value())
|
||||||
o->powerRank = 0;
|
o->powerRank = 0;
|
||||||
|
|
||||||
@@ -274,6 +276,8 @@ void Inspector::updateProperties(CGHeroPlaceholder * o)
|
|||||||
{
|
{
|
||||||
if(!o) return;
|
if(!o) return;
|
||||||
|
|
||||||
|
addProperty("Owner", o->tempOwner, false);
|
||||||
|
|
||||||
bool type = false;
|
bool type = false;
|
||||||
if(o->heroType.has_value())
|
if(o->heroType.has_value())
|
||||||
type = true;
|
type = true;
|
||||||
|
@@ -953,7 +953,11 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="roadLayout"/>
|
<layout class="QVBoxLayout" name="roadLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -989,7 +993,11 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="riverLayout"/>
|
<layout class="QVBoxLayout" name="riverLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@@ -89,8 +89,6 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
|||||||
if(tile == tilePrev) //do not redraw
|
if(tile == tilePrev) //do not redraw
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tilePrev = tile;
|
|
||||||
|
|
||||||
emit currentCoordinates(tile.x, tile.y);
|
emit currentCoordinates(tile.x, tile.y);
|
||||||
|
|
||||||
switch(selectionTool)
|
switch(selectionTool)
|
||||||
@@ -208,7 +206,21 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
|||||||
case MapView::SelectionTool::Lasso:
|
case MapView::SelectionTool::Lasso:
|
||||||
if(mouseEvent->buttons() == Qt::LeftButton)
|
if(mouseEvent->buttons() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
sc->selectionTerrainView.select(tile);
|
for(auto i = tilePrev; i != tile;)
|
||||||
|
{
|
||||||
|
int length = std::numeric_limits<int>::max();
|
||||||
|
int3 dir;
|
||||||
|
for(auto & d : int3::getDirs())
|
||||||
|
{
|
||||||
|
if(tile.dist2dSQ(i + d) < length)
|
||||||
|
{
|
||||||
|
dir = d;
|
||||||
|
length = tile.dist2dSQ(i + d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i += dir;
|
||||||
|
sc->selectionTerrainView.select(i);
|
||||||
|
}
|
||||||
sc->selectionTerrainView.draw();
|
sc->selectionTerrainView.draw();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -235,6 +247,8 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
|||||||
sc->selectionObjectsView.draw();
|
sc->selectionObjectsView.draw();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tilePrev = tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::mousePressEvent(QMouseEvent *event)
|
void MapView::mousePressEvent(QMouseEvent *event)
|
||||||
@@ -459,6 +473,23 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
case MapView::SelectionTool::Lasso: {
|
case MapView::SelectionTool::Lasso: {
|
||||||
if(event->button() == Qt::RightButton)
|
if(event->button() == Qt::RightButton)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//connect with initial tile
|
||||||
|
for(auto i = tilePrev; i != tileStart;)
|
||||||
|
{
|
||||||
|
int length = std::numeric_limits<int>::max();
|
||||||
|
int3 dir;
|
||||||
|
for(auto & d : int3::getDirs())
|
||||||
|
{
|
||||||
|
if(tileStart.dist2dSQ(i + d) < length)
|
||||||
|
{
|
||||||
|
dir = d;
|
||||||
|
length = tileStart.dist2dSQ(i + d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i += dir;
|
||||||
|
sc->selectionTerrainView.select(i);
|
||||||
|
}
|
||||||
|
|
||||||
//key: y position of tile
|
//key: y position of tile
|
||||||
//value.first: x position of left tile
|
//value.first: x position of left tile
|
||||||
|
Reference in New Issue
Block a user