Skip to content

Commit

Permalink
fix (./Statistcs)
Browse files Browse the repository at this point in the history
  • Loading branch information
PharaEthan committed Jan 9, 2024
1 parent e75646d commit a737e14
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 24 deletions.
1 change: 1 addition & 0 deletions Exodia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(SOURCES
src/Panel/ContentBrowser/ContentBrowser.cpp
src/Panel/SceneHierarchy/SceneHierarchy.cpp
src/Panel/Statistics/Statistics.cpp
src/Panel/Console/Console.cpp

# Thumbnail sources files

Expand Down
4 changes: 4 additions & 0 deletions Exodia/src/Layer/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ namespace Exodia {
ImGui::Checkbox("Show Collision", &_ShowCollisions);
ImGui::End();

// -- Console ------------------------------------------------------

_Console.OnImGuiRender();

// -- Viewport -----------------------------------------------------

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{0, 0});
Expand Down
2 changes: 2 additions & 0 deletions Exodia/src/Layer/EditorLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Panel/ContentBrowser/ContentBrowser.hpp"
#include "Panel/SceneHierarchy/SceneHierarchy.hpp"
#include "Panel/Statistics/Statistics.hpp"
#include "Panel/Console/Console.hpp"

namespace Exodia {

Expand Down Expand Up @@ -87,6 +88,7 @@ namespace Exodia {
Scope<ContentBrowser> _ContentBrowser;
SceneHierarchy _SceneHierarchy;
StatistcsPanel _StatisticsPanel;
Console _Console;

// Entity
GameObject _HoveredEntity;
Expand Down
50 changes: 50 additions & 0 deletions Exodia/src/Panel/Console/Console.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
** EPITECH PROJECT, 2024
** R-Type
** File description:
** Console
*/

#include "Console.hpp"
#include "Exodia.hpp"

namespace Exodia {

/////////////
// Methods //
/////////////

void Console::OnImGuiRender()
{
ImGui::Begin("Console");

for (std::string &log : GetLogs())
ImGui::Text("%s", log.c_str());

ImGui::End();
}

///////////////////////
// Getters & Setters //
///////////////////////

std::vector<std::string> Console::GetLogs()
{
LogHistory coreHistory = Log::GetCoreLoggerHistory();
std::vector <std::string> logs;

for (const std::string &logFileName : coreHistory.GetLogs()) {
std::ifstream logFile(logFileName);

if (logFile.is_open()) {
std::string line;

while (std::getline(logFile, line))
logs.push_back(line);
logFile.close();
}
}

return logs;
}
};
43 changes: 43 additions & 0 deletions Exodia/src/Panel/Console/Console.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
** EPITECH PROJECT, 2024
** R-Type
** File description:
** Console
*/

#ifndef CONSOLE_HPP_
#define CONSOLE_HPP_

// External includes
#include <vector>
#include <string>

namespace Exodia {

class Console {

//////////////////////////////
// Constructor & Destructor //
//////////////////////////////
public:

Console() = default;
~Console() = default;

/////////////
// Methods //
/////////////
public:

void OnImGuiRender();

///////////////////////
// Getters & Setters //
///////////////////////
private:

std::vector<std::string> GetLogs();
};
};

#endif /* !CONSOLE_HPP_ */
7 changes: 3 additions & 4 deletions Exodia/src/Panel/Statistics/Statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ namespace Exodia {
/////////////

void StatistcsPanel::OnImGuiRender() {
ImGui::Begin("Statistics :");
ImGui::Begin("Statistics");
ImGui::Text("FPS: %.1f", Application::Get().GetStatistics().FPS);
ImGui::Text("Frame Time: %.3f ms", Application::Get().GetStatistics().FrameTime);
ImGui::Text("Memory Usage: %ld KB", Application::Get().GetStatistics().MemoryUsage / 1024);
ImGui::End();

ImGui::Begin("Renderer Statistics:");
ImGui::Separator();
ImGui::Text("Renderer Statistics :");
ImGui::Text("Draw Calls: %d", Renderer2D::GetStats().DrawCalls);
ImGui::Text("Quad Count: %d", Renderer2D::GetStats().QuadCount);
ImGui::Text("Vertex Count: %d", Renderer2D::GetStats().GetTotalVertexCount());
Expand Down
27 changes: 27 additions & 0 deletions Library/Debug/src/Logger/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,31 @@ namespace Exodia {

spdlog::register_logger(_ClientLogger);
}

///////////////////////
// Getters & Setters //
///////////////////////

LogHistory Log::GetCoreLoggerHistory()
{
LogHistory history;

for (const auto &sink : _CoreLogger->sinks()) {
if (auto file_sink = std::dynamic_pointer_cast<spdlog::sinks::basic_file_sink_mt>(sink))
history.AddLog(file_sink->filename());
}
return history;
}

LogHistory Log::GetClientLoggerHistory()
{
LogHistory history;

for (const auto &sink : _ClientLogger->sinks()) {
if (auto file_sink = std::dynamic_pointer_cast<spdlog::sinks::basic_file_sink_mt>(sink))
history.AddLog(file_sink->filename());
}

return history;
}
}; // namespace Exodia
17 changes: 17 additions & 0 deletions Library/Debug/src/Logger/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@

namespace Exodia {

struct LogHistory {
std::vector<std::string> Logs;

void AddLog(const std::string &log)
{
Logs.push_back(log);
}

const std::vector<std::string> &GetLogs() const
{
return Logs;
}
};

/**
* @brief Class that will be used for log
*/
Expand Down Expand Up @@ -52,6 +66,9 @@ namespace Exodia {
*/
inline static Ref<spdlog::logger> &GetClientLogger() { return _ClientLogger; }

static LogHistory GetCoreLoggerHistory();
static LogHistory GetClientLoggerHistory();

////////////////
// Attributes //
////////////////
Expand Down
56 changes: 36 additions & 20 deletions imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,60 @@ DockId=0x00000002,0

[Window][Viewport]
Pos=302,58
Size=996,584
Size=996,585
Collapsed=0
DockId=0x00000008,0

[Window][Content Browser]
Pos=302,644
Size=996,256
Pos=302,645
Size=996,255
Collapsed=0
DockId=0x00000004,0

[Window][Statistics :]
Pos=1300,24
Size=300,876
Pos=1452,24
Size=148,876
Collapsed=0
DockId=0x0000000A,1
DockId=0x0000000C,0

[Window][Renderer Statistics:]
Pos=1300,24
Size=300,876
Size=150,876
Collapsed=0
DockId=0x0000000A,0
DockId=0x0000000B,0

[Window][Settings]
Pos=1300,24
Size=300,876
Collapsed=0
DockId=0x0000000A,2
DockId=0x0000000E,0

[Window][Console]
Pos=302,645
Size=996,255
Collapsed=0
DockId=0x00000004,1

[Window][Statistics]
Pos=1300,24
Size=300,876
Collapsed=0
DockId=0x0000000E,1

[Docking][Data]
DockSpace ID=0x3FC20BEE Window=0x9A404470 Pos=210,132 Size=1600,876 Split=X Selected=0x13926F0B
DockNode ID=0x00000009 Parent=0x3FC20BEE SizeRef=1298,876 Split=X
DockNode ID=0x00000005 Parent=0x00000009 SizeRef=300,876 Split=Y Selected=0x2E9237F7
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=253,619 Selected=0x2E9237F7
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=253,255 Selected=0x199AB496
DockNode ID=0x00000006 Parent=0x00000009 SizeRef=996,876 Split=Y
DockNode ID=0x00000003 Parent=0x00000006 SizeRef=1600,618 Split=Y Selected=0x13926F0B
DockNode ID=0x00000007 Parent=0x00000003 SizeRef=1140,32 HiddenTabBar=1 Selected=0xF0F70764
DockNode ID=0x00000008 Parent=0x00000003 SizeRef=1140,584 CentralNode=1 HiddenTabBar=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000006 SizeRef=1600,256 Selected=0xBF096F38
DockNode ID=0x0000000A Parent=0x3FC20BEE SizeRef=300,876 Selected=0x54723243
DockSpace ID=0x3FC20BEE Window=0x9A404470 Pos=152,137 Size=1600,876 Split=X Selected=0x13926F0B
DockNode ID=0x0000000D Parent=0x3FC20BEE SizeRef=1298,876 Split=X
DockNode ID=0x00000009 Parent=0x0000000D SizeRef=1298,876 Split=X
DockNode ID=0x00000005 Parent=0x00000009 SizeRef=300,876 Split=Y Selected=0x2E9237F7
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=253,619 Selected=0x2E9237F7
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=253,255 Selected=0x199AB496
DockNode ID=0x00000006 Parent=0x00000009 SizeRef=996,876 Split=Y
DockNode ID=0x00000003 Parent=0x00000006 SizeRef=1600,619 Split=Y Selected=0x13926F0B
DockNode ID=0x00000007 Parent=0x00000003 SizeRef=1140,32 HiddenTabBar=1 Selected=0xF0F70764
DockNode ID=0x00000008 Parent=0x00000003 SizeRef=1140,585 CentralNode=1 HiddenTabBar=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000006 SizeRef=1600,255 Selected=0x49278EEE
DockNode ID=0x0000000A Parent=0x0000000D SizeRef=300,876 Split=X Selected=0x537592BB
DockNode ID=0x0000000B Parent=0x0000000A SizeRef=150,876 Selected=0x537592BB
DockNode ID=0x0000000C Parent=0x0000000A SizeRef=148,876 Selected=0xF097908C
DockNode ID=0x0000000E Parent=0x3FC20BEE SizeRef=300,876 Selected=0x47E8F9DC

0 comments on commit a737e14

Please sign in to comment.