Skip to content

Commit

Permalink
Update resource panel
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorton06 committed Jul 2, 2023
1 parent 619c333 commit 2842e65
Show file tree
Hide file tree
Showing 56 changed files with 3,952 additions and 3,213 deletions.
104 changes: 55 additions & 49 deletions Editor/Source/ApplicationInfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,36 @@

namespace Lumos
{
struct ScrollingBuffer {
int MaxSize;
int Offset;
ImVector<ImVec2> Data;
ScrollingBuffer(int max_size = 2000) {
MaxSize = max_size;
Offset = 0;
Data.reserve(MaxSize);
}
void AddPoint(float x, float y) {
if (Data.size() < MaxSize)
Data.push_back(ImVec2(x,y));
else {
Data[Offset] = ImVec2(x,y);
Offset = (Offset + 1) % MaxSize;
}
}
void Erase() {
if (Data.size() > 0) {
Data.shrink(0);
struct ScrollingBuffer
{
int MaxSize;
int Offset;
ImVector<ImVec2> Data;
ScrollingBuffer(int max_size = 2000)
{
MaxSize = max_size;
Offset = 0;
Data.reserve(MaxSize);
}
}
};
void AddPoint(float x, float y)
{
if(Data.size() < MaxSize)
Data.push_back(ImVec2(x, y));
else
{
Data[Offset] = ImVec2(x, y);
Offset = (Offset + 1) % MaxSize;
}
}
void Erase()
{
if(Data.size() > 0)
{
Data.shrink(0);
Offset = 0;
}
}
};

ApplicationInfoPanel::ApplicationInfoPanel()
{
Expand All @@ -54,50 +60,50 @@ struct ScrollingBuffer {
{
ImGuiUtilities::PushID();

//m_FPSData.push_back(Lumos::Engine::Get().Statistics().FramesPerSecond);
//MaxFrameTime = Maths::Max(MaxFrameTime, m_FPSData.back());
// m_FPSData.push_back(Lumos::Engine::Get().Statistics().FramesPerSecond);
// MaxFrameTime = Maths::Max(MaxFrameTime, m_FPSData.back());

static ScrollingBuffer rdata(40000), rdata1(40000);
static float t = 0;
t += ImGui::GetIO().DeltaTime;
static int frame = 0;
frame++;
//if (frame > (int)(ImGui::GetIO().Framerate / 60))

// if (frame > (int)(ImGui::GetIO().Framerate / 60))
{
rdata.AddPoint(t, ImGui::GetIO().Framerate);
rdata1.AddPoint(t, Lumos::Engine::GetTimeStep().GetMillis());//1000.0f / ImGui::GetIO().Framerate);
rdata1.AddPoint(t, Lumos::Engine::GetTimeStep().GetMillis()); // 1000.0f / ImGui::GetIO().Framerate);
}

static ImPlotAxisFlags rt_axis = ImPlotAxisFlags_NoTickLabels;
static bool PlotFrameTime = true;
static bool PlotFramerate = false;
static bool PlotFrameTime = true;
static bool PlotFramerate = false;

ImGui::Checkbox("Plot Frame Time", &PlotFrameTime);
ImGui::Checkbox("Plot Frame Rate", &PlotFramerate);

if (PlotFramerate && ImPlot::BeginPlot("Framerate", ImVec2(-1, 350), 0))
{
ImPlot::SetupAxis(ImAxis_X1, nullptr, rt_axis);
ImPlot::SetupAxis(ImAxis_Y1, "FPS", 0);
ImPlot::SetupAxisLimits(ImAxis_X1, t - 10.0f, t, ImGuiCond_Always);
ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 120);
if(PlotFramerate && ImPlot::BeginPlot("Framerate", ImVec2(-1, 350), 0))
{
ImPlot::SetupAxis(ImAxis_X1, nullptr, rt_axis);
ImPlot::SetupAxis(ImAxis_Y1, "FPS", 0);
ImPlot::SetupAxisLimits(ImAxis_X1, t - 10.0f, t, ImGuiCond_Always);
ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 120);

ImPlot::PlotLine("##Framerate", &rdata.Data[0].x, &rdata.Data[0].y, rdata.Data.size(), 0, rdata.Offset, 2 * sizeof(float));
ImPlot::PlotLine("##Framerate", &rdata.Data[0].x, &rdata.Data[0].y, rdata.Data.size(), 0, rdata.Offset, 2 * sizeof(float));

ImPlot::EndPlot();
}
if (PlotFrameTime && ImPlot::BeginPlot("Frametime", ImVec2(-1, 350), 0))
{
ImPlot::SetupAxis(ImAxis_X1, nullptr, rt_axis);
ImPlot::SetupAxis(ImAxis_Y1, "Frame (ms)", 0);
ImPlot::SetupAxisLimits(ImAxis_X1, t - 10.0f, t, ImGuiCond_Always);
ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 60);
ImPlot::EndPlot();
}
if(PlotFrameTime && ImPlot::BeginPlot("Frametime", ImVec2(-1, 350), 0))
{
ImPlot::SetupAxis(ImAxis_X1, nullptr, rt_axis);
ImPlot::SetupAxis(ImAxis_Y1, "Frame (ms)", 0);
ImPlot::SetupAxisLimits(ImAxis_X1, t - 10.0f, t, ImGuiCond_Always);
ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 60);

ImPlot::PlotLine("##Framerate", &rdata1.Data[0].x, &rdata1.Data[0].y, rdata1.Data.size(), 0, rdata1.Offset, 2 * sizeof(float));
ImPlot::PlotLine("##Framerate", &rdata1.Data[0].x, &rdata1.Data[0].y, rdata1.Data.size(), 0, rdata1.Offset, 2 * sizeof(float));

ImPlot::EndPlot();
}
ImPlot::EndPlot();
}

if(ImGui::TreeNodeEx("Application", ImGuiTreeNodeFlags_DefaultOpen))
{
Expand Down
135 changes: 69 additions & 66 deletions Editor/Source/ConsolePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,38 +176,43 @@ namespace Lumos
{
LUMOS_PROFILE_FUNCTION();
// ImGui::BeginChild("ScrollRegion", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
if(ImGui::BeginTable("Messages", 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg ))
if(ImGui::BeginTable("Messages", 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg))
{

ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_NoSort, 0.0f, MyItemColumnID_Type);
ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoSort, 0.0f, MyItemColumnID_Time);
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Type);
ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Time);
ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_NoSort, 0.0f, MyItemColumnID_Message);
ImGui::TableSetupScrollFreeze(0, 1);

