how should I implement forms and switch between them in SFML?
I have a custom abstract Form class for displaying window and other stuff
class Form {
public:
Form();
~Form();
void display();
protected:
sf::RenderWindow *window;
sf::Event event;
bool isRunning() const;
virtual void pollEvents() = 0;
virtual void update() = 0;
virtual void render() = 0;
void initWindow();
};
and I have 3 classes for 3 menus:
- MainForm
- OptionsForm
- GameForm
each inherited class Form:
class OptionsForm : public Form {
public:
OptionsForm(Form *context);
~OptionsForm();
private:
Form *context;
};
I use Form* context
to save the form before this form and when i want to return i dont loose it's data
how I switch between forms:
window->close(); //pointing to the window in the current class
context->display();
but it closes the form completely
I also cant create an instance of the current form because I don't want to lose the current form's class state and data