void DialogueOptionsBox::draw(ApplicationData appData, Graphics graphics) const { graphics.setColor(Color::LIGHTBLUE); graphics.fillRect(frame); //TODO draw boxBg if(font!=nullptr) { Graphics textGraphics = graphics; textGraphics.setColor(fontColor); font->setSize(fontSize); font->setStyle(fontStyle); textGraphics.setFont(font); RectangleD wordBox = RectangleD(frame.x+textPadding.left, frame.y+textPadding.top, frame.width-textPadding.right-textPadding.left, frame.height-textPadding.bottom-textPadding.top); textGraphics.clip(wordBox); textGraphics.translate(wordBox.x, wordBox.y-scrollPosY); double fontHeight = (double)fontSize; for(size_t options_size=options.size(), i=0; i<options_size; i++) { const Option& option = options[i]; for(size_t words_size=option.words.size(), j=0; j<words_size; j++) { const Word& word = option.words[j]; textGraphics.drawString(word.text, word.x, word.y+fontHeight); } } } if(selectedOptionIndex!=NO_OPTION) { double x = frame.x + textPadding.left - 12; double y = frame.y + textPadding.top + options[selectedOptionIndex].y; graphics.setColor(Color::GREEN); graphics.fillRect(x, y, 8, 8); } }
RectangleD MenuBar::getLabelFrame(const RectD&bounds) const { RectangleD frame = getFrame(); Vector2d topleft(bounds.left*frame.width, bounds.top*frame.height); Vector2d bottomright(bounds.right*frame.width, bounds.bottom*frame.height); return RectangleD(frame.x+topleft.x, frame.y+topleft.y, bottomright.x-topleft.x, bottomright.y-topleft.y); }
void ZoomPanElement::drawElements(ApplicationData appData, Graphics graphics) const { RectangleD frame = getFrame(); graphics.clip(RectangleD(0,0,frame.width,frame.height)); graphics.translate(contentOffset.x*zoomScale, contentOffset.y*zoomScale); graphics.scale(zoomScale, zoomScale); ScreenElement::drawElements(appData, graphics); }
void Game::loadContent(AssetManager* assetManager) { assetManager->setRootDirectory("assets"); dialogueBox = new DialogueBox(assetManager, RectangleD(0, 0, 330*3/2, 110)); dialogueBox->setTextPadding(RectD(30, 26, 30, 8)); addMap("village", new Village(this, assetManager)); player = new Jerk(this, assetManager); goToMap("village", Vector2d(400, 200)); }
void Map::draw(ApplicationData appData, Graphics graphics) const { Window* window = appData.getWindow(); Vector2d cameraCenter = game->getCameraCenter(); Vector2d viewSize = window->getView()->getSize(); graphics.setColor(backgroundColor); graphics.fillRect(0, 0, viewSize.x, viewSize.y); double centerShift_x = (viewSize.x/2)-cameraCenter.x; double centerShift_y = (viewSize.y/2)-cameraCenter.y; graphics.translate(centerShift_x, centerShift_y); //draw tiles double tile_x = 0; double tile_y = 0; size_t tile_index = 0; for(size_t row=0; row<tilemap_rows; row++) { for(size_t col=0; col<tilemap_cols; col++) { Animation* tile_anim = getTileAnimation(tilemap[tile_index]); if(tile_anim!=nullptr) { tile_anim->drawFrame(appData, graphics, 0, RectangleD(tile_x, tile_y, tilesize, tilesize)); } tile_x += tilesize; tile_index++; } tile_x = 0; tile_y += tilesize; } //draw bottom layer drawManager_bottom->draw(appData, graphics); //draw middle layer drawManager_middle->draw(appData, graphics); //draw top layer drawManager_top->draw(appData, graphics); }
PixelIterator::PixelIterator(const Vector2u&dims, const RectangleU&srcrect, const RectangleD&dstrect, const RectangleD&looprect, double xincrement, double yincrement, const TransformD&transform, const Vector2d&rat, bool mirrorHorizontal_arg, bool mirrorVertical_arg) { if(!dstrect.contains(looprect)) { throw IllegalArgumentException("loopRect", "not within bounds of dstRect"); } if((unsigned int)(srcrect.x + srcrect.width) > dims.x) { throw IllegalArgumentException("srcRect", "not within bounds of dimensions"); } else if((unsigned int)(srcrect.y + srcrect.height) > dims.y) { throw IllegalArgumentException("srcRect", "not within bounds of dimensions"); } usesTransform = true; started = false; dimensions = Vector2d((double)dims.x, (double)dims.y); srcRect = srcrect; srcRectD = RectangleD((double)srcRect.x, (double)srcRect.y, (double)srcRect.width, (double)srcRect.height); srcRectRight = srcRectD.x + srcRectD.width; srcRectBottom = srcRectD.y + srcRectD.height; dstRect = dstrect; loopRect = looprect; loopRectRel = RectD(loopRect.x-dstRect.x, loopRect.y-dstRect.y, loopRect.x+loopRect.width-dstRect.x, loopRect.y+loopRect.height-dstRect.y); ratio.x = rat.x; ratio.y = rat.y; incr.x = xincrement; incr.y = yincrement; incrpxl.x = incr.x*ratio.x; incrpxl.y = incr.y*ratio.y; inverseTransform = transform.getInverse(); mirrorHorizontal = mirrorHorizontal_arg; mirrorVertical = mirrorVertical_arg; currentPoint.x = loopRect.x - dstRect.x; currentPoint.y = loopRect.y - dstRect.y; row = 0; lastRowStartIndex = 0; currentPixelIndex = calculatePixelIndex(); lastRowStartIndex = currentPixelIndex; }
ZoomPanElement::ZoomPanElement() : ZoomPanElement(RectangleD(0,0,0,0)) { // }