#ifndef YAZE_APP_EDITOR_SYSTEM_SHORTCUT_MANAGER_H #define YAZE_APP_EDITOR_SYSTEM_SHORTCUT_MANAGER_H #include #include #include #include "imgui/imgui.h" namespace yaze { namespace editor { struct Shortcut { std::string name; std::vector keys; std::function callback; }; std::vector ParseShortcut(const std::string &shortcut); std::string PrintShortcut(const std::vector &keys); class ShortcutManager { public: void RegisterShortcut(const std::string &name, const std::vector &keys) { shortcuts_[name] = {name, keys}; } void RegisterShortcut(const std::string &name, const std::vector &keys, std::function callback) { shortcuts_[name] = {name, keys, callback}; } void RegisterShortcut(const std::string &name, ImGuiKey key, std::function callback) { shortcuts_[name] = {name, {key}, callback}; } void ExecuteShortcut(const std::string &name) const { shortcuts_.at(name).callback(); } // Access the shortcut and print the readable name of the shortcut for menus const Shortcut &GetShortcut(const std::string &name) const { return shortcuts_.at(name); } // Get shortcut callback function std::function GetCallback(const std::string &name) const { return shortcuts_.at(name).callback; } const std::string GetKeys(const std::string &name) const { return PrintShortcut(shortcuts_.at(name).keys); } private: std::unordered_map shortcuts_; }; } // namespace editor } // namespace yaze #endif // YAZE_APP_EDITOR_SYSTEM_SHORTCUT_MANAGER_H