void VRAMEditorLayeredGraphicScene::renderTiles(
                 Graphic& g,
                 int tileIndex,
                 GGTileSet& tiles,
                 GGPalette& palette,
                 Graphic::TileTransferTransOption tileTransOption) {
  // Render each tile and blit to Graphic
  for (int j = 0; j < tiles.numTiles(); j++) {
    // Render tile
    Graphic tileGraphic(tiles[j],
                        palette,
                        tileTransOption);
                        
    // Calculate position in Graphic
    int xPos = tileIndexToXPos(tileIndex);
    int yPos = tileIndexToYPos(tileIndex);
    
    // Blit if transparency is enabled; copy otherwise
    if (tileTransOption == Graphic::tileTrans) {
      g.blit(tileGraphic,
             Box(xPos, yPos, 0, 0),
             Graphic::noTransUpdate);
    }
    else {
      g.copy(tileGraphic,
             Box(xPos, yPos, 0, 0),
             Graphic::noTransUpdate);
    }
    
    // Move to next tile position
    ++tileIndex;
  }
}
void LevelEffectGraphicSceneLayer::drawMetatile(
                          Graphic& drawSurf,
                          int metatileID,
                          int baseDrawX,
                          int baseDrawY) {
  drawSurf.blit(metatileCache_[(int)metatileID],
                Box(baseDrawX,
                    baseDrawY,
                    MetatileStructure::metatileWidth,
                    MetatileStructure::metatileHeight),
                Graphic::noTransUpdate);
}
Ejemplo n.º 3
0
void VRAMCache::renderTiles(Graphic& g,
                            int tileIndex,
                            GGTileSet& tiles,
                            GGPalette& palette,
                            Graphic::TileTransferTransOption tileTransOption) {
    // Render each tile and blit to Graphic
    for (int j = 0; j < tiles.numTiles(); j++) {
        // Render tile
        Graphic tileGraphic(tiles[j],
                            palette,
                            tileTransOption);

        // Calculate position in Graphic
        int xPos = tileIndex * GGTile::width;
        int yPos = 0;

        // Clear the tiles before writing to them to avoid leaving
        // artifacts from previous contents (due to our program's
        // different concept of transparency from the hardware)
        g.fillRect(xPos, yPos, GGTile::width, GGTile::height,
                   Color(0xFF, 0xFF, 0xFF, Color::fullAlphaTransparency),
                   Graphic::noTransUpdate);

        // Blit if transparency is enabled; copy otherwise
        if (tileTransOption == Graphic::tileTrans) {
            g.blit(tileGraphic,
                   Box(xPos, yPos, 0, 0),
                   Graphic::transUpdate);
        }
        else {
            g.copy(tileGraphic,
                   Box(xPos, yPos, 0, 0),
                   Graphic::transUpdate);
        }

        // Move to next tile position
        ++tileIndex;
    }
}
void MetatilePickerLayeredGraphicScene::render(Graphic& dst,
                      Box srcbox,
                      double scale) {
  dst.clear();
  
  int metatileNum = 0;
  for (int j = 0; j < metatilesPerColumn_; j++) {
    for (int i = 0; i < metatilesPerRow_; i++) {
      if (bgLayerEnabled_) {
        dst.blit(metatilesVisualBG_[metatileNum],
                 Box(i * MetatileStructure::metatileWidth,
                     j * MetatileStructure::metatileHeight,
                     MetatileStructure::metatileWidth,
                     MetatileStructure::metatileHeight),
                 Graphic::transUpdate);
      }
      
      if (fgLayerEnabled_) {
        dst.blit(metatilesVisualFG_[metatileNum],
                 Box(i * MetatileStructure::metatileWidth,
                     j * MetatileStructure::metatileHeight,
                     MetatileStructure::metatileWidth,
                     MetatileStructure::metatileHeight),
                 Graphic::transUpdate);
      }
      
      if (effectLayerEnabled_) {
        dst.blit(metatilesEffect_[metatileNum],
                 Box(i * MetatileStructure::metatileWidth,
                     j * MetatileStructure::metatileHeight,
                     MetatileStructure::metatileWidth,
                     MetatileStructure::metatileHeight),
                 Graphic::noTransUpdate);
      }
      
      if (verticalSolidityLayerEnabled_) {
        dst.blit(metatilesVerticalSolidity_[metatileNum],
                 Box(i * MetatileStructure::metatileWidth,
                     j * MetatileStructure::metatileHeight,
                     MetatileStructure::metatileWidth,
                     MetatileStructure::metatileHeight),
                 Graphic::noTransUpdate);
      }
      
      if (horizontalSolidityLayerEnabled_) {
        dst.blit(metatilesHorizontalSolidity_[metatileNum],
                 Box(i * MetatileStructure::metatileWidth,
                     j * MetatileStructure::metatileHeight,
                     MetatileStructure::metatileWidth,
                     MetatileStructure::metatileHeight),
                 Graphic::noTransUpdate);
      }
      
      ++metatileNum;
    }
  }
      
  if (gridLayerEnabled_) {
    gridLayer_.render(dst,
                      Box(srcbox.x(),
                          srcbox.y(),
                          dst.w(),
                          dst.h()),
                      1.00);
  }
  
  if ((highlightedMetatileBoxEnabled_)) {
    dst.drawRectBorder(metatileIndexToX(highlightedMetatileIndex_),
                       metatileIndexToY(highlightedMetatileIndex_),
                       MetatileStructure::metatileWidth,
                       MetatileStructure::metatileHeight,
                       Color(0xFF, 0xFF, 0x00, Color::fullAlphaOpacity),
                       2);
  }
  
  if ((toolManager_->currentTool() == LevelEditorTools::metatilePaint)) {
    dst.drawRectBorder(metatileIndexToX(toolManager_->pickedMetatileIndex()),
                       metatileIndexToY(toolManager_->pickedMetatileIndex()),
                       MetatileStructure::metatileWidth,
                       MetatileStructure::metatileHeight,
                       Color(0xFF, 0x00, 0x00, Color::fullAlphaOpacity),
                       2);
  }
}