mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-15 13:33:36 +02:00
Merge pull request #3106 from Nordsoft91/editor-improvements-1.4
Fixes for map editor
This commit is contained in:
commit
def927f8be
@ -336,7 +336,8 @@ void CGameStateCampaign::replaceHeroesPlaceholders(const std::vector<CampaignHer
|
||||
|
||||
CGHeroInstance *heroToPlace = campaignHeroReplacement.hero;
|
||||
heroToPlace->id = campaignHeroReplacement.heroPlaceholderId;
|
||||
heroToPlace->tempOwner = heroPlaceholder->tempOwner;
|
||||
if(heroPlaceholder->tempOwner.isValidPlayer())
|
||||
heroToPlace->tempOwner = heroPlaceholder->tempOwner;
|
||||
heroToPlace->pos = heroPlaceholder->pos;
|
||||
heroToPlace->type = VLC->heroh->objects[heroToPlace->subID];
|
||||
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)
|
||||
{
|
||||
serializeJsonOwner(handler);
|
||||
|
||||
bool isHeroType = heroType.has_value();
|
||||
handler.serializeBool("placeholderType", isHeroType, false);
|
||||
|
||||
|
@ -123,6 +123,8 @@ void Initializer::initialize(CGHeroPlaceholder * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
o->tempOwner = defaultPlayer;
|
||||
|
||||
if(!o->powerRank.has_value() && !o->heroType.has_value())
|
||||
o->powerRank = 0;
|
||||
|
||||
@ -274,6 +276,8 @@ void Inspector::updateProperties(CGHeroPlaceholder * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
|
||||
bool type = false;
|
||||
if(o->heroType.has_value())
|
||||
type = true;
|
||||
|
@ -953,7 +953,11 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="roadLayout"/>
|
||||
<layout class="QVBoxLayout" name="roadLayout">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -989,7 +993,11 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="riverLayout"/>
|
||||
<layout class="QVBoxLayout" name="riverLayout">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -89,8 +89,6 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
||||
if(tile == tilePrev) //do not redraw
|
||||
return;
|
||||
|
||||
tilePrev = tile;
|
||||
|
||||
emit currentCoordinates(tile.x, tile.y);
|
||||
|
||||
switch(selectionTool)
|
||||
@ -208,7 +206,21 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
||||
case MapView::SelectionTool::Lasso:
|
||||
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();
|
||||
}
|
||||
break;
|
||||
@ -235,6 +247,8 @@ void MapView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
||||
sc->selectionObjectsView.draw();
|
||||
break;
|
||||
}
|
||||
|
||||
tilePrev = tile;
|
||||
}
|
||||
|
||||
void MapView::mousePressEvent(QMouseEvent *event)
|
||||
@ -459,6 +473,23 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
||||
case MapView::SelectionTool::Lasso: {
|
||||
if(event->button() == Qt::RightButton)
|
||||
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
|
||||
//value.first: x position of left tile
|
||||
|
Loading…
x
Reference in New Issue
Block a user