The puppet master in the background, in charge of the entire show in this case, has to be the GUI_Manager
class. It is responsible for storing all the interfaces in the application as well as maintaining their states. All mouse input processing originates from this class and is passed down the ownership tree. Let's begin by getting some type definitions out of the way:
using GUI_Interfaces = std::unordered_map<std::string, GUI_Interface*>; using GUI_Container = std::unordered_map<StateType, GUI_Interfaces>; using GUI_Events = std::unordered_map<StateType, std::vector<GUI_Event>>; using GUI_Factory = std::unordered_map<GUI_ElementType, std::function<GUI_Element*(GUI_Interface*)>>; using GUI_ElemTypes = std::unordered_map<std::string, GUI_ElementType>;
We will use the std::unordered_map
data structure that indexes them by name to store the interface data. The interface data containers also need to be grouped by game states,...