début de qqch
This commit is contained in:
@@ -59,13 +59,47 @@ void GamePiecesAppMenu::drawFrame() const {
|
||||
// draw pieces line
|
||||
int firstElem = std::clamp(((int) this->playerCursor.getPosition().y) - 2, 1, MAXIMUM_PIECES_SIZE - 1);
|
||||
this->drawRow(firstElem, 25.f);
|
||||
this->drawRow(firstElem, 35.f);
|
||||
this->drawRow(firstElem, 45.f);
|
||||
this->drawRow(firstElem + 1, 35.f);
|
||||
this->drawRow(firstElem + 2, 45.f);
|
||||
std::cout << this->playerCursor.getPosition().x << " " << this->playerCursor.getPosition().y << " " << firstElem << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
this->renderWindow->display();
|
||||
}
|
||||
|
||||
void GamePiecesAppMenu::drawRow(int piecesSize, float yPos) const {
|
||||
//TODO
|
||||
int numberOfPieces = this->settings->getMenu().readPiecesList().getNumberOfPieces(piecesSize);
|
||||
int firstElem = std::clamp(((int) this->playerCursor.getPosition().x) - 3, 0, std::max(numberOfPieces - 6, 0));
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (i + firstElem >= numberOfPieces) return;
|
||||
|
||||
const Piece& piece = this->settings->getMenu().readPiecesList().lookAtPiece({piecesSize, firstElem + i});
|
||||
int cellSize = (8 * this->settings->getWindowSizeMultiplier()) / (piece.getLength());
|
||||
sf::FloatRect pos(sf::Vector2f(5.f + (i * 10.f), yPos) * (float) this->settings->getWindowSizeMultiplier(), sf::Vector2f(8 , 8) * (float) this->settings->getWindowSizeMultiplier());
|
||||
this->drawPiece(piece, cellSize, pos, this->playerCursor.getPosition() == sf::Vector2u{i + firstElem + 4, piecesSize + 2});
|
||||
}
|
||||
}
|
||||
|
||||
void GamePiecesAppMenu::drawPiece(const Piece& piece, int cellSize, const sf::FloatRect& pos, bool selected) const {
|
||||
sf::RectangleShape cell(sf::Vector2f(cellSize, cellSize));
|
||||
sf::Color color = this->getColorOfBlock(piece.getBlockType(), (selected) ? +100 : 0);
|
||||
sf::Color boxColor = sf::Color(180, 180, 180);
|
||||
|
||||
for (int y = 0; y < piece.getLength(); y++) {
|
||||
for (int x = 0; x < piece.getLength(); x++) {
|
||||
if (piece.getPositions().contains(Position{x, y})) {
|
||||
cell.setFillColor(color);
|
||||
}
|
||||
else {
|
||||
cell.setFillColor(boxColor);
|
||||
|
||||
}
|
||||
cell.setPosition(sf::Vector2f(pos.position.x + (x * cellSize),
|
||||
pos.position.y + ((piece.getLength() - y - 1) * cellSize)));
|
||||
this->renderWindow->draw(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user