Skip to content

Commit

Permalink
Core : Prepare the final launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed May 3, 2024
1 parent ab7f744 commit 242f3cd
Show file tree
Hide file tree
Showing 16 changed files with 476 additions and 56 deletions.
Binary file modified build/bin/vortex
Binary file not shown.
8 changes: 8 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "./tools/launcher/app/include/launcher.h"

#include "./main/include/vortex.h"
#include "./main/include/templates/load.h"
#include "./lib/uikit/src/EntryPoint.h"

void PrintInfinite()
Expand Down Expand Up @@ -120,6 +121,8 @@ VxContext *InitRuntime(bool logger)

return ctx;
}
// Project sys size== 0


// Project creator,
// Template deployment overrides (project, modules_content, etc...)
Expand All @@ -132,6 +135,11 @@ VxContext *InitBlankRuntime(bool logger)
// Initialize environment
VortexMaker::InitEnvironment();

// Refresh environment registered projects
VortexMaker::RefreshEnvironmentProjects();

VortexMaker::LoadSystemTemplates(ctx->IO.sys_templates);

ctx->logger = logger;
return ctx;
}
Expand Down
2 changes: 2 additions & 0 deletions main/include/vortex.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ namespace VortexMaker
VORTEX_API void UpdateEnvironmentProject();
VORTEX_API void UpdateEnvironmentProject(const std::string& oldname);

VORTEX_API std::string getCurrentTimeStamp();

VORTEX_API std::vector<std::string> SearchFiles(const std::string &path, const std::string &filename);
VORTEX_API std::vector<std::string> SearchSystemFiles(const std::string &path, const std::string &filename);
VORTEX_API std::string SearchFilesRecursive(const fs::path &chemin, const std::string &filename, std::vector<std::string> &file);
Expand Down
1 change: 1 addition & 0 deletions main/include/vortex_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct VxContext
VxPaths paths;
std::string configFilePath;
std::string author;
std::string compatibleWith;
std::string description;
std::string label;
std::string name;
Expand Down
35 changes: 32 additions & 3 deletions main/src/vortex/environment/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,39 @@ VORTEX_API void VortexMaker::InitEnvironment()
std::string path = VortexMaker::getHomeDirectory() + "/.vx/modules/";
VortexMaker::createFolderIfNotExists(path);
}

{
std::string path = VortexMaker::getHomeDirectory() + "/.vx/templates/";
VortexMaker::createFolderIfNotExists(path);
}

{
std::string path = VortexMaker::getHomeDirectory() + "/.vx/templates/vortex.templates.builtin.__blankproject/";
VortexMaker::createFolderIfNotExists(path);
}
{
std::string path = VortexMaker::getHomeDirectory() + "/.vx/templates/vortex.templates.builtin.__blankproject/";
std::string file = path + "template.json";

nlohmann::json default_data = {
{"type", "project"},
{"group", "Core"},
{"name", "vortex.templates.builtin.blankproject"},
{"proper_name", "Blank project"},
{"author", "Infinite"},
{"version", "--"},
{"compatibleWith", "--"},
{"tarball", "--"},
{"picture", "/usr/include/vortex/icon.png"},
{"description", "This the most minimum sample project for Vortex."},
{"deps", nlohmann::json::array()},
{"contributors", nlohmann::json::array()}
};

VortexMaker::createJsonFileIfNotExists(file, default_data);
}

