diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 578c3ae9..35335236 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -138,6 +138,8 @@ void Client::registerLuaFunctions() 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", "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.bindSingletonFunction("g_minimap", "clean", &Minimap::clean, &g_minimap); @@ -578,6 +580,7 @@ void Client::registerLuaFunctions() g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIMapPtr(new UIMap); }); g_lua.bindClassMemberFunction("drawSelf", &UIMap::drawSelf); + g_lua.bindClassMemberFunction("movePixels", &UIMap::movePixels); g_lua.bindClassMemberFunction("setZoom", &UIMap::setZoom); g_lua.bindClassMemberFunction("zoomIn", &UIMap::zoomIn); g_lua.bindClassMemberFunction("zoomOut", &UIMap::zoomOut); diff --git a/src/client/map.cpp b/src/client/map.cpp index e17362cf..8af4cc13 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -365,6 +365,16 @@ void Map::setZoneColor(tileflags_t zone, const Color& 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) { m_knownCreatures[creature->getId()] = creature; diff --git a/src/client/map.h b/src/client/map.h index 8423eed6..e207cf8d 100644 --- a/src/client/map.h +++ b/src/client/map.h @@ -194,6 +194,9 @@ public: bool showZones() { return m_zoneFlags != 0; } bool showZone(tileflags_t zone) { return (m_zoneFlags & zone) == zone; } + void beginGhostMode(float opacity); + void endGhostMode(); + // known creature related void addCreature(const CreaturePtr& creature); CreaturePtr getCreatureById(uint32 id); diff --git a/src/client/mapview.cpp b/src/client/mapview.cpp index 3857c781..2a3830d7 100644 --- a/src/client/mapview.cpp +++ b/src/client/mapview.cpp @@ -564,12 +564,20 @@ Position MapView::getPosition(const Point& point, const Size& mapSize) return position; } +void MapView::move(int x, int y) +{ + m_moveOffset.x = x; + m_moveOffset.y = y; +} + Rect MapView::calcFramebufferSource(const Size& destSize) { float scaleFactor = m_tileSize/(float)Otc::TILE_PIXELS; Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize; if(isFollowingCreature()) drawOffset += m_followingCreature->getWalkOffset() * scaleFactor; + else if(!m_moveOffset.isNull()) + drawOffset += m_moveOffset * scaleFactor; Size srcSize = destSize; Size srcVisible = m_visibleDimension * m_tileSize; @@ -703,3 +711,5 @@ void MapView::setDrawLights(bool enable) m_lightView = nullptr; m_drawLights = enable; } + +/* vim: set ts=4 sw=4 et: */ diff --git a/src/client/mapview.h b/src/client/mapview.h index 6b8c8ca2..179c6809 100644 --- a/src/client/mapview.h +++ b/src/client/mapview.h @@ -108,6 +108,8 @@ public: void setDrawLights(bool enable); bool isDrawingLights() { return m_drawLights; } + void move(int x, int y); + void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); } bool isAnimating() { return m_animated; } @@ -139,6 +141,7 @@ private: Size m_optimizedSize; Point m_virtualCenterOffset; Point m_visibleCenterOffset; + Point m_moveOffset; Position m_customCameraPosition; stdext::boolean m_mustUpdateVisibleTilesCache; stdext::boolean m_mustDrawVisibleTilesCache; diff --git a/src/client/uimap.cpp b/src/client/uimap.cpp index 3a53444e..90594726 100644 --- a/src/client/uimap.cpp +++ b/src/client/uimap.cpp @@ -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) { m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut); @@ -215,3 +220,5 @@ void UIMap::updateMapSize() if(!m_keepAspectRatio) updateVisibleDimension(); } + +/* vim: set ts=4 sw=4 et: */ diff --git a/src/client/uimap.h b/src/client/uimap.h index c3e8bd6f..244a711b 100644 --- a/src/client/uimap.h +++ b/src/client/uimap.h @@ -37,6 +37,7 @@ public: void drawSelf(Fw::DrawPane drawPane); + void movePixels(int x, int y); bool setZoom(int zoom); bool zoomIn(); bool zoomOut();