mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fix terrain tooltip
This commit is contained in:
@ -1148,14 +1148,13 @@ void CAdvMapInt::onTileHovered(const int3 &mapPos)
|
|||||||
std::string text = curHero() ? objAtTile->getHoverText(curHero()) : objAtTile->getHoverText(LOCPLINT->playerID);
|
std::string text = curHero() ? objAtTile->getHoverText(curHero()) : objAtTile->getHoverText(LOCPLINT->playerID);
|
||||||
boost::replace_all(text,"\n"," ");
|
boost::replace_all(text,"\n"," ");
|
||||||
statusbar->write(text);
|
statusbar->write(text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string hlp;
|
std::string hlp = CGI->mh->getTerrainDescr(mapPos, false);
|
||||||
CGI->mh->getTerrainDescr(mapPos, hlp, false);
|
statusbar->write(hlp);
|
||||||
statusbar->write(hlp);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(spellBeingCasted)
|
if(spellBeingCasted)
|
||||||
{
|
{
|
||||||
switch(spellBeingCasted->id)
|
switch(spellBeingCasted->id)
|
||||||
@ -1306,16 +1305,15 @@ void CAdvMapInt::onTileRightClicked(const int3 &mapPos)
|
|||||||
|
|
||||||
const CGObjectInstance * obj = getActiveObject(mapPos);
|
const CGObjectInstance * obj = getActiveObject(mapPos);
|
||||||
if(!obj)
|
if(!obj)
|
||||||
{
|
{
|
||||||
// Bare or undiscovered terrain
|
// Bare or undiscovered terrain
|
||||||
const TerrainTile * tile = LOCPLINT->cb->getTile(mapPos);
|
const TerrainTile * tile = LOCPLINT->cb->getTile(mapPos);
|
||||||
if (tile)
|
if(tile)
|
||||||
{
|
{
|
||||||
std::string hlp;
|
std::string hlp = CGI->mh->getTerrainDescr(mapPos, true);
|
||||||
CGI->mh->getTerrainDescr(mapPos, hlp, true);
|
CRClickPopup::createAndPush(hlp);
|
||||||
CRClickPopup::createAndPush(hlp);
|
}
|
||||||
}
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CRClickPopup::createAndPush(obj, GH.getCursorPosition(), ETextAlignment::CENTER);
|
CRClickPopup::createAndPush(obj, GH.getCursorPosition(), ETextAlignment::CENTER);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "../CGameInfo.h"
|
#include "../CGameInfo.h"
|
||||||
#include "../CPlayerInterface.h"
|
#include "../CPlayerInterface.h"
|
||||||
|
#include "../CCallback.h"
|
||||||
|
|
||||||
#include "../../lib/UnlockGuard.h"
|
#include "../../lib/UnlockGuard.h"
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
@ -40,41 +41,32 @@ void CMapHandler::waitForOngoingAnimations()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapHandler::getTerrainDescr(const int3 & pos, std::string & out, bool isRMB) const
|
std::string CMapHandler::getTerrainDescr(const int3 & pos, bool rightClick) const
|
||||||
{
|
{
|
||||||
const TerrainTile & t = map->getTile(pos);
|
const TerrainTile & t = map->getTile(pos);
|
||||||
|
|
||||||
if(t.hasFavorableWinds())
|
if(t.hasFavorableWinds())
|
||||||
|
return CGI->objtypeh->getObjectName(Obj::FAVORABLE_WINDS, 0);
|
||||||
|
|
||||||
|
std::string result = t.terType->getNameTranslated();
|
||||||
|
|
||||||
|
for(const auto & object : map->objects)
|
||||||
{
|
{
|
||||||
out = CGI->objtypeh->getObjectName(Obj::FAVORABLE_WINDS, 0);
|
if(object->coveringAt(pos.x, pos.y) && object->pos.z == pos.z && object->isTile2Terrain())
|
||||||
return;
|
{
|
||||||
|
result = object->getObjectName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//const TerrainTile2 & tt = ttiles[pos.z][pos.x][pos.y];
|
|
||||||
bool isTile2Terrain = false;
|
|
||||||
out.clear();
|
|
||||||
|
|
||||||
//for(auto & elem : tt.objects)
|
if(LOCPLINT->cb->getTileDigStatus(pos, false) == EDiggingStatus::CAN_DIG)
|
||||||
//{
|
|
||||||
// if(elem.obj)
|
|
||||||
// {
|
|
||||||
// out = elem.obj->getObjectName();
|
|
||||||
// if(elem.obj->ID == Obj::HOLE)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// isTile2Terrain = elem.obj->isTile2Terrain();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
if(!isTile2Terrain || out.empty())
|
|
||||||
out = t.terType->getNameTranslated();
|
|
||||||
|
|
||||||
if(t.getDiggingStatus(false) == EDiggingStatus::CAN_DIG)
|
|
||||||
{
|
{
|
||||||
out = boost::str(boost::format(isRMB ? "%s\r\n%s" : "%s %s") // New line for the Message Box, space for the Status Bar
|
return boost::str(boost::format(rightClick ? "%s\r\n%s" : "%s %s") // New line for the Message Box, space for the Status Bar
|
||||||
% out
|
% result
|
||||||
% CGI->generaltexth->allTexts[330]); // 'digging ok'
|
% CGI->generaltexth->allTexts[330]); // 'digging ok'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMapHandler::compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b)
|
bool CMapHandler::compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b)
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
void removeMapObserver(IMapObjectObserver * observer);
|
void removeMapObserver(IMapObjectObserver * observer);
|
||||||
|
|
||||||
/// returns string description for terrain interaction
|
/// returns string description for terrain interaction
|
||||||
void getTerrainDescr(const int3 & pos, std::string & out, bool isRMB) const;
|
std::string getTerrainDescr(const int3 & pos, bool rightClick) const;
|
||||||
|
|
||||||
/// returns list of ambient sounds for specified tile
|
/// returns list of ambient sounds for specified tile
|
||||||
std::vector<std::string> getAmbientSounds(const int3 & tile);
|
std::vector<std::string> getAmbientSounds(const int3 & tile);
|
||||||
|
Reference in New Issue
Block a user