{
std::string path = VortexMaker::getHomeDirectory() + "/.vx/data/";
std::string file = path + "projects.json";

Expand All @@ -36,9 +62,9 @@ VORTEX_API void VortexMaker::RefreshEnvironmentProjects()
// Get reference to the Vortex context
VxContext &ctx = *CVortexMaker;

std::string path = VortexMaker::getHomeDirectory() + "/.vx/data/projects.json";
std::string path = VortexMaker::getHomeDirectory() + "/.vx/data/";

std::string json_file = path + "/project.json";
std::string json_file = path + "/projects.json";

// Verify if the project is valid
try
Expand All @@ -57,7 +83,6 @@ VORTEX_API void VortexMaker::RefreshEnvironmentProjects()

ctx.IO.sys_projects.push_back(newproject);
}

}
catch (const std::exception &e)
{
Expand Down Expand Up @@ -92,6 +117,8 @@ VORTEX_API void VortexMaker::UpdateEnvironmentProject()
project["version"] = ctx.version;
project["description"] = ctx.description;
project["path"] = ctx.projectPath;
project["compatibleWith"] = ctx.compatibleWith;
project["lastOpened"] = VortexMaker::getCurrentTimeStamp();
project["logoPath"] = ctx.logoPath;
projectExists = true;
break;
Expand All @@ -106,6 +133,8 @@ VORTEX_API void VortexMaker::UpdateEnvironmentProject()
{"version", ctx.version},
{"description", ctx.description},
{"path", ctx.projectPath},
{"lastOpened", VortexMaker::getCurrentTimeStamp()},
{"compatibleWith", ctx.compatibleWith},
{"logoPath", ctx.logoPath}
});
}
Expand Down
1 change: 1 addition & 0 deletions main/src/vortex/project/create_project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void VortexMaker::CreateProject(const std::string& name, const std::string& path
j["project"]["name"] = name;
j["project"]["type"] = "???";
j["project"]["version"] = "1.0.0";
j["project"]["compatibleWith"] = VORTEX_VERSION;
j["project"]["include_system_templates"] = true;

j["data"]["toolchains"] = "./.vx/data/toolchains/";
Expand Down
18 changes: 9 additions & 9 deletions main/src/vortex/project/init_project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

/**
* @brief Initialize project settings based on provided JSON configurations.
*
*
* This function initializes project settings based on the configurations provided in a JSON object.
* It sets various properties of the VortexMaker context object accordingly.
*
*
* @param main_configs JSON object containing main project configurations.
*/
VORTEX_API void VortexMaker::InitProject(const nlohmann::json& main_configs)
VORTEX_API void VortexMaker::InitProject(const nlohmann::json &main_configs)
{
// Get reference to the Vortex context
VxContext &ctx = *CVortexMaker;
Expand All @@ -24,7 +24,7 @@ VORTEX_API void VortexMaker::InitProject(const nlohmann::json& main_configs)
ctx.name = main_configs["project"]["name"].get<std::string>();
ctx.type = main_configs["project"]["type"].get<std::string>();
ctx.project_version = main_configs["project"]["version"].get<std::string>();
ctx.version = VORTEX_VERSION;
ctx.compatibleWith = main_configs["project"]["compatibleWith"].get<std::string>();
ctx.include_system_templates = main_configs["project"]["include_system_templates"].get<bool>();

// Set project path to current working directory
Expand All @@ -44,16 +44,16 @@ VORTEX_API void VortexMaker::InitProject(const nlohmann::json& main_configs)
VortexMaker::LoadEditorModules(ctx.projectPath, ctx.IO.em_handles, ctx.IO.em);

// Load modules installed in the system
// Note: These modules are simply initialized in the project, not loaded, but we can add these in CLI/GUI
// Note: These modules are simply initialized in the project, not loaded, but we can add these in CLI/GUI
VortexMaker::LoadSystemModules(ctx.IO.sys_em);

// Load templates installed in the system if the configuration allow it
// Note: These templates are simply initialized in the project, not included, but we can add these in CLI/GUI
if(ctx.include_system_templates)
// Note: These templates are simply initialized in the project, not included, but we can add these in CLI/GUI
if (ctx.include_system_templates)
{
VortexMaker::LoadSystemTemplates(ctx.IO.sys_templates);
}

// Finally, start all loaded modules.
VortexMaker::BootstrappAllModules();
}
}
15 changes: 15 additions & 0 deletions main/src/vortex/utils/utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "../../../include/vortex.h"

VORTEX_API std::string VortexMaker::getCurrentTimeStamp()
{
// Get actual time
std::time_t currentTime = std::time(nullptr);

// Convert to tm
std::tm *localTime = std::localtime(&currentTime);

// Format timestamp
std::ostringstream oss;
oss << std::put_time(localTime, "%Y-%m-%d %H:%M:%S");
return oss.str();
}
5 changes: 3 additions & 2 deletions tools/editor/app/core/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "ModuleManager.hpp"
#include <optional>

static int item_current = 0;
static int item_current = 0;
static bool open_ADDMODULE = false;

// Left
static int mb_selected = 0;
Expand Down Expand Up @@ -428,7 +429,7 @@ void ModuleManager::menubar()
static ImTextureID refreshIcon = this->m_RefreshIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
static ImTextureID addIcon = this->m_AddIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);

static bool open_ADDMODULE = false;


