added buttons to main state

This commit is contained in:
2025-11-22 12:16:47 +01:00
parent 838b5b1836
commit 4e69ed9742
12 changed files with 644 additions and 60 deletions

35
src/states/OptionsState.h Normal file
View File

@ -0,0 +1,35 @@
#pragma once
#include "State.h"
class OptionsState : public State {
public:
explicit OptionsState(StateContext& ctx);
void onEnter() override;
void onExit() override;
void handleEvent(const SDL_Event& e) override;
void update(double frameMs) override;
void render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logicalVP) override;
private:
enum class Field : int {
PlayerName = 0,
Fullscreen = 1,
Back = 2
};
static constexpr int MAX_NAME_LENGTH = 12;
Field m_selectedField = Field::PlayerName;
double m_cursorTimer = 0.0;
bool m_cursorVisible = true;
void moveSelection(int delta);
void activateSelection();
void handleNameInput(const SDL_Event& e);
void addCharacter(char c);
void removeCharacter();
void toggleFullscreen();
void exitToMenu();
const std::string& playerName() const;
bool isFullscreen() const;
};