omg on a un deuxième menu
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "InGameAppMenu.h"
|
||||
#include "GamePlayingAppMenu.h"
|
||||
|
||||
#include "AppMenu.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
InGameAppMenu::InGameAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
|
||||
GamePlayingAppMenu::GamePlayingAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
|
||||
AppMenu(menuStack, settings, renderWindow),
|
||||
game(this->settings->getMenu().startGame(this->settings->getGamemode()))
|
||||
{
|
||||
@@ -16,7 +16,7 @@ InGameAppMenu::InGameAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_p
|
||||
this->paused = false;
|
||||
}
|
||||
|
||||
void InGameAppMenu::computeFrame() {
|
||||
void GamePlayingAppMenu::computeFrame() {
|
||||
this->updateMetaBinds();
|
||||
|
||||
if (this->escReleased) {
|
||||
@@ -46,7 +46,7 @@ void InGameAppMenu::computeFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
void InGameAppMenu::drawFrame() const {
|
||||
void GamePlayingAppMenu::drawFrame() const {
|
||||
this->renderWindow->clear(sf::Color::Black);
|
||||
|
||||
int sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
class InGameAppMenu : public AppMenu {
|
||||
class GamePlayingAppMenu : public AppMenu {
|
||||
private:
|
||||
Game game;
|
||||
bool paused;
|
||||
|
||||
public:
|
||||
InGameAppMenu(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);
|
||||
|
||||
void computeFrame();
|
||||
|
||||
91
src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp
Normal file
91
src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#include "GameSettingsAppMenu.h"
|
||||
|
||||
#include "AppMenu.h"
|
||||
#include "GamePlayingAppMenu.h"
|
||||
#include "PlayerCursor.h"
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
GameSettingsAppMenu::GameSettingsAppMenu(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>({2, 3, 1})) {
|
||||
|
||||
}
|
||||
|
||||
void GameSettingsAppMenu::computeFrame() {
|
||||
this->updateMetaBinds();
|
||||
this->playerCursor.updatePosition();
|
||||
|
||||
switch (this->playerCursor.getPosition().y) {
|
||||
case 1 : {
|
||||
switch (this->playerCursor.getPosition().x) {
|
||||
case 0 : {this->settings->setGamemode(SPRINT); break;}
|
||||
case 1 : {this->settings->setGamemode(MARATHON); break;}
|
||||
case 2 : {this->settings->setGamemode(ULTRA); break;}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2 : {
|
||||
switch (this->playerCursor.getPosition().x) {
|
||||
case 0 : {this->settings->setGamemode(MASTER); break;}
|
||||
case 1 : break; //TODO
|
||||
case 2 : break; //TODO
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->enterReleased) {
|
||||
if (this->playerCursor.getPosition().y == 0) {
|
||||
//TODO
|
||||
}
|
||||
if (this->playerCursor.getPosition().y > 0) {
|
||||
this->menuStack->push(std::make_shared<GamePlayingAppMenu>(this->menuStack, this->settings, this->renderWindow));
|
||||
}
|
||||
}
|
||||
if (this->escReleased) {
|
||||
this->menuStack->pop();
|
||||
}
|
||||
}
|
||||
|
||||
void GameSettingsAppMenu::drawFrame() const {
|
||||
this->renderWindow->clear(sf::Color(200, 200, 200));
|
||||
|
||||
|
||||
sf::Font font("data/fonts/pressstart/prstartk.ttf");
|
||||
sf::Text text(font, "", this->settings->getWindowSizeMultiplier() * 2);
|
||||
text.setFillColor(sf::Color(0, 0, 0));
|
||||
text.setOutlineColor(sf::Color(255, 255, 255));
|
||||
|
||||
text.setString("GAME SETTINGS");
|
||||
text.setOrigin(text.getLocalBounds().getCenter());
|
||||
text.setPosition(sf::Vector2f({(float) this->settings->getWindowSizeMultiplier() * 40, (float) this->settings->getWindowSizeMultiplier() * 5}));
|
||||
this->renderWindow->draw(text);
|
||||
|
||||
this->placeText(text, "PIECES SELECT", 5.f, 15.f, 0, 0);
|
||||
this->placeText(text, "BOARD SELECT", 40.f, 15.f, 1, 0);
|
||||
|
||||
this->placeText(text, "SPRINT", 5.f, 25.f, 0, 1);
|
||||
this->placeText(text, "MARATHON", 25.f, 25.f, 1, 1);
|
||||
this->placeText(text, "ULTRA", 50.f, 25.f, 2, 1);
|
||||
this->placeText(text, "MASTER", 5.f, 35.f, 0, 2);
|
||||
this->placeText(text, "TODO", 25.f, 35.f, 1, 2);
|
||||
this->placeText(text, "TOOD", 50.f, 35.f, 2, 2);
|
||||
|
||||
this->renderWindow->display();
|
||||
}
|
||||
|
||||
void GameSettingsAppMenu::placeText(sf::Text& text, const sf::String& string, float xPos, float yPos, unsigned int xCursorOutline, unsigned int yCursorOutline) const {
|
||||
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
||||
|
||||
text.setString(string);
|
||||
text.setOutlineThickness((this->playerCursor.getPosition().x == xCursorOutline
|
||||
&& this->playerCursor.getPosition().y == yCursorOutline) ? (sizeMultiplier / 2) : 0);
|
||||
text.setOrigin(sf::Vector2f({0, text.getLocalBounds().size.y / 2}));
|
||||
text.setPosition(sf::Vector2f({sizeMultiplier * xPos, sizeMultiplier * yPos}));
|
||||
this->renderWindow->draw(text);
|
||||
}
|
||||
23
src/GraphicalUI/AppMenus/GameSettingsAppMenu.h
Normal file
23
src/GraphicalUI/AppMenus/GameSettingsAppMenu.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppMenu.h"
|
||||
#include "PlayerCursor.h"
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
class GameSettingsAppMenu : public AppMenu {
|
||||
private:
|
||||
PlayerCursor playerCursor;
|
||||
|
||||
public:
|
||||
GameSettingsAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);
|
||||
|
||||
void computeFrame();
|
||||
|
||||
void drawFrame() const;
|
||||
|
||||
void placeText(sf::Text& text, const sf::String& string, float xPos, float yPos, unsigned int xCursorOutline, unsigned int yCursorOutline) const ;
|
||||
};
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "MainAppMenu.h"
|
||||
|
||||
#include "AppMenu.h"
|
||||
#include "InGameAppMenu.h"
|
||||
#include "GameSettingsAppMenu.h"
|
||||
#include "PlayerCursor.h"
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
@@ -20,7 +22,13 @@ void MainAppMenu::computeFrame() {
|
||||
|
||||
if (this->enterReleased) {
|
||||
if (this->playerCursor.getPosition().y == 0) {
|
||||
this->menuStack->push(std::make_shared<InGameAppMenu>(this->menuStack, this->settings, this->renderWindow));
|
||||
this->menuStack->push(std::make_shared<GameSettingsAppMenu>(this->menuStack, this->settings, this->renderWindow));
|
||||
}
|
||||
if (this->playerCursor.getPosition().y == 1) {
|
||||
//TODO
|
||||
}
|
||||
if (this->playerCursor.getPosition().y == 2) {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
if (this->escReleased) {
|
||||
@@ -33,29 +41,29 @@ void MainAppMenu::drawFrame() const {
|
||||
|
||||
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
||||
|
||||
sf::Font font("data/fonts/arial.ttf");
|
||||
sf::Text text(font, "", this->settings->getWindowSizeMultiplier() * 5);
|
||||
sf::Font font("data/fonts/pressstart/prstartk.ttf");
|
||||
sf::Text text(font, "", this->settings->getWindowSizeMultiplier() * 2);
|
||||
text.setFillColor(sf::Color(0, 0, 0));
|
||||
text.setOutlineColor(sf::Color(255, 255, 255));
|
||||
|
||||
text.setString("jminos");
|
||||
text.setString("JMINOS");
|
||||
text.setOrigin(text.getLocalBounds().getCenter());
|
||||
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 10}));
|
||||
this->renderWindow->draw(text);
|
||||
|
||||
text.setString("Play");
|
||||
text.setString("PLAY");
|
||||
text.setOutlineThickness((this->playerCursor.getPosition().y == 0) ? (sizeMultiplier / 2) : 0);
|
||||
text.setOrigin(text.getLocalBounds().getCenter());
|
||||
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 20}));
|
||||
this->renderWindow->draw(text);
|
||||
|
||||
text.setString("Settings");
|
||||
text.setString("SETTINGS");
|
||||
text.setOutlineThickness((this->playerCursor.getPosition().y == 1) ? (sizeMultiplier / 2) : 0);
|
||||
text.setOrigin(text.getLocalBounds().getCenter());
|
||||
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 30}));
|
||||
this->renderWindow->draw(text);
|
||||
|
||||
text.setString("Info");
|
||||
text.setString("INFO");
|
||||
text.setOutlineThickness((this->playerCursor.getPosition().y == 2) ? (sizeMultiplier / 2) : 0);
|
||||
text.setOrigin(text.getLocalBounds().getCenter());
|
||||
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 40}));
|
||||
|
||||
@@ -86,7 +86,7 @@ void PlayerCursor::moveUp() {
|
||||
this->position.y--;
|
||||
}
|
||||
|
||||
if (this->position.x > this->rows.at(this->position.y)) {
|
||||
if (this->position.x >= this->rows.at(this->position.y)) {
|
||||
this->position.x = this->rows.at(this->position.y) - 1;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void PlayerCursor::moveDown() {
|
||||
this->position.y++;
|
||||
}
|
||||
|
||||
if (this->position.x > this->rows.at(this->position.y)) {
|
||||
if (this->position.x >= this->rows.at(this->position.y)) {
|
||||
this->position.x = this->rows.at(this->position.y) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <fstream>
|
||||
|
||||
static const sf::Vector2u BASE_WINDOW_SIZE = {80, 50};
|
||||
static const int WINDOW_SIZE_MULTIPLIERS[] = {4, 6, 9, 14, 20};
|
||||
static const int WINDOW_SIZE_MULTIPLIERS[] = {4, 6, 10, 14, 20};
|
||||
static const int WINDOW_SIZE_LAST_MODE = (sizeof(WINDOW_SIZE_MULTIPLIERS) / sizeof(int)) - 1;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user