diff --git a/src/GraphicalUI/AppMenus/AppMenu.h b/src/GraphicalUI/AppMenus/AppMenu.h index 5feab5e..9a527c6 100644 --- a/src/GraphicalUI/AppMenus/AppMenu.h +++ b/src/GraphicalUI/AppMenus/AppMenu.h @@ -82,7 +82,7 @@ class AppMenu { else { 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})); this->renderWindow->draw(text); } diff --git a/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp b/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp index fe6e5c3..50abd17 100644 --- a/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include diff --git a/src/GraphicalUI/AppMenus/InfoAppMenu.cpp b/src/GraphicalUI/AppMenus/InfoAppMenu.cpp new file mode 100644 index 0000000..ca3e181 --- /dev/null +++ b/src/GraphicalUI/AppMenus/InfoAppMenu.cpp @@ -0,0 +1,89 @@ +#include "InfoAppMenu.h" + +#include "AppMenu.h" +#include "../PlayerCursor.h" + +#include +#include +#include +#include + + +InfoAppMenu::InfoAppMenu(std::shared_ptr menuStack, std::shared_ptr settings, std::shared_ptr renderWindow) : + AppMenu(menuStack, settings, renderWindow), + playerCursor(std::vector({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(); +} diff --git a/src/GraphicalUI/AppMenus/InfoAppMenu.h b/src/GraphicalUI/AppMenus/InfoAppMenu.h new file mode 100644 index 0000000..8e3063c --- /dev/null +++ b/src/GraphicalUI/AppMenus/InfoAppMenu.h @@ -0,0 +1,23 @@ +#pragma once + +#include "AppMenu.h" +#include "../PlayerCursor.h" + +#include +#include +#include + + +class InfoAppMenu : public AppMenu { + private: + PlayerCursor playerCursor; + sf::String sectionsName[4]; + sf::String sectionsContent[4]; + + public: + InfoAppMenu(std::shared_ptr menuStack, std::shared_ptr settings, std::shared_ptr renderWindow); + + void computeFrame() override; + + void drawFrame() const override; +}; diff --git a/src/GraphicalUI/AppMenus/MainAppMenu.cpp b/src/GraphicalUI/AppMenus/MainAppMenu.cpp index 14cafa7..845d089 100644 --- a/src/GraphicalUI/AppMenus/MainAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/MainAppMenu.cpp @@ -3,12 +3,12 @@ #include "AppMenu.h" #include "GameSettingsAppMenu.h" #include "SettingsMainAppMenu.h" +#include "InfoAppMenu.h" #include "../PlayerCursor.h" #include #include #include -#include #include @@ -30,7 +30,7 @@ void MainAppMenu::computeFrame() { this->menuStack->push(std::make_shared(this->menuStack, this->settings, this->renderWindow)); } if (this->playerCursor.getPosition().y == 2) { - //TODO + this->menuStack->push(std::make_shared(this->menuStack, this->settings, this->renderWindow)); } } if (this->escReleased) { @@ -41,8 +41,6 @@ void MainAppMenu::computeFrame() { void MainAppMenu::drawFrame() const { this->renderWindow->clear(sf::Color(200, 200, 200)); - float sizeMultiplier = this->settings->getWindowSizeMultiplier(); - sf::Text text(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * 2); text.setFillColor(sf::Color(0, 0, 0)); 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, "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(); } diff --git a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp index 0e32ff9..add97d2 100644 --- a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp @@ -92,7 +92,7 @@ void SettingsKeybindsAppMenu::drawFrame() const { } 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) { if (i >= firstElem && i < (firstElem + 3)) {