next queue fixed

This commit is contained in:
2025-03-28 15:53:21 +01:00
parent d1646d0fb5
commit 3320545465
2 changed files with 13 additions and 10 deletions

View File

@@ -31,7 +31,13 @@ GamePlayingAppMenu::GamePlayingAppMenu(std::shared_ptr<MenuStack> menuStack, std
for (int i = 0; i < 5; i++) {
this->nextQueuePosition[i] = sf::Rect<float>(sf::Vector2f(this->boardPosition.position.x + boardWidth + (5.f * this->settings->getWindowSizeMultiplier()), (1.f + (10.f * i)) * this->settings->getWindowSizeMultiplier()),
sf::Vector2f(8 * this->settings->getWindowSizeMultiplier(), 8 * this->settings->getWindowSizeMultiplier()));
sf::Vector2f(8.f * this->settings->getWindowSizeMultiplier(), 8.f * this->settings->getWindowSizeMultiplier()));
}
this->nextCellSizeZoom = this->nextQueuePosition[0].size.y;
for (const auto& piece : this->settings->getMenu().getPiecesList().getSelectedPieces()) {
float nextPieceCellSizeZoom = ((int) this->nextQueuePosition[0].size.y) / this->settings->getMenu().getPiecesList().getPiece(piece).getLength();
this->nextCellSizeZoom = std::min(this->nextCellSizeZoom, nextPieceCellSizeZoom);
}
}
@@ -144,20 +150,16 @@ void GamePlayingAppMenu::drawFrame() const {
// next queue
for (int i = 0; i < std::min((int) this->game.getNextPieces().size(), 5); i++) {
float nextCellZoom = 2 * this->settings->getWindowSizeMultiplier();
for (int s = this->game.getNextPieces().at(i).getLength(); s > 4; s /= 2) {
nextCellZoom /= 2;
}
sf::Vector2f nextCellSize(nextCellZoom, nextCellZoom);
sf::Vector2f nextCellSize(this->nextCellSizeZoom, this->nextCellSizeZoom);
sf::Color color = this->getColorOfBlock(this->game.getNextPieces().at(i).getBlockType(), 0);
for (int y = this->game.getNextPieces().at(i).getLength() - 1; y >= 0; y--) {
for (int y = 0; y < this->game.getNextPieces().at(i).getLength(); y++) {
for (int x = 0; x < this->game.getNextPieces().at(i).getLength(); x++) {
if (this->game.getNextPieces().at(i).getPositions().contains(Position{x, y})) {
sf::RectangleShape cell(nextCellSize);
cell.setFillColor(color);
cell.setPosition(sf::Vector2f(this->nextQueuePosition[i].position.x + (x * nextCellZoom),
this->nextQueuePosition[i].position.y + ((this->game.getNextPieces().size() - y - 1) * nextCellZoom)));
cell.setPosition(sf::Vector2f(this->nextQueuePosition[i].position.x + (x * this->nextCellSizeZoom),
this->nextQueuePosition[i].position.y + ((this->game.getNextPieces().at(i).getLength() - y - 1) * this->nextCellSizeZoom)));
this->renderWindow->draw(cell);
}
}