lxgui
gui_addon_registry.hpp
1 #ifndef LXGUI_GUI_ADDON_REGISTRY_HPP
2 #define LXGUI_GUI_ADDON_REGISTRY_HPP
3 
4 #include "lxgui/gui_addon.hpp"
5 #include "lxgui/lxgui.hpp"
6 
7 #include <string>
8 #include <unordered_map>
9 #include <vector>
10 
13 namespace sol {
14 
15 class state;
16 
17 }
21 namespace lxgui::gui {
22 
23 class localizer;
24 class event_emitter;
25 class root;
26 class virtual_root;
27 
30 public:
40  sol::state& lua, localizer& loc, event_emitter& emitter, root& r, virtual_root& vr);
41 
42  addon_registry(const addon_registry&) = delete;
46 
54  void load_addon_directory(const std::string& directory);
55 
60  const addon* get_current_addon();
61 
70  void set_current_addon(const addon* a);
71 
73  void save_variables() const;
74 
75 private:
76  void load_addon_toc_(const std::string& addon_name, const std::string& addon_directory);
77  void load_addon_files_(const addon& a);
78 
79  void save_variables_(const addon& a) const noexcept;
80 
81  void parse_layout_file_(const std::string& file_name, const addon& a);
82 
83  template<typename T>
84  using string_map = std::unordered_map<std::string, T>;
85 
86  sol::state& lua_;
87  localizer& localizer_;
88  event_emitter& event_emitter_;
89  root& root_;
90  virtual_root& virtual_root_;
91 
92  const addon* current_addon_ = nullptr;
93  string_map<string_map<addon>> addon_list_;
94 };
95 
96 } // namespace lxgui::gui
97 
98 #endif
Loads and owns addons.
addon_registry(addon_registry &&)=delete
const addon * get_current_addon()
Returns the addon that is being parsed.
void save_variables() const
Save Lua variables registred for saving for all addons.
void set_current_addon(const addon *a)
Sets the current addon.
void load_addon_directory(const std::string &directory)
Parse all addons inside a directory.
addon_registry & operator=(addon_registry &&)=delete
addon_registry(const addon_registry &)=delete
addon_registry & operator=(const addon_registry &)=delete
addon_registry(sol::state &lua, localizer &loc, event_emitter &emitter, root &r, virtual_root &vr)
Constructor.
Generates events and keep tracks of registered callbacks.
Utility class to translate strings for display in GUI.
Root of the UI object hierarchy.
Definition: gui_root.hpp:39
Root of the virtual UI object hierarchy.
A piece of the user interface.
Definition: gui_addon.hpp:12