Integrating the GUI system
In order to use the GUI system, it needs to first exist. Just like in previous chapters, we need to instantiate and update the GUI classes we built. Let's start by adding the GUI manager and the font manager to the SharedContext.h
file:
struct SharedContext{ SharedContext(): ... m_fontManager(nullptr), ... m_guiManager(nullptr){} ... FontManager* m_fontManager; GUI_Manager* m_guiManager; };
We need to keep a pointer to the GUI manager and the font manager in the Game
class, as with all of the other classes that are shared through the SharedContext
structure, starting with the header:
class Game{ public: ... private: ... FontManager m_fontManager; ... GUI_Manager m_guiManager; };
These pointers are, of course meaningless, unless they actually point to valid objects in memory. Let's take care of the allocation and de-allocation of resources in the Game.cpp
file:
Game::Game() : m_window("Chapter 11", sf::Vector2u(800, 600...