Skip to content

Commit

Permalink
feat: Adapt to new libs
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed Oct 29, 2024
1 parent d674b26 commit d64544b
Show file tree
Hide file tree
Showing 25 changed files with 883 additions and 808 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
git submodule update --init --recursive
# Configure and build
cd "build"
cd build
sudo bash ./build.sh
3 changes: 3 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
build_spdlog
dist
2 changes: 1 addition & 1 deletion lib/cherry
Submodule cherry updated 156 files
2 changes: 1 addition & 1 deletion lib/json
2 changes: 1 addition & 1 deletion lib/spdlog
7 changes: 3 additions & 4 deletions ui/crash_handler/crash_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ class CrashHandler
CrashHandler()
{
// Render static windows
crash_handler = std::make_shared<Crash>("Crash report");
crash_handler->RefreshRender(crash_handler);
Cherry::AddWindow(crash_handler->GetAppWindow()); // Publish this window into the workspace
crash_handler = CrashAppWindow::Create("Crash report");
Cherry::AddAppWindow(crash_handler->GetAppWindow()); // Publish this window into the workspace
};

private:
std::shared_ptr<Crash> crash_handler;
std::shared_ptr<CrashAppWindow> crash_handler;
};

static std::shared_ptr<CrashHandler> c_CrashHandler;
Expand Down
50 changes: 34 additions & 16 deletions ui/crash_handler/src/static/crash_report/crash_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
static bool consent_data_inspection;
static bool consent_response;

Crash::Crash(const std::string &name)
CrashAppWindow::CrashAppWindow(const std::string &name)
{
this->ctx = VortexMaker::GetCurrentContext();
m_AppWindow = std::make_shared<Cherry::AppWindow>(name, name);
Expand Down Expand Up @@ -78,10 +78,30 @@ bool loadFileToString(const std::string &filename, char *text, size_t maxSize)

static std::vector<std::tuple<std::string, std::string, std::string>> modifiable_values;

void Crash::RefreshRender(const std::shared_ptr<Crash> &instance)
std::shared_ptr<Cherry::AppWindow> &CrashAppWindow::GetAppWindow()
{
return m_AppWindow;
}

std::shared_ptr<CrashAppWindow> CrashAppWindow::Create(const std::string &name)
{
auto instance = std::shared_ptr<CrashAppWindow>(new CrashAppWindow(name));
instance->SetupRenderCallback();
return instance;
}

void CrashAppWindow::SetupRenderCallback()
{
auto self = shared_from_this();
m_AppWindow->SetRenderCallback([self]()
{
if (self) {
self->Render();
} });
}

void CrashAppWindow::Render()
{
m_AppWindow->SetRenderCallback([instance]()
{
float oldsize = ImGui::GetFont()->Scale;
ImGui::GetFont()->Scale *= 1.5;
ImGui::PushFont(ImGui::GetFont());
Expand All @@ -102,7 +122,7 @@ void Crash::RefreshRender(const std::shared_ptr<Crash> &instance)
ImGui::SameLine();

ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 105));
ImGui::TextWrapped(instance->ctx->state.session_id.c_str());
ImGui::TextWrapped(ctx->state.session_id.c_str());
ImGui::PopStyleColor(1);

ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
Expand Down Expand Up @@ -260,7 +280,7 @@ void Crash::RefreshRender(const std::shared_ptr<Crash> &instance)
static char text[bufferSize];

// Load content from file into text variable
static std::string log_file = VortexMaker::getHomeDirectory() + "/.vx/sessions/" + instance->ctx->state.session_id + "/logs/global.log";
static std::string log_file = VortexMaker::getHomeDirectory() + "/.vx/sessions/" + ctx->state.session_id + "/logs/global.log";
if (!loadFileToString(log_file, text, bufferSize))
{
// Handle error opening or reading the file
Expand All @@ -280,7 +300,7 @@ void Crash::RefreshRender(const std::shared_ptr<Crash> &instance)
static char text[bufferSize];

// Load content from file into text variable
static std::string log_file = VortexMaker::getHomeDirectory() + "/.vx/sessions/" + instance->ctx->state.session_id + "/crash/core_dumped.txt";
static std::string log_file = VortexMaker::getHomeDirectory() + "/.vx/sessions/" + ctx->state.session_id + "/crash/core_dumped.txt";
if (!loadFileToString(log_file, text, bufferSize))
{
// Handle error opening or reading the file
Expand Down Expand Up @@ -329,8 +349,6 @@ void Crash::RefreshRender(const std::shared_ptr<Crash> &instance)
if (ImGui::Button("Send and restart", buttonSize))
{
}

});
}

static void handleRefresh()
Expand Down Expand Up @@ -363,15 +381,15 @@ static void handleSearch()
// Behavior
}

void Crash::addModuleModal()
void CrashAppWindow::addModuleModal()
{
}

