Animations are now optional
The default behaviour is still there though.
This commit is contained in:
		
							parent
							
								
									4f997a3826
								
							
						
					
					
						commit
						eb4fb4ff41
					
				| 
						 | 
				
			
			@ -141,6 +141,10 @@ 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", "setForceShowAnimations", &Map::setForceShowAnimations, &g_map);
 | 
			
		||||
    g_lua.bindSingletonFunction("g_map", "isForcingAnimations", &Map::isForcingAnimations, &g_map);
 | 
			
		||||
    g_lua.bindSingletonFunction("g_map", "isShowingAnimations", &Map::isShowingAnimations, &g_map);
 | 
			
		||||
    g_lua.bindSingletonFunction("g_map", "setShowAnimations", &Map::setShowAnimations, &g_map);
 | 
			
		||||
    g_lua.bindSingletonFunction("g_map", "beginGhostMode", &Map::beginGhostMode, &g_map);
 | 
			
		||||
    g_lua.bindSingletonFunction("g_map", "endGhostMode", &Map::endGhostMode, &g_map);
 | 
			
		||||
    g_lua.bindSingletonFunction("g_map", "findItemsById", &Map::findItemsById, &g_map);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,6 +39,7 @@ TilePtr Map::m_nulltile;
 | 
			
		|||
void Map::init()
 | 
			
		||||
{
 | 
			
		||||
    resetAwareRange();
 | 
			
		||||
    m_animationFlags |= Animation_Show;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Map::terminate()
 | 
			
		||||
| 
						 | 
				
			
			@ -363,6 +364,34 @@ void Map::setZoneColor(tileflags_t zone, const Color& color)
 | 
			
		|||
        m_zoneColors[zone] = color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Map::setForceShowAnimations(bool force)
 | 
			
		||||
{
 | 
			
		||||
    if(force) {
 | 
			
		||||
        if(!(m_animationFlags & Animation_Force))
 | 
			
		||||
            m_animationFlags |= Animation_Force;
 | 
			
		||||
    } else
 | 
			
		||||
        m_animationFlags &= ~Animation_Force;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Map::isForcingAnimations()
 | 
			
		||||
{
 | 
			
		||||
    return (m_animationFlags & Animation_Force) == Animation_Force;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Map::isShowingAnimations()
 | 
			
		||||
{
 | 
			
		||||
    return (m_animationFlags & Animation_Show) == Animation_Show;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Map::setShowAnimations(bool show)
 | 
			
		||||
{
 | 
			
		||||
    if(show) {
 | 
			
		||||
        if(!(m_animationFlags & Animation_Show))
 | 
			
		||||
            m_animationFlags |= Animation_Show;
 | 
			
		||||
    } else
 | 
			
		||||
        m_animationFlags &= ~Animation_Show;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Map::beginGhostMode(float opacity)
 | 
			
		||||
{
 | 
			
		||||
    g_painter->setOpacity(opacity);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,6 +93,11 @@ enum {
 | 
			
		|||
    BLOCK_SIZE = 32
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum : uint8 {
 | 
			
		||||
    Animation_Force,
 | 
			
		||||
    Animation_Show
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class TileBlock {
 | 
			
		||||
public:
 | 
			
		||||
    TileBlock() { m_tiles.fill(nullptr); }
 | 
			
		||||
| 
						 | 
				
			
			@ -195,6 +200,11 @@ public:
 | 
			
		|||
    bool showZones() { return m_zoneFlags != 0; }
 | 
			
		||||
    bool showZone(tileflags_t zone) { return (m_zoneFlags & zone) == zone; }
 | 
			
		||||
 | 
			
		||||
    void setForceShowAnimations(bool force);
 | 
			
		||||
    bool isForcingAnimations();
 | 
			
		||||
    bool isShowingAnimations();
 | 
			
		||||
    void setShowAnimations(bool show);
 | 
			
		||||
 | 
			
		||||
    void beginGhostMode(float opacity);
 | 
			
		||||
    void endGhostMode();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -244,6 +254,7 @@ private:
 | 
			
		|||
    std::vector<MapViewPtr> m_mapViews;
 | 
			
		||||
    std::unordered_map<Position, std::string, PositionHasher> m_waypoints;
 | 
			
		||||
 | 
			
		||||
    uint8 m_animationFlags;
 | 
			
		||||
    uint32 m_zoneFlags;
 | 
			
		||||
    std::array<Color, TILESTATE_LAST> m_zoneColors;
 | 
			
		||||
    float m_zoneOpacity;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,11 +85,22 @@ void MapView::draw(const Rect& rect)
 | 
			
		|||
    Position cameraPosition = getCameraPosition();
 | 
			
		||||
 | 
			
		||||
    int drawFlags = 0;
 | 
			
		||||
    // First branch:
 | 
			
		||||
    // This is unlikely to be false because a lot of us
 | 
			
		||||
    // don't wanna hear their GPU fan while playing a 
 | 
			
		||||
    // 2D game.
 | 
			
		||||
    //
 | 
			
		||||
    // Second & Third branch:
 | 
			
		||||
    // This is likely to be true since not many people have
 | 
			
		||||
    // low-end graphics cards.
 | 
			
		||||
    if(unlikely(g_map.isForcingAnimations()) || (likely(g_map.isShowingAnimations()) && m_viewMode == NEAR_VIEW))
 | 
			
		||||
        drawFlags = Otc::DrawAnimations;
 | 
			
		||||
 | 
			
		||||
    if(m_viewMode == NEAR_VIEW)
 | 
			
		||||
        drawFlags = Otc::DrawGround | Otc::DrawGroundBorders | Otc::DrawWalls |
 | 
			
		||||
                    Otc::DrawItems | Otc::DrawCreatures | Otc::DrawEffects | Otc::DrawMissiles | Otc::DrawAnimations;
 | 
			
		||||
        drawFlags |= Otc::DrawGround | Otc::DrawGroundBorders | Otc::DrawWalls |
 | 
			
		||||
                    Otc::DrawItems | Otc::DrawCreatures | Otc::DrawEffects | Otc::DrawMissiles;
 | 
			
		||||
    else
 | 
			
		||||
        drawFlags = Otc::DrawGround | Otc::DrawGroundBorders | Otc::DrawWalls | Otc::DrawItems;
 | 
			
		||||
        drawFlags |= Otc::DrawGround | Otc::DrawGroundBorders | Otc::DrawWalls | Otc::DrawItems;
 | 
			
		||||
 | 
			
		||||
    if(m_mustDrawVisibleTilesCache || (drawFlags & Otc::DrawAnimations)) {
 | 
			
		||||
        m_framebuffer->bind();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue