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++) { 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()), 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 // next queue
for (int i = 0; i < std::min((int) this->game.getNextPieces().size(), 5); i++) { for (int i = 0; i < std::min((int) this->game.getNextPieces().size(), 5); i++) {
float nextCellZoom = 2 * this->settings->getWindowSizeMultiplier(); sf::Vector2f nextCellSize(this->nextCellSizeZoom, this->nextCellSizeZoom);
for (int s = this->game.getNextPieces().at(i).getLength(); s > 4; s /= 2) {
nextCellZoom /= 2;
}
sf::Vector2f nextCellSize(nextCellZoom, nextCellZoom);
sf::Color color = this->getColorOfBlock(this->game.getNextPieces().at(i).getBlockType(), 0); 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++) { for (int x = 0; x < this->game.getNextPieces().at(i).getLength(); x++) {
if (this->game.getNextPieces().at(i).getPositions().contains(Position{x, y})) { if (this->game.getNextPieces().at(i).getPositions().contains(Position{x, y})) {
sf::RectangleShape cell(nextCellSize); sf::RectangleShape cell(nextCellSize);
cell.setFillColor(color); cell.setFillColor(color);
cell.setPosition(sf::Vector2f(this->nextQueuePosition[i].position.x + (x * nextCellZoom), cell.setPosition(sf::Vector2f(this->nextQueuePosition[i].position.x + (x * this->nextCellSizeZoom),
this->nextQueuePosition[i].position.y + ((this->game.getNextPieces().size() - y - 1) * nextCellZoom))); this->nextQueuePosition[i].position.y + ((this->game.getNextPieces().at(i).getLength() - y - 1) * this->nextCellSizeZoom)));
this->renderWindow->draw(cell); this->renderWindow->draw(cell);
} }
} }

View File

@@ -13,9 +13,10 @@ class GamePlayingAppMenu : public AppMenu {
bool paused; bool paused;
bool pausePressed; bool pausePressed;
bool retryPressed; bool retryPressed;
float cellSizeZoom;
sf::Rect<float> boardPosition; sf::Rect<float> boardPosition;
float cellSizeZoom;
sf::Rect<float> nextQueuePosition[5]; sf::Rect<float> nextQueuePosition[5];
float nextCellSizeZoom;
public: public:
GamePlayingAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow); GamePlayingAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);