/****************************************************************************** * 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 namespace lunarium { class Console; class GuiListener : public LogListener { public: GuiListener(Console* pCon, uint32_t acceptedLogLevels = LogLevel::ANY, uint32_t acceptedLogCategories = LogLevel::ANY, const char* myName = "Gui Listener"); virtual bool Log(LogMessage& message); private: Console* mpConsole; }; const int LUA_CON_BUFFER_SIZE = 64; class Console : public Panel { public: Console(const char* name); virtual ~Console(); virtual void Update(float dt); virtual bool DoFrame(); bool IsFocused() const; // LUA COMMAND STUFF const std::vector* GetCommandHistory() const; std::string GetLastCommand(); bool GetNewCommand(std::string& command); // returns true if there is a new and false if not static int MyCallback(ImGuiInputTextCallbackData* data); private: // LUA COMMAND STUFF LogListener* mpListener; char mBuffer[LUA_CON_BUFFER_SIZE]; std::vector mCommandHistory; bool mbNewCommand; int mRecalledCommand; // float mAlpha; bool mIsFocused; // LOG STUFF std::vector mMsgHistory; friend GuiListener; GuiListener* mListener; bool mbOglDebug; bool mbInfoVerbose; private: void CheckFocus(); }; } #endif // CONSOLE_H_