1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Merge pull request #1689 from IvanSavenko/map_renderer_fixes

Map renderer fixes
This commit is contained in:
Ivan Savenko 2023-03-16 14:48:57 +02:00 committed by GitHub
commit 77f92e56ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 23 deletions

View File

@ -327,7 +327,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
adventureInt->infoBar->requestPopAll();
if (details.result == TryMoveHero::EMBARK || details.result == TryMoveHero::DISEMBARK)
{
if (hero->getRemovalSound())
if(hero->getRemovalSound() && hero->tempOwner == playerID)
CCS->soundh->playSound(hero->getRemovalSound().get());
}
@ -375,7 +375,6 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
if(details.stopMovement()) //hero failed to move
{
stillMoveHero.setn(STOP_MOVE);
GH.totalRedraw();
adventureInt->heroList->update(hero);
return;
}
@ -1208,8 +1207,6 @@ void CPlayerInterface::tileRevealed(const std::unordered_set<int3, ShashInt3> &p
//FIXME: wait for dialog? Magi hut/eye would benefit from this but may break other areas
for (auto & po : pos)
adventureInt->minimap->updateTile(po);
if (!pos.empty())
GH.totalRedraw();
}
void CPlayerInterface::tileHidden(const std::unordered_set<int3, ShashInt3> &pos)
@ -1217,8 +1214,6 @@ void CPlayerInterface::tileHidden(const std::unordered_set<int3, ShashInt3> &pos
EVENT_HANDLER_CALLED_BY_CLIENT;
for (auto & po : pos)
adventureInt->minimap->updateTile(po);
if (!pos.empty())
GH.totalRedraw();
}
void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)

View File

@ -604,6 +604,13 @@ void ApplyClientNetPackVisitor::visitSetObjectProperty(SetObjectProperty & pack)
if(gs.isVisible(gs.getObjInstance(pack.id), it->first))
callInterfaceIfPresent(cl, it->first, &IGameEventsReceiver::objectPropertyChanged, &pack);
}
if (pack.what == ObjProperty::OWNER)
{
// invalidate section of map view with our objec and force an update with new flag color
CGI->mh->onObjectInstantRemove(gs.getObjInstance(pack.id));
CGI->mh->onObjectInstantAdd(gs.getObjInstance(pack.id));
}
}
void ApplyClientNetPackVisitor::visitHeroLevelUp(HeroLevelUp & pack)

View File

@ -27,13 +27,12 @@
void MapViewController::setViewCenter(const int3 & position)
{
assert(context->isInMap(position));
setViewCenter(Point(position) * model->getSingleTileSize() + model->getSingleTileSize() / 2, position.z);
}
void MapViewController::setViewCenter(const Point & position, int level)
{
Point upperLimit = Point(context->getMapSize()) * model->getSingleTileSize() + model->getSingleTileSize();
Point upperLimit = Point(context->getMapSize()) * model->getSingleTileSize();
Point lowerLimit = Point(0, 0);
if(worldViewContext)
@ -219,7 +218,15 @@ void MapViewController::fadeOutObject(const CGObjectInstance * obj)
adventureContext = fadingOutContext;
context = fadingOutContext;
fadingOutContext->target = obj->id;
const CGObjectInstance * movingObject = obj;
if (obj->ID == Obj::HERO)
{
auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
if (hero->boat)
movingObject = hero->boat;
}
fadingOutContext->target = movingObject->id;
fadingOutContext->progress = 1.0;
}
@ -230,7 +237,15 @@ void MapViewController::fadeInObject(const CGObjectInstance * obj)
adventureContext = fadingInContext;
context = fadingInContext;
fadingInContext->target = obj->id;
const CGObjectInstance * movingObject = obj;
if (obj->ID == Obj::HERO)
{
auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
if (hero->boat)
movingObject = hero->boat;
}
fadingInContext->target = movingObject->id;
fadingInContext->progress = 0.0;
}
@ -324,8 +339,12 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const
{
assert(!hasOngoingAnimations());
removeObject(obj);
addObject(obj);
const CGObjectInstance * movingObject = obj;
if(obj->boat)
movingObject = obj->boat;
removeObject(movingObject);
addObject(movingObject);
if(isEventVisible(obj, from, dest))
{
@ -333,7 +352,7 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const
teleportContext->animationTime = adventureContext->animationTime;
adventureContext = teleportContext;
context = teleportContext;
setViewCenter(obj->getSightCenter());
setViewCenter(movingObject->getSightCenter());
}
}

View File

@ -504,13 +504,13 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType typ
const std::vector<Rect> tmp =
{
Rect(Point(x + 0 * dx, y + 0 * dx), Point(h, w) ),
Rect(Point(x + 1 * dx, y + 0 * dx), Point(h, w) ),
Rect(Point(x + 2 * dx, y + 0 * dx), Point(h, w) ),
Rect(Point(x + 0 * dx, y + 1 * dy), Point(h, w) ),
Rect(Point(x + 1 * dx, y + 1 * dy), Point(h, w) ),
Rect(Point(x + 2 * dx, y + 1 * dy), Point(h, w) ),
Rect(Point(x + 1 * dx, y + 2 * dy), Point(h, w) )
Rect(Point(x + 0 * dx, y + 0 * dx), Point(w, h) ),
Rect(Point(x + 1 * dx, y + 0 * dx), Point(w, h) ),
Rect(Point(x + 2 * dx, y + 0 * dx), Point(w, h) ),
Rect(Point(x + 0 * dx, y + 1 * dy), Point(w, h) ),
Rect(Point(x + 1 * dx, y + 1 * dy), Point(w, h) ),
Rect(Point(x + 2 * dx, y + 1 * dy), Point(w, h) ),
Rect(Point(x + 1 * dx, y + 2 * dy), Point(w, h) )
};
vstd::concatenate(poss, tmp);

View File

@ -923,12 +923,12 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
{
primSkillAreas.push_back(std::make_shared<LRClickableAreaWTextComp>());
if (qeLayout)
primSkillAreas[g]->pos = Rect(Point(pos.x + 324, pos.y + 12 + 26 * g), Point(22, 152));
primSkillAreas[g]->pos = Rect(Point(pos.x + 324, pos.y + 12 + 26 * g), Point(152, 22));
else
primSkillAreas[g]->pos = Rect(Point(pos.x + 329, pos.y + 19 + 36 * g), Point(32, 140));
primSkillAreas[g]->pos = Rect(Point(pos.x + 329, pos.y + 19 + 36 * g), Point(140, 32));
primSkillAreas[g]->text = CGI->generaltexth->arraytxt[2+g];
primSkillAreas[g]->type = g;
primSkillAreas[g]->bonusValue = -1;
primSkillAreas[g]->bonusValue = 0;
primSkillAreas[g]->baseType = 0;
primSkillAreas[g]->hoverText = CGI->generaltexth->heroscrn[1];
boost::replace_first(primSkillAreas[g]->hoverText, "%s", CGI->generaltexth->primarySkillNames[g]);