Introduce 4 new functions:
- g_map.beginGhostMode(float opacity) - g_map.endGhostMode() - UIMap::movePixels(int x, int y) - MapView::move(int x, int y)
This commit is contained in:
parent
3db8f54aa9
commit
56d6ef6642
|
@ -138,6 +138,8 @@ void Client::registerLuaFunctions()
|
||||||
g_lua.bindSingletonFunction("g_map", "getZoneColor", &Map::getZoneColor, &g_map);
|
g_lua.bindSingletonFunction("g_map", "getZoneColor", &Map::getZoneColor, &g_map);
|
||||||
g_lua.bindSingletonFunction("g_map", "showZones", &Map::showZones, &g_map);
|
g_lua.bindSingletonFunction("g_map", "showZones", &Map::showZones, &g_map);
|
||||||
g_lua.bindSingletonFunction("g_map", "showZone", &Map::showZone, &g_map);
|
g_lua.bindSingletonFunction("g_map", "showZone", &Map::showZone, &g_map);
|
||||||
|
g_lua.bindSingletonFunction("g_map", "beginGhostMode", &Map::beginGhostMode, &g_map);
|
||||||
|
g_lua.bindSingletonFunction("g_map", "endGhostMode", &Map::endGhostMode, &g_map);
|
||||||
|
|
||||||
g_lua.registerSingletonClass("g_minimap");
|
g_lua.registerSingletonClass("g_minimap");
|
||||||
g_lua.bindSingletonFunction("g_minimap", "clean", &Minimap::clean, &g_minimap);
|
g_lua.bindSingletonFunction("g_minimap", "clean", &Minimap::clean, &g_minimap);
|
||||||
|
@ -578,6 +580,7 @@ void Client::registerLuaFunctions()
|
||||||
g_lua.registerClass<UIMap, UIWidget>();
|
g_lua.registerClass<UIMap, UIWidget>();
|
||||||
g_lua.bindClassStaticFunction<UIMap>("create", []{ return UIMapPtr(new UIMap); });
|
g_lua.bindClassStaticFunction<UIMap>("create", []{ return UIMapPtr(new UIMap); });
|
||||||
g_lua.bindClassMemberFunction<UIMap>("drawSelf", &UIMap::drawSelf);
|
g_lua.bindClassMemberFunction<UIMap>("drawSelf", &UIMap::drawSelf);
|
||||||
|
g_lua.bindClassMemberFunction<UIMap>("movePixels", &UIMap::movePixels);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("setZoom", &UIMap::setZoom);
|
g_lua.bindClassMemberFunction<UIMap>("setZoom", &UIMap::setZoom);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("zoomIn", &UIMap::zoomIn);
|
g_lua.bindClassMemberFunction<UIMap>("zoomIn", &UIMap::zoomIn);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("zoomOut", &UIMap::zoomOut);
|
g_lua.bindClassMemberFunction<UIMap>("zoomOut", &UIMap::zoomOut);
|
||||||
|
|
|
@ -365,6 +365,16 @@ void Map::setZoneColor(tileflags_t zone, const Color& color)
|
||||||
m_zoneColors[zone] = color;
|
m_zoneColors[zone] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Map::beginGhostMode(float opacity)
|
||||||
|
{
|
||||||
|
g_painter->setOpacity(opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Map::endGhostMode()
|
||||||
|
{
|
||||||
|
g_painter->resetOpacity();
|
||||||
|
}
|
||||||
|
|
||||||
void Map::addCreature(const CreaturePtr& creature)
|
void Map::addCreature(const CreaturePtr& creature)
|
||||||
{
|
{
|
||||||
m_knownCreatures[creature->getId()] = creature;
|
m_knownCreatures[creature->getId()] = creature;
|
||||||
|
|
|
@ -194,6 +194,9 @@ public:
|
||||||
bool showZones() { return m_zoneFlags != 0; }
|
bool showZones() { return m_zoneFlags != 0; }
|
||||||
bool showZone(tileflags_t zone) { return (m_zoneFlags & zone) == zone; }
|
bool showZone(tileflags_t zone) { return (m_zoneFlags & zone) == zone; }
|
||||||
|
|
||||||
|
void beginGhostMode(float opacity);
|
||||||
|
void endGhostMode();
|
||||||
|
|
||||||
// known creature related
|
// known creature related
|
||||||
void addCreature(const CreaturePtr& creature);
|
void addCreature(const CreaturePtr& creature);
|
||||||
CreaturePtr getCreatureById(uint32 id);
|
CreaturePtr getCreatureById(uint32 id);
|
||||||
|
|
|
@ -564,12 +564,20 @@ Position MapView::getPosition(const Point& point, const Size& mapSize)
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::move(int x, int y)
|
||||||
|
{
|
||||||
|
m_moveOffset.x = x;
|
||||||
|
m_moveOffset.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
Rect MapView::calcFramebufferSource(const Size& destSize)
|
Rect MapView::calcFramebufferSource(const Size& destSize)
|
||||||
{
|
{
|
||||||
float scaleFactor = m_tileSize/(float)Otc::TILE_PIXELS;
|
float scaleFactor = m_tileSize/(float)Otc::TILE_PIXELS;
|
||||||
Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize;
|
Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize;
|
||||||
if(isFollowingCreature())
|
if(isFollowingCreature())
|
||||||
drawOffset += m_followingCreature->getWalkOffset() * scaleFactor;
|
drawOffset += m_followingCreature->getWalkOffset() * scaleFactor;
|
||||||
|
else if(!m_moveOffset.isNull())
|
||||||
|
drawOffset += m_moveOffset * scaleFactor;
|
||||||
|
|
||||||
Size srcSize = destSize;
|
Size srcSize = destSize;
|
||||||
Size srcVisible = m_visibleDimension * m_tileSize;
|
Size srcVisible = m_visibleDimension * m_tileSize;
|
||||||
|
@ -703,3 +711,5 @@ void MapView::setDrawLights(bool enable)
|
||||||
m_lightView = nullptr;
|
m_lightView = nullptr;
|
||||||
m_drawLights = enable;
|
m_drawLights = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim: set ts=4 sw=4 et: */
|
||||||
|
|
|
@ -108,6 +108,8 @@ public:
|
||||||
void setDrawLights(bool enable);
|
void setDrawLights(bool enable);
|
||||||
bool isDrawingLights() { return m_drawLights; }
|
bool isDrawingLights() { return m_drawLights; }
|
||||||
|
|
||||||
|
void move(int x, int y);
|
||||||
|
|
||||||
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
|
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
|
||||||
bool isAnimating() { return m_animated; }
|
bool isAnimating() { return m_animated; }
|
||||||
|
|
||||||
|
@ -139,6 +141,7 @@ private:
|
||||||
Size m_optimizedSize;
|
Size m_optimizedSize;
|
||||||
Point m_virtualCenterOffset;
|
Point m_virtualCenterOffset;
|
||||||
Point m_visibleCenterOffset;
|
Point m_visibleCenterOffset;
|
||||||
|
Point m_moveOffset;
|
||||||
Position m_customCameraPosition;
|
Position m_customCameraPosition;
|
||||||
stdext::boolean<true> m_mustUpdateVisibleTilesCache;
|
stdext::boolean<true> m_mustUpdateVisibleTilesCache;
|
||||||
stdext::boolean<true> m_mustDrawVisibleTilesCache;
|
stdext::boolean<true> m_mustDrawVisibleTilesCache;
|
||||||
|
|
|
@ -70,6 +70,11 @@ void UIMap::drawSelf(Fw::DrawPane drawPane)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIMap::movePixels(int x, int y)
|
||||||
|
{
|
||||||
|
m_mapView->move(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
bool UIMap::setZoom(int zoom)
|
bool UIMap::setZoom(int zoom)
|
||||||
{
|
{
|
||||||
m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut);
|
m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut);
|
||||||
|
@ -215,3 +220,5 @@ void UIMap::updateMapSize()
|
||||||
if(!m_keepAspectRatio)
|
if(!m_keepAspectRatio)
|
||||||
updateVisibleDimension();
|
updateVisibleDimension();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vim: set ts=4 sw=4 et: */
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
|
|
||||||
void drawSelf(Fw::DrawPane drawPane);
|
void drawSelf(Fw::DrawPane drawPane);
|
||||||
|
|
||||||
|
void movePixels(int x, int y);
|
||||||
bool setZoom(int zoom);
|
bool setZoom(int zoom);
|
||||||
bool zoomIn();
|
bool zoomIn();
|
||||||
bool zoomOut();
|
bool zoomOut();
|
||||||
|
|
Loading…
Reference in New Issue