ImGui::TableHeadersRow();
// ImGuiUtilities::AlternatingRowsBackground();

ImGui::TableNextRow();

auto DrawMessage = [](Message* message)
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text, message->GetRenderColour(message->m_Level));
auto levelIcon = message->GetLevelIcon(message->m_Level);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - ImGui::CalcTextSize(levelIcon).x
- ImGui::GetScrollX() - 2 * ImGui::GetStyle().ItemSpacing.x);
ImGui::TextUnformatted(levelIcon);

if(ImGui::IsItemHovered())
if(s_MessageBufferRenderFilter & message->m_Level)
{
ImGui::SetTooltip("%s", Message::GetLevelName(message->m_Level));
}
ImGui::PopStyleColor();
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text, message->GetRenderColour(message->m_Level));
auto levelIcon = message->GetLevelIcon(message->m_Level);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - ImGui::CalcTextSize(levelIcon).x
- ImGui::GetScrollX() - 2 * ImGui::GetStyle().ItemSpacing.x);
ImGui::TextUnformatted(levelIcon);

if(ImGui::IsItemHovered())
{
ImGui::SetTooltip("%s", Message::GetLevelName(message->m_Level));
}
ImGui::PopStyleColor();

ImGui::TableNextColumn();
ImGui::TextUnformatted(message->m_Time.c_str());
ImGui::TableNextColumn();
ImGui::TextUnformatted(message->m_Time.c_str());

