Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void drawActionMenu(sf::RenderWindow& window, std::vector<menuOption> options, int selectedIndex) {
- sf::RectangleShape menuBack = makeMenu({183.0f, 120.0f}, {45.0f, 315.0f});
- window.draw(menuBack);
- sf::Font font("assets/fonts/pixelPirate.ttf");
- sf::Vector2f textStart = {50.0f, 320.0f};
- int fontSize = 10;
- for (int i = 0; i < options.size(); i++) {
- sf::Text text(font);
- text.setCharacterSize(fontSize);
- menuOption optionData = options.at(i);
- text.setString(" " + optionData.text);
- text.setPosition({textStart.x, textStart.y + i * fontSize});
- if (i == selectedIndex) {
- text.setString("> " + optionData.text);
- text.setFillColor(sf::Color(240, 235, 86));
- }
- if (!optionData.active) {
- text.setFillColor(sf::Color(158, 158, 158));
- }
- window.draw(text);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment