#pragma once #include #include #define IMGUI_DEFINE_MATH_OPERATORS #include #include #include #include #include #include #include #include #include #include #include #include namespace hex { class View { public: explicit View(std::string unlocalizedViewName); virtual ~View() = default; virtual void drawContent() = 0; virtual void drawAlwaysVisible() { } [[nodiscard]] virtual bool isAvailable() const; [[nodiscard]] virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); } static void drawCommonInterfaces(); static void showMessagePopup(const std::string &message); static void showErrorPopup(const std::string &errorMessage); static void showFatalPopup(const std::string &errorMessage); static void showYesNoQuestionPopup(const std::string &message, const std::function &yesCallback, const std::function &noCallback); static void showFileChooserPopup(const std::vector &paths, const std::vector &validExtensions, const std::function &callback); [[nodiscard]] virtual bool hasViewMenuItemEntry() const; [[nodiscard]] virtual ImVec2 getMinSize() const; [[nodiscard]] virtual ImVec2 getMaxSize() const; [[nodiscard]] bool &getWindowOpenState(); [[nodiscard]] const bool &getWindowOpenState() const; [[nodiscard]] const std::string &getUnlocalizedName() const; [[nodiscard]] std::string getName() const; static void confirmButtons(const std::string &textLeft, const std::string &textRight, const std::function &leftButtonFn, const std::function &rightButtonFn); static void discardNavigationRequests(); static inline std::string toWindowName(const std::string &unlocalizedName) { return LangEntry(unlocalizedName) + "###" + unlocalizedName; } static ImFontAtlas *getFontAtlas() { return View::s_fontAtlas; } static void setFontAtlas(ImFontAtlas *atlas) { View::s_fontAtlas = atlas; } static ImFontConfig getFontConfig() { return View::s_fontConfig; } static void setFontConfig(ImFontConfig config) { View::s_fontConfig = config; } private: std::string m_unlocalizedViewName; bool m_windowOpen = false; std::map> m_shortcuts; static std::string s_popupMessage; static std::function s_yesCallback, s_noCallback; static u32 s_selectableFileIndex; static std::vector s_selectableFiles; static std::function s_selectableFileOpenCallback; static std::vector s_selectableFilesValidExtensions; static ImFontAtlas *s_fontAtlas; static ImFontConfig s_fontConfig; friend class ShortcutManager; }; }