You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/gui/console.h

75 lines
1.9 KiB
C

/******************************************************************************
* 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 <gui/panel.h>
#include <utils/logger.h>
#include <vector>
namespace lunarium
{
namespace gui
{
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<std::string>* 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<std::string> mCommandHistory;
bool mbNewCommand;
int mRecalledCommand;
// float mAlpha;
bool mIsFocused;
// LOG STUFF
std::vector<std::string> mMsgHistory;
friend GuiListener;
GuiListener* mListener;
bool mbOglDebug;
bool mbInfoVerbose;
private:
void CheckFocus();
};
}}
#endif // CONSOLE_H_