void Crash::mainButtonsMenuItem()
void CrashAppWindow::mainButtonsMenuItem()
{
}

void Crash::filterMenuItem()
void CrashAppWindow::filterMenuItem()
{
ImGui::Separator();
if (ImGui::BeginMenu("Filters"))
Expand All @@ -388,7 +406,7 @@ void Crash::filterMenuItem()
}
}

void Crash::createMenuItem()
void CrashAppWindow::createMenuItem()
{
if (ImGui::BeginMenu("Create a module"))
{
Expand All @@ -404,7 +422,7 @@ void Crash::createMenuItem()
}
}

void Crash::searchMenuItem()
void CrashAppWindow::searchMenuItem()
{
if (ImGui::BeginMenu("Search"))
{
Expand All @@ -420,7 +438,7 @@ void Crash::searchMenuItem()
}
}

void Crash::menubar()
void CrashAppWindow::menubar()
{
if (ImGui::BeginMenuBar())
{
Expand All @@ -429,5 +447,5 @@ void Crash::menubar()
}
}

void Crash::Refresh() {
void CrashAppWindow::Refresh() {
};
13 changes: 6 additions & 7 deletions ui/crash_handler/src/static/crash_report/crash_report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
#ifndef CRASH_H
#define CRASH_H

class Crash
class CrashAppWindow : public std::enable_shared_from_this<CrashAppWindow>
{
public:
Crash(const std::string& name);
CrashAppWindow(const std::string& name);

void menubar();
void addModuleModal();

void Refresh();
void Update();

void RefreshRender(const std::shared_ptr<Crash>& instance);
std::shared_ptr<Cherry::AppWindow> &GetAppWindow();
static std::shared_ptr<CrashAppWindow> Create(const std::string &name);
void SetupRenderCallback();
void Render();

std::shared_ptr<Cherry::AppWindow> &GetAppWindow()
{
return m_AppWindow;
}

/**
* @brief Menu items
Expand Down
28 changes: 23 additions & 5 deletions ui/editor/app/core/modules_utility/modules_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,30 @@ namespace VortexEditor
m_AppWindow->SetInternalPaddingY(10.0f);
}

std::shared_ptr<Cherry::AppWindow> &ModuleManagerAppWindow::GetAppWindow()
{
return m_AppWindow;
}

std::shared_ptr<ModuleManagerAppWindow> ModuleManagerAppWindow::Create(const std::string &name)
{
auto instance = std::shared_ptr<ModuleManagerAppWindow>(new ModuleManagerAppWindow(name));
instance->SetupRenderCallback();
return instance;
}

void ModuleManagerAppWindow::RefreshRender(const std::shared_ptr<ModuleManagerAppWindow> &instance)
void ModuleManagerAppWindow::SetupRenderCallback()
{
m_AppWindow->SetRenderCallback([instance]()
auto self = shared_from_this();
m_AppWindow->SetRenderCallback([self]()
{
if (self) {
self->Render();
} });
}

void ModuleManagerAppWindow::Render()
{
float oldsize = ImGui::GetFont()->Scale;
ImGui::GetFont()->Scale *= 1.3;
ImGui::PushFont(ImGui::GetFont());
Expand Down Expand Up @@ -330,8 +349,8 @@ namespace VortexEditor
if (ImGui::Button("Details"))
{
// Behavior
//std::shared_ptr<ModuleDetails> instance = std::make_shared<ModuleDetails>(VortexMaker::GetCurrentContext(), VortexMaker::GetCurrentContext()->IO.em[i]);
//this->factory->SpawnInstance(instance);
// std::shared_ptr<ModuleDetails> instance = std::make_shared<ModuleDetails>(VortexMaker::GetCurrentContext(), VortexMaker::GetCurrentContext()->IO.em[i]);
// this->factory->SpawnInstance(instance);
}
}

Expand Down Expand Up @@ -380,7 +399,6 @@ namespace VortexEditor
}

ImGui::EndChildFrame();
});
}

// Helper functions for menu items
Expand Down
13 changes: 6 additions & 7 deletions ui/editor/app/core/modules_utility/modules_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ using namespace Cherry;

namespace VortexEditor
{
class ModuleManagerAppWindow
class ModuleManagerAppWindow : public std::enable_shared_from_this<ModuleManagerAppWindow>
{
public:
ModuleManagerAppWindow(const std::string &name);

void menubar();
void addModuleModal();
void RefreshRender(const std::shared_ptr<ModuleManagerAppWindow> &instance);

std::shared_ptr<Cherry::AppWindow> &GetAppWindow()
{
return m_AppWindow;
}

std::shared_ptr<Cherry::AppWindow> &GetAppWindow();
static std::shared_ptr<ModuleManagerAppWindow> Create(const std::string &name);
void SetupRenderCallback();
void Render();

private:
bool opened;
Expand Down
Loading

0 comments on commit d64544b

Please sign in to comment.