Beispiel #1
0
void Scene::drawSpots(bool disableVideos) {
  bool processed = false;
  
  if (_canDrawSpots) {
    Node* currentNode = _currentRoom->currentNode();
    if (currentNode->isEnabled()) {
      renderManager.enablePostprocess();
      renderManager.clearView();
      
      currentNode->updateFade();
      renderManager.setAlpha(currentNode->fadeLevel());
      
      currentNode->beginIteratingSpots();
      do {
        Spot* spot = currentNode->currentSpot();
        
        if (spot->hasTexture() && spot->isEnabled()) {
          if (spot->texture()->isLoaded()) {
			// FIXME: This was the culprit of a crash that should be investigated someday
            if (spot->hasVideo()) {
              // If it has a video, we need to check if it's playing
              if (spot->isPlaying()) { // FIXME: Must stop the spot later!
                if (spot->video()->hasNewFrame() && !disableVideos) {
                  DGFrame* frame = spot->video()->currentFrame();
                  Texture* texture = spot->texture();
                  texture->loadRawData(frame->data, frame->width, frame->height);
                }
                
                spot->texture()->bind();
                renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face());
              }
            }
            else {
              // Draw right away...
              spot->texture()->bind();
              renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face());
            }
          }
        }
      } while (currentNode->iterateSpots());
      
      if (config.showSpots) {
        renderManager.disableTextures();
        
        currentNode->beginIteratingSpots();
        do {
          Spot* spot = currentNode->currentSpot();
          
          if (spot->hasColor() && spot->isEnabled()) {
            renderManager.setColor(0x2500AAAA);
            renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face());
          }
        } while (currentNode->iterateSpots());
        
        renderManager.enableTextures();
      }
      
      renderManager.disablePostprocess();
      processed = true;
    }
  }
  
  
  // Blends, gamma, etc.
  cameraManager.beginOrthoView();
  if (processed)
    renderManager.drawPostprocessedView();
  renderManager.blendView();
}
Beispiel #2
0
bool Scene::scanSpots() {
  bool foundAction = false;
  
  // Check if the current node has spots to draw, and also if
  // we aren't dragging the view
  if (_canDrawSpots) {
    Node* currentNode = _currentRoom->currentNode();
    
    // Check if the current node is enabled
    if (currentNode->isEnabled()) {
      renderManager.disableAlpha();
      renderManager.disableTextures();
      
      // First pass: draw the colored spots
      currentNode->beginIteratingSpots();
      do {
        Spot* spot = currentNode->currentSpot();
        
        if (spot->hasColor() && spot->isEnabled()) {
          renderManager.setColor(spot->color());
          renderManager.drawPolygon(spot->arrayOfCoordinates(), spot->face());
        }
      } while (currentNode->iterateSpots());
      
      // Second pass: test the color under the cursor and
      // set action, if available
      
      // FIXME: Should unify the checks here a bit more...
      if (!cursorManager.isDragging() && !cursorManager.onButton()) {
        Point position = cursorManager.position();
        uint32_t color = renderManager.testColor(position.x, position.y);
        if (color) {
          currentNode->beginIteratingSpots();
          do {
            Spot* spot = currentNode->currentSpot();
            if (color == spot->color()) {
              cursorManager.setAction(*spot->action());
              foundAction = true;
              if (_hoveredSpot != spot) {
                if (_hoveredSpot && _hoveredSpot->hasOnUnhoverCallback()) {
                  Script::instance().processCallback(_hoveredSpot->onUnhoverCallback(),
                                                     _hoveredSpot->luaObject());
                }
                _hoveredSpot = spot;
                if (spot->hasOnHoverCallback()) {
                  Script::instance().processCallback(spot->onHoverCallback(), spot->luaObject());
                }
              }
              break;
            }
          } while (currentNode->iterateSpots());
        }
        
        if (!foundAction) {
          if (_hoveredSpot && _hoveredSpot->hasOnUnhoverCallback()) {
            Script::instance().processCallback(_hoveredSpot->onUnhoverCallback(),
                                               _hoveredSpot->luaObject());
          }
          _hoveredSpot = nullptr;
          cursorManager.removeAction();
          
          if (cameraManager.isPanning())
            cursorManager.setCursor(cameraManager.cursorWhenPanning());
          else cursorManager.setCursor(kCursorNormal);
        }
      }
      
      renderManager.enableAlpha();
      renderManager.enableTextures();
    }
  }
  
  renderManager.clearView();
  
  if (foundAction) return true;
  else return false;
}