ImGui::TableNextColumn();
message->OnImGUIRender();
ImGui::TableNextColumn();
message->OnImGUIRender();
ImGui::TableNextRow();
}
};

auto messageStart = s_MessageBuffer.begin() + s_MessageBufferBegin;
Expand Down Expand Up @@ -272,70 +277,68 @@ namespace Lumos
void ConsolePanel::Message::OnImGUIRender()
{
LUMOS_PROFILE_FUNCTION();
if(s_MessageBufferRenderFilter & m_Level)
{
ImGuiUtilities::ScopedID scopedID((int)m_MessageID);
ImGui::TextUnformatted(m_Message.c_str());

bool clicked = false;
if(ImGui::IsItemClicked())
clicked = true;
ImGuiUtilities::ScopedID scopedID((int)m_MessageID);
ImGui::TextUnformatted(m_Message.c_str());

if(ImGui::BeginPopupContextItem(m_Message.c_str()))
{
if(ImGui::MenuItem("Copy"))
{
ImGui::SetClipboardText(m_Message.c_str());
}
bool clicked = false;
if(ImGui::IsItemClicked())
clicked = true;

ImGui::EndPopup();
}
static bool m_DetailedPanelOpen = false;
if(clicked)
if(ImGui::BeginPopupContextItem(m_Message.c_str()))
{
if(ImGui::MenuItem("Copy"))
{
ImGui::OpenPopup("Message");
ImVec2 size = ImGui::GetMainViewport()->Size;
ImGui::SetNextWindowSize({ size.x * 0.5f, size.y * 0.5f });
ImGui::SetNextWindowPos({ size.x / 2.0f, size.y / 2.5f }, 0, { 0.5, 0.5 });
m_DetailedPanelOpen = true;
ImGui::SetClipboardText(m_Message.c_str());
}

if(m_DetailedPanelOpen)
ImGui::EndPopup();
}
static bool m_DetailedPanelOpen = false;
if(clicked)
{
ImGui::OpenPopup("Message");
ImVec2 size = ImGui::GetMainViewport()->Size;
ImGui::SetNextWindowSize({ size.x * 0.5f, size.y * 0.5f });
ImGui::SetNextWindowPos({ size.x / 2.0f, size.y / 2.5f }, 0, { 0.5, 0.5 });
m_DetailedPanelOpen = true;
}

if(m_DetailedPanelOpen)
{
if(ImGui::BeginPopupModal("Message", &m_DetailedPanelOpen, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
if(ImGui::BeginPopupModal("Message", &m_DetailedPanelOpen, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
ImGui::TextWrapped("Message : %s", m_Message.c_str());
ImGui::TextWrapped("Message : %s", m_Message.c_str());

if(ImGui::BeginPopupContextItem(m_Message.c_str()))
if(ImGui::BeginPopupContextItem(m_Message.c_str()))
{
if(ImGui::MenuItem("Copy"))
{
if(ImGui::MenuItem("Copy"))
{
ImGui::SetClipboardText(m_Message.c_str());
}

ImGui::EndPopup();
ImGui::SetClipboardText(m_Message.c_str());
}

ImGui::TextWrapped("Source : %s", m_Source.c_str());

ImGui::Text("Time : %s", m_Time.c_str());
ImGui::Text("Type : %s", Message::GetLevelName(m_Level));

ImGui::EndPopup();
}
}

if(ImGui::IsItemHovered())
{
ImGui::SetTooltip("%s", m_Source.c_str());
}
ImGui::TextWrapped("Source : %s", m_Source.c_str());

if(m_Count > 1)
{
ImGui::SameLine(ImGui::GetContentRegionAvail().x - (m_Count > 99 ? ImGui::GetFontSize() * 1.7f : ImGui::GetFontSize() * 1.5f));
ImGui::Text("%d", m_Count);
ImGui::Text("Time : %s", m_Time.c_str());
ImGui::Text("Type : %s", Message::GetLevelName(m_Level));

ImGui::EndPopup();
}
}

if(ImGui::IsItemHovered())
{
ImGui::SetTooltip("%s", m_Source.c_str());
}

if(m_Count > 1)
{
ImGui::SameLine(ImGui::GetContentRegionAvail().x - (m_Count > 99 ? ImGui::GetFontSize() * 1.7f : ImGui::GetFontSize() * 1.5f));
ImGui::Text("%d", m_Count);
}
}

const char* ConsolePanel::Message::GetLevelIcon(Level level)
Expand Down
21 changes: 7 additions & 14 deletions Editor/Source/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@

#include <cereal/version.hpp>

#ifdef LUMOS_PLATFORM_WINDOWS
#include <shellapi.h>
#endif

namespace Lumos
{
Editor* Editor::s_Editor = nullptr;
Expand All @@ -89,6 +85,9 @@ namespace Lumos
{
SaveEditorSettings();

for(auto panel : m_Panels)
panel->DestroyGraphicsResources();

m_GridRenderer.reset();
// m_PreviewRenderer.reset();
m_PreviewTexture.reset();
Expand Down Expand Up @@ -239,9 +238,9 @@ namespace Lumos
m_ComponentIconMap[typeid(Maths::Transform).hash_code()] = ICON_MDI_VECTOR_LINE;
m_ComponentIconMap[typeid(RigidBody2DComponent).hash_code()] = ICON_MDI_SQUARE_OUTLINE;
m_ComponentIconMap[typeid(RigidBody3DComponent).hash_code()] = ICON_MDI_CUBE_OUTLINE;
m_ComponentIconMap[typeid(Graphics::ModelComponent).hash_code()] = ICON_MDI_SHAPE;
m_ComponentIconMap[typeid(Graphics::Model).hash_code()] = ICON_MDI_SHAPE;
m_ComponentIconMap[typeid(LuaScriptComponent).hash_code()] = ICON_MDI_SCRIPT;
m_ComponentIconMap[typeid(Graphics::ModelComponent).hash_code()] = ICON_MDI_VECTOR_POLYGON;
m_ComponentIconMap[typeid(Graphics::Model).hash_code()] = ICON_MDI_VECTOR_POLYGON;
m_ComponentIconMap[typeid(LuaScriptComponent).hash_code()] = ICON_MDI_LANGUAGE_LUA;
m_ComponentIconMap[typeid(Graphics::Environment).hash_code()] = ICON_MDI_EARTH;
m_ComponentIconMap[typeid(Editor).hash_code()] = ICON_MDI_SQUARE;
m_ComponentIconMap[typeid(TextComponent).hash_code()] = ICON_MDI_TEXT;
Expand Down Expand Up @@ -804,13 +803,7 @@ namespace Lumos
std::string githubMenuText = ICON_MDI_GITHUB_BOX " Github";
if(ImGui::MenuItem(githubMenuText.c_str()))
{
#ifdef LUMOS_PLATFORM_WINDOWS
ShellExecute(NULL, NULL, L"https://www.github.com/jmorton06/Lumos", NULL, NULL, SW_SHOWNORMAL);
#else
#ifndef LUMOS_PLATFORM_IOS
system("open https://www.github.com/jmorton06/Lumos");
#endif
#endif
Lumos::OS::Instance()->OpenURL("https://www.github.com/jmorton06/Lumos");
}
ImGui::Separator();

Expand Down
4 changes: 4 additions & 0 deletions Editor/Source/EditorPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ namespace Lumos
{
}

virtual void DestroyGraphicsResources()
{
}

protected:
bool m_Active = true;
std::string m_Name;
Expand Down
Loading

0 comments on commit 2842e65

Please sign in to comment.