Debug log and LUA console gui windows implemented
parent
cc811b2a7e
commit
4486eb8890
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
The root project folder needs to contain a project.xml file that describes the project (See ??? for details)
|
||||||
|
|
||||||
|
Project directory structure (this should be auto-generated by the editor when creating a new project):
|
||||||
|
|
||||||
|
Project root
|
||||||
|
├── project.xml
|
||||||
|
├── engine/
|
||||||
|
│ └── Lunarium_NE.exe (non-editor version of the engine. Used for creating a release build of the project)
|
||||||
|
│
|
||||||
|
├── contents/
|
||||||
|
│ ├── content_meta.xml - (Associates each asset with a unique id, and whatever else is needed to compile the assets)
|
||||||
|
│ └── assets/
|
||||||
|
│ └── (Can be organized however the user wants)
|
||||||
|
│
|
||||||
|
└─ release/
|
||||||
|
├── (This directory is generated by the editor when building the project)
|
||||||
|
├── game_name.exe - (The non-editor version of the engine renamed to the game name)
|
||||||
|
└── data/ - (The data folder generated by the asset compiler, contains all the assets for the game in binary formats)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
├──
|
||||||
|
│
|
||||||
|
└─
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* File - luaConsole.cpp
|
||||||
|
* Author - Joey Pollack
|
||||||
|
* Date - 2021/09/17 (y/m/d)
|
||||||
|
* Mod Date - 2021/09/17 (y/m/d)
|
||||||
|
* Description - GUI window for the LUA console
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "luaConsole.h"
|
||||||
|
#include <core/core.h>
|
||||||
|
#include <input/inputManager.h>
|
||||||
|
#include <window/window.h>
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <imgui_impl_glfw.h>
|
||||||
|
#include <imgui_impl_opengl3.h>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace lunarium
|
||||||
|
{
|
||||||
|
LuaConsole* LuaConsole::mpInstance = nullptr;
|
||||||
|
LuaConsole::LuaConsole()
|
||||||
|
: mbShow(false), mbNewCommand(false)
|
||||||
|
{
|
||||||
|
memset(mBuffer, 0, LUA_CON_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaConsole& LuaConsole::GetInstance()
|
||||||
|
{
|
||||||
|
if (!mpInstance)
|
||||||
|
{
|
||||||
|
mpInstance = new LuaConsole;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *mpInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaConsole::FreeInstance()
|
||||||
|
{
|
||||||
|
delete mpInstance;
|
||||||
|
mpInstance = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpRes LuaConsole::Initialize()
|
||||||
|
{
|
||||||
|
return OpRes::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaConsole::Show()
|
||||||
|
{
|
||||||
|
// TODO: LuaConsole::Show
|
||||||
|
if (!mbShow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
Core::MainWindow().GetPosition(&x, &y);
|
||||||
|
int width, height;
|
||||||
|
Core::MainWindow().GetFramebufferSize(&width, &height);
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_Always);
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(width / 3.0f, height / 3.0f), ImGuiCond_Always);
|
||||||
|
if (!ImGui::Begin("LUA Console", &mbShow, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove
|
||||||
|
| ImGuiWindowFlags_NoSavedSettings))
|
||||||
|
{
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::BeginChild("history", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
|
for (int i = 0; i < mCommandHistory.size(); i++)
|
||||||
|
{
|
||||||
|
const char* msg = mCommandHistory[i].c_str();
|
||||||
|
int len = strlen(msg);
|
||||||
|
|
||||||
|
ImGui::TextUnformatted(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::InputText("command", mBuffer, LUA_CON_BUFFER_SIZE);
|
||||||
|
|
||||||
|
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
|
||||||
|
ImGui::SetScrollHereY(1.0f);
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
|
if (Core::Input().IsKeyPressed(KeyCode::RETURN) && strlen(mBuffer) > 1)
|
||||||
|
{
|
||||||
|
mCommandHistory.push_back(mBuffer);
|
||||||
|
memset(mBuffer, 0, LUA_CON_BUFFER_SIZE);
|
||||||
|
mbNewCommand = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaConsole::SetShow(bool show)
|
||||||
|
{
|
||||||
|
mbShow = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LuaConsole::IsShown() const
|
||||||
|
{
|
||||||
|
return mbShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>* LuaConsole::GetCommandHistory() const
|
||||||
|
{
|
||||||
|
return &mCommandHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LuaConsole::GetLastCommand()
|
||||||
|
{
|
||||||
|
return mCommandHistory.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LuaConsole::GetNewCommand(std::string& command)
|
||||||
|
{
|
||||||
|
if (mbNewCommand)
|
||||||
|
{
|
||||||
|
command = mCommandHistory.back();
|
||||||
|
mbNewCommand = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* File - luaConsole.h
|
||||||
|
* Author - Joey Pollack
|
||||||
|
* Date - 2021/09/17 (y/m/d)
|
||||||
|
* Mod Date - 2021/09/17 (y/m/d)
|
||||||
|
* Description - GUI window for the LUA console
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LUA_CONSOLE_H_
|
||||||
|
#define LUA_CONSOLE_H_
|
||||||
|
|
||||||
|
#include <utils/opRes.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace lunarium
|
||||||
|
{
|
||||||
|
const int LUA_CON_BUFFER_SIZE = 64;
|
||||||
|
class LuaConsole
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static LuaConsole& GetInstance();
|
||||||
|
static void FreeInstance();
|
||||||
|
|
||||||
|
OpRes Initialize();
|
||||||
|
void Show();
|
||||||
|
|
||||||
|
void SetShow(bool show);
|
||||||
|
bool IsShown() const;
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
static LuaConsole* mpInstance;
|
||||||
|
bool mbShow;
|
||||||
|
char mBuffer[LUA_CON_BUFFER_SIZE];
|
||||||
|
std::vector<std::string> mCommandHistory;
|
||||||
|
bool mbNewCommand;
|
||||||
|
|
||||||
|
private:
|
||||||
|
LuaConsole();
|
||||||
|
LuaConsole(const LuaConsole&) = delete;
|
||||||
|
const LuaConsole& operator=(const LuaConsole&) = delete;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LUA_CONSOLE_H_
|
||||||
Loading…
Reference in New Issue