for (auto em : ctx->IO.sys_em)
{
Expand Down
1 change: 0 additions & 1 deletion tools/editor/app/core/ModuleManager.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef MODULEMANAGER_H
#define MODULEMANAGER_H

Expand Down
99 changes: 59 additions & 40 deletions tools/editor/app/core/ProjectSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,61 +146,81 @@ void ProjectSettings::addModuleModal()
{
}

// Main menu function

void ProjectSettings::menubar()
void ProjectSettings::mainButtonsMenuItem()
{
static ImTextureID refreshIcon = this->m_RefreshIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
static ImTextureID addIcon = this->m_AddIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);

if (ImGui::BeginMenuBar())
if (ImGui::ImageButtonWithText(refreshIcon, "Save", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight())))
{
this->Update();
}
if (ImGui::ImageButtonWithText(refreshIcon, "Refresh", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight())))
{
this->Refresh();
}
}

if (ImGui::ImageButtonWithText(refreshIcon, "Save", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight())))
void ProjectSettings::filterMenuItem()
{
ImGui::Separator();
if (ImGui::BeginMenu("Filters"))
{
if (ImGui::MenuItem("Build/Rebuild single parts"))
{
this->Update();
handleFilterBuildRebuild();
}
if (ImGui::ImageButtonWithText(refreshIcon, "Refresh", ImVec2(this->m_RefreshIcon->GetWidth(), this->m_RefreshIcon->GetHeight())))
if (ImGui::MenuItem("Global build"))
{
this->Refresh();
handleGlobalBuild();
}
ImGui::Separator();
if (ImGui::BeginMenu("Filters"))
ImGui::EndMenu();
}
}

void ProjectSettings::createMenuItem()
{
if (ImGui::BeginMenu("Create a module"))
{
if (ImGui::MenuItem("Build/Rebuild single parts"))
{
if (ImGui::MenuItem("Build/Rebuild single parts"))
{
handleFilterBuildRebuild();
}
if (ImGui::MenuItem("Global build"))
{
handleGlobalBuild();
}
ImGui::EndMenu();
handleCreateModule();
}
if (ImGui::BeginMenu("Create a module"))
if (ImGui::MenuItem("Global build"))
{
if (ImGui::MenuItem("Build/Rebuild single parts"))
{
handleCreateModule();
}
if (ImGui::MenuItem("Global build"))
{
handleGlobalBuild();
}
ImGui::EndMenu();
handleGlobalBuild();
}
if (ImGui::BeginMenu("Search"))
ImGui::EndMenu();
}
}

void ProjectSettings::searchMenuItem()
{
if (ImGui::BeginMenu("Search"))
{
if (ImGui::MenuItem("Build/Rebuild single parts"))
{
handleSearch();
}
if (ImGui::MenuItem("Global build"))
{
if (ImGui::MenuItem("Build/Rebuild single parts"))
{
handleSearch();
}
if (ImGui::MenuItem("Global build"))
{
handleGlobalBuild();
}
ImGui::EndMenu();
handleGlobalBuild();
}
ImGui::EndMenu();
}
}

void ProjectSettings::menubar()
{
static ImTextureID refreshIcon = this->m_RefreshIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
static ImTextureID addIcon = this->m_AddIcon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);

if (ImGui::BeginMenuBar())
{
this->mainButtonsMenuItem();
this->filterMenuItem();
this->createMenuItem();
this->searchMenuItem();
ImGui::EndMenuBar();
}
}
Expand Down Expand Up @@ -269,6 +289,5 @@ void ProjectSettings::Update()

this->Refresh();


VortexMaker::UpdateEnvironmentProject(oldname);
}
7 changes: 7 additions & 0 deletions tools/editor/app/core/ProjectSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class ProjectSettings
void Refresh();
void Update();

/**
* @brief Menu items
*/
void mainButtonsMenuItem();
void filterMenuItem();
void createMenuItem();
void searchMenuItem();

VxContext *ctx;
InstanceFactory* factory;
Expand Down
1 change: 1 addition & 0 deletions tools/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_library(launcher
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/platform/GUI/editor/Image.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/src/core/Log.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/assets/icons.cpp
${CMAKE_CURRENT_SOURCE_DIR}/app/core/ProjectManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/app/src/launcher.cpp
)

Expand Down
Loading

0 comments on commit 242f3cd

Please sign in to comment.