ajout menu info

This commit is contained in:
2025-03-26 00:39:39 +01:00
parent b2567844fc
commit 009ed8edc3
6 changed files with 117 additions and 8 deletions

View File

@@ -82,7 +82,7 @@ class AppMenu {
else { else {
text.setOutlineThickness(0); text.setOutlineThickness(0);
} }
text.setOrigin(text.getLocalBounds().getCenter()); text.setOrigin({text.getLocalBounds().getCenter().x, text.getLocalBounds().size.y / 2});
text.setPosition(sf::Vector2f({sizeMultiplier * 40.f, sizeMultiplier * yPos})); text.setPosition(sf::Vector2f({sizeMultiplier * 40.f, sizeMultiplier * yPos}));
this->renderWindow->draw(text); this->renderWindow->draw(text);
} }

View File

@@ -7,7 +7,6 @@
#include <stack> #include <stack>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <optional>
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>

View File

@@ -0,0 +1,89 @@
#include "InfoAppMenu.h"
#include "AppMenu.h"
#include "../PlayerCursor.h"
#include <stack>
#include <memory>
#include <vector>
#include <SFML/Graphics.hpp>
InfoAppMenu::InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
AppMenu(menuStack, settings, renderWindow),
playerCursor(std::vector<unsigned int>({4})),
sectionsName(
"< ABOUT >",
"< ROTATION SYSTEM >",
"< SCORING >",
"< 0 DEGREES ROTATIONS >"
),
sectionsContent(
"This game is written in C++,\n"
"using SFML 3 for the GUI.\n"
"It's just a solo project made\n"
"for fun and for polyominos.\n"
"It has been inspired by other\n"
"stacker games, such as\n"
"Techmino, jstris, tetr.io, etc.\n"
"This project isn't affiliated\n"
"to them in any ways.\n"
"Current version: beta.",
"This game uses its own\n"
"Rotation Sytem, called AutoRS.\n"
"The rotation center is always the\n"
"center of the piece by default.\n"
"When kicking the piece, it will\n"
"compute and try every position that\n"
"touches the original piece,\n"
"prioritizing sides over depth and\n"
"firstly going down before going up.",
"The score gained from a line clear\n"
"doubles when clearing one more line.\n"
"Clearing with a spin scores as much\n"
"as clearing 2x more lines normally.\n"
"B2B is granted by clearing at least\n"
"4 lines or doing a spin or mini-spin,\n"
"and doubles the score gained.\n"
"A spin is detected when the piece is\n"
"locked in place, a mini-spin simply\n"
"when the last move was a kick.",
"This games introduces 0 degrees\n"
"rotations, which work by simpling\n"
"moving the piece down and kicking\n"
"it as is, allowing for new kinds\n"
"of kicks.\n"
"As a leniency mechanic, when a\n"
"piece spawns it will automatically\n"
"try a 0 degrees rotations if it\n"
"spawned inside a wall."
) {
}
void InfoAppMenu::computeFrame() {
this->updateMetaBinds();
this->playerCursor.updatePosition();
if (this->escReleased) {
this->menuStack->pop();
}
}
void InfoAppMenu::drawFrame() const {
this->renderWindow->clear(sf::Color(200, 200, 200));
sf::Text text(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * 2);
text.setFillColor(sf::Color(0, 0, 0));
text.setOutlineColor(sf::Color(255, 255, 255));
this->placeTitle(text, this->playerCursor, this->sectionsName[this->playerCursor.getPosition().x], 10.f, this->playerCursor.getPosition());
text.setLineSpacing((float) this->settings->getWindowSizeMultiplier() / 8);
this->placeText(text, {}, this->sectionsContent[this->playerCursor.getPosition().x], 5.f, 30.f, {});
this->renderWindow->display();
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "AppMenu.h"
#include "../PlayerCursor.h"
#include <stack>
#include <memory>
#include <SFML/Graphics.hpp>
class InfoAppMenu : public AppMenu {
private:
PlayerCursor playerCursor;
sf::String sectionsName[4];
sf::String sectionsContent[4];
public:
InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);
void computeFrame() override;
void drawFrame() const override;
};

View File

@@ -3,12 +3,12 @@
#include "AppMenu.h" #include "AppMenu.h"
#include "GameSettingsAppMenu.h" #include "GameSettingsAppMenu.h"
#include "SettingsMainAppMenu.h" #include "SettingsMainAppMenu.h"
#include "InfoAppMenu.h"
#include "../PlayerCursor.h" #include "../PlayerCursor.h"
#include <stack> #include <stack>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <optional>
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
@@ -30,7 +30,7 @@ void MainAppMenu::computeFrame() {
this->menuStack->push(std::make_shared<SettingsMainAppMenu>(this->menuStack, this->settings, this->renderWindow)); this->menuStack->push(std::make_shared<SettingsMainAppMenu>(this->menuStack, this->settings, this->renderWindow));
} }
if (this->playerCursor.getPosition().y == 2) { if (this->playerCursor.getPosition().y == 2) {
//TODO this->menuStack->push(std::make_shared<InfoAppMenu>(this->menuStack, this->settings, this->renderWindow));
} }
} }
if (this->escReleased) { if (this->escReleased) {
@@ -41,8 +41,6 @@ void MainAppMenu::computeFrame() {
void MainAppMenu::drawFrame() const { void MainAppMenu::drawFrame() const {
this->renderWindow->clear(sf::Color(200, 200, 200)); this->renderWindow->clear(sf::Color(200, 200, 200));
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
sf::Text text(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * 2); sf::Text text(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * 2);
text.setFillColor(sf::Color(0, 0, 0)); text.setFillColor(sf::Color(0, 0, 0));
text.setOutlineColor(sf::Color(255, 255, 255)); text.setOutlineColor(sf::Color(255, 255, 255));
@@ -51,7 +49,7 @@ void MainAppMenu::drawFrame() const {
this->placeTitle(text, this->playerCursor, "PLAY", 20.f, sf::Vector2u{0, 0}); this->placeTitle(text, this->playerCursor, "PLAY", 20.f, sf::Vector2u{0, 0});
this->placeTitle(text, this->playerCursor, "SETTINGS", 30.f, sf::Vector2u{0, 1}); this->placeTitle(text, this->playerCursor, "SETTINGS", 30.f, sf::Vector2u{0, 1});
this->placeTitle(text, this->playerCursor, "INFO (TODO)", 40.f, sf::Vector2u{0, 2}); this->placeTitle(text, this->playerCursor, "INFO", 40.f, sf::Vector2u{0, 2});
this->renderWindow->display(); this->renderWindow->display();
} }

View File

@@ -92,7 +92,7 @@ void SettingsKeybindsAppMenu::drawFrame() const {
} }
int i = 0; int i = 0;
int firstElem = std::clamp(((int) this->playerCursor.getPosition().y) - 1, 0, 8); int firstElem = std::clamp(((int) this->playerCursor.getPosition().y) - 2, 0, 8);
for (Action action : ACTION_LIST_IN_ORDER) { for (Action action : ACTION_LIST_IN_ORDER) {
if (i >= firstElem && i < (firstElem + 3)) { if (i >= firstElem && i < (firstElem + 3)) {