I'm trying to set up everything I need to render all my buttons using enums and a button class in SDL2/C++ so that the class variables adapt depending on the enum element changes. Each button shape is a different size, individual button presence and position changes depending on game state, and all the image files have a "Button::name_Button::ButtonState" naming convention.
I'm new to C++, so having trouble translating this idea into working code. Does anyone have any ideas on how to make this more elegant?
class Game
{
public:
enum class GameState
{
PLAY, MENU, SETTINGS, EXIT
};
enum class ButtonShape
{
LONG, SHORT, ROUND
};
enum class ButtonState
{
DEFAULT, HOVER, INACTIVE, PRESSED
};
int ButtonShape::LONG::H = 128;
int ButtonShape::LONG::W = 256;
int ButtonShape::SHORT::H = 64;
int ButtonShape::SHORT::W = 64;
int ButtonShape::ROUND::H = 256;
int ButtonShape::ROUND::W = 256;
class Button
{
public:
char name;
ButtonShape _buttonShape;
ButtonState _buttonState;
GameState _gameState;
int x = _gameState x;
int x = _gameState y;
int h = _buttonShape::H;
int w = _buttonShape::W;
string imagefile = "%c_%s.png" name, _buttonState;
};
private:
ButtonState _buttonState;
ButtonShape _buttonShape;
GameState _gameState;
};