/****************************************************************************** * File - console.h * Author - Joey Pollack * Date - 2022/02/09 (y/m/d) * Mod Date - 2022/02/09 (y/m/d) * Description - Engine console for viewing the debug log and entering lua commands ******************************************************************************/ #ifndef CONSOLE_H_ #define CONSOLE_H_ #include #include #include #include namespace lunarium { class Console; class GuiListener : public LogListener { public: GuiListener(Console* pCon, uint32_t acceptedLogLevels = LogLevel::ANY & ~LogLevel::GRAPHICS_INTERNAL_DEBUG, uint32_t acceptedLogCategories = LogLevel::ANY, const char* myName = "Gui Listener"); virtual bool Log(LogMessage& message); private: Console* mpConsole; }; const int CONSOLE_BUFFER_SIZE = 64; class Console : public Panel { public: Console(const char* name, PanelDockZone dock_zone, bool isOpen = false, int window_flags = 0); virtual ~Console(); virtual void Update(float dt); virtual void DoFrame(); void ClearMessageHistory(); bool IsFocused() const; f32 GetInputWindowHeight() const; // INPUT COMMAND STUFF const std::vector* GetCommandHistory() const; std::string GetLastCommand(); bool GetNewCommand(std::string& command); // returns true if there is a new command and false if not static int MyCallback(ImGuiInputTextCallbackData* data); void SetOGLDebugFlag(bool flag); void SetVerboseFlag(bool flag); private: // INPUT COMMAND STUFF LogListener* mpListener; char mBuffer[CONSOLE_BUFFER_SIZE]; std::vector mCommandHistory; bool mbNewCommand; int mRecalledCommand; // float mAlpha; bool mIsFocused; const f32 mInputWindowHeight; // LOG STUFF std::vector mMsgHistory; friend GuiListener; GuiListener* mListener; bool mbOglDebug; bool mbInfoVerbose; private: void CheckFocus(); }; } #endif // CONSOLE_H_