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

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