Skip to content

Commit

Permalink
Not working yet : Add some managment features
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed Jun 14, 2024
1 parent 978c872 commit fddad27
Show file tree
Hide file tree
Showing 17 changed files with 1,091 additions and 85 deletions.
85 changes: 56 additions & 29 deletions build/in_system/imgui.ini
Original file line number Diff line number Diff line change
@@ -1,50 +1,77 @@
[Window][DockSpaceWindow]
[Window][Debug##Default]
ViewportPos=1244,1465
ViewportId=0x9F5F46A1
Size=400,400
Collapsed=0

[Window][DockSpaceWindow.base]
Pos=0,0
Size=1550,850
Size=1920,1044
Collapsed=0

[Window][Project managers]
Pos=1,58
Size=1548,791
Pos=6,58
Size=1536,980
Collapsed=0
DockId=0xCDC34B94,0
DockId=0x00000001,1

[Window][Debug##Default]
Pos=60,60
Size=400,400
[Window][Detail]
Pos=1544,58
Size=370,980
Collapsed=0
DockId=0x00000002,0

[Window][Example Window]
Pos=373,58
Size=826,641
[Window][Dear ImGui Demo]
Pos=6,58
Size=1536,980
Collapsed=0
DockId=0xCDC34B94,0
DockId=0x00000001,0

[Window][Example Window2]
Pos=1,58
Size=370,641
[Window][DockSpaceWindow.base221155]
ViewportPos=1184,1043
ViewportId=0xDD958508
Size=32,63
Collapsed=0
DockId=0xCDC34B94,1

[Window][System Settings]
Pos=1,58
Size=1548,791
Pos=6,58
Size=1536,980
Collapsed=0
DockId=0x00000001,2

[Window][Search modules in folder]
ViewportPos=1808,945
ViewportId=0xC3792C5F
Size=713,546
Collapsed=0
DockId=0xCDC34B94,1

[Window][Import a module]
Pos=554,317
Size=423,184
[Window][Search templates in folder]
Pos=601,178
Size=588,532
Collapsed=0

[Table][0xED032332,4]
RefScale=16.6
Column 0 Width=123
Column 1 Width=88
Column 2 Width=215
Column 3 Width=106

[Table][0x3EC6FA37,2]
RefScale=16.6
Column 0 Width=151
Column 1 Width=233

[Table][0x05431DF0,5]
RefScale=18
Column 0 Width=74
Column 1 Width=279
Column 2 Width=96
Column 3 Width=33
Column 4 Width=152
RefScale=16.6
Column 0 Width=91
Column 1 Width=88
Column 2 Width=215
Column 3 Width=51
Column 4 Width=428

[Docking][Data]
DockSpace ID=0xCDC34B94 Window=0x41896AB8 Pos=1210,695 Size=1548,791 CentralNode=1 Selected=0xFC41C5EB
DockSpace ID=0x6526BAE1 Window=0x2A894DFC Pos=1030,598 Size=1908,980 Split=X Selected=0x26217AFD
DockNode ID=0x00000001 Parent=0x6526BAE1 SizeRef=884,980 CentralNode=1 Selected=0xFC41C5EB
DockNode ID=0x00000002 Parent=0x6526BAE1 SizeRef=370,980 Selected=0xBC4FCFE6

2 changes: 2 additions & 0 deletions main/include/modules/install.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace VortexMaker {
VORTEX_API void InstallModule(const std::string &directory);
VORTEX_API std::shared_ptr<ModuleInterface> FindModuleInDirectory(const std::string &directory);
VORTEX_API std::vector<std::shared_ptr<ModuleInterface>> FindModulesInDirectory(const std::string &directory);
}

#endif
2 changes: 2 additions & 0 deletions main/include/templates/install.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace VortexMaker {
VORTEX_API void InstallTemplateOnSystem(const std::string &directory); // From anywhere to system
VORTEX_API void InstallTemplate(const std::string &name, const std::string& path); // From system to project
VORTEX_API std::vector<std::shared_ptr<TemplateInterface>> FindTemplatesInDirectory(const std::string &directory);
}


#endif // TEMPLATE_INSTALL_H
2 changes: 2 additions & 0 deletions main/include/vortex.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ namespace VortexMaker
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> SearchFiles(const std::string &path, const std::string &filename, int recursions);
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);
VORTEX_API std::string SearchFilesRecursive(const fs::path &chemin, const std::string &filename, std::vector<std::string> &file, int recursions, int counter);
bool DebugCheckVersionAndDataLayout(const char *version);

VORTEX_API void MoveAllContent();
Expand Down
93 changes: 92 additions & 1 deletion main/src/modules/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,95 @@ VORTEX_API void VortexMaker::InstallModule(const std::string &module_name, const
// Create the folder name
// Copy distant module content into the module into the projet
// Restart modules
}
}

VORTEX_API std::shared_ptr<ModuleInterface> VortexMaker::FindModuleInDirectory(const std::string &directory)
{
// Search modules registered
auto module_files = VortexMaker::SearchFiles(directory, "module.json");


// Iterate through each found module file
for (const auto &file : module_files)
{
try
{
// Load JSON data from the module configuration file
auto json_data = VortexMaker::DumpJSON(file);

std::string module_path = file.substr(0, file.find_last_of("/"));

std::shared_ptr<ModuleInterface> interface = std::make_shared<ModuleInterface>();

interface->m_name = json_data["name"].get<std::string>();
interface->m_version = json_data["version"].get<std::string>();

return interface;

}
catch (std::exception e)
{
VortexMaker::LogError("Core", e.what());
}
}

VortexMaker::LogError("Core", "Failed to find the module at " + directory + ", no modules detected.");
return nullptr;
}

VORTEX_API std::vector<std::shared_ptr<ModuleInterface>> VortexMaker::FindModulesInDirectory(const std::string &directory)
{
// Search modules registered
auto module_files = VortexMaker::SearchFiles(directory, "module.json", 3);

std::vector<std::shared_ptr<ModuleInterface>> interfaces;

// Iterate through each found module file
for (const auto &file : module_files)
{
try
{
// Load JSON data from the module configuration file
auto json_data = VortexMaker::DumpJSON(file);

std::string module_path = file.substr(0, file.find_last_of("/"));

std::shared_ptr<ModuleInterface> interface = std::make_shared<ModuleInterface>();
interface->m_name = json_data["name"].get<std::string>();
interface->m_auto_exec = json_data["auto_exec"].get<bool>();
interface->m_proper_name = json_data["proper_name"].get<std::string>();
interface->m_type = json_data["type"].get<std::string>();
interface->m_version = json_data["version"].get<std::string>();
interface->m_description = json_data["description"].get<std::string>();
interface->m_picture = json_data["picture"].get<std::string>();
interface->m_logo_path = module_path + "/" + interface->m_picture;
interface->m_path = module_path + "/";
interface->m_author = json_data["author"].get<std::string>();
interface->m_group = json_data["group"].get<std::string>();
interface->m_contributors = json_data["contributors"].get<std::vector<std::string>>();

for (auto dep : json_data["deps"])
{
std::shared_ptr<ModuleInterfaceDep> dependence = std::make_shared<ModuleInterfaceDep>();
dependence->name = dep["name"].get<std::string>();
dependence->type = dep["type"].get<std::string>();
for (auto version : dep["versions"])
{
dependence->supported_versions.push_back(version);
}
interface->m_dependencies.push_back(dependence);
}

interface->m_supported_versions = json_data["compatibility"].get<std::vector<std::string>>();

interfaces.push_back(interface);

}
catch (std::exception e)
{
VortexMaker::LogError("Core", e.what());
}
}

return interfaces;
}
3 changes: 3 additions & 0 deletions main/src/modules/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ namespace VortexMaker
// Search for module files recursively in the directory
auto module_files = VortexMaker::SearchSystemFiles(path, "module.json");

// Clear system modules vector
sys_modules.clear();

// Iterate through each found module file
for (const auto &file : module_files)
{
Expand Down
56 changes: 55 additions & 1 deletion main/src/templates/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,58 @@ VORTEX_API void VortexMaker::InstallTemplate(const std::string &name, const std:
{
VortexMaker::LogError("Core", "Failed to find the template " + name + " this template is installed ?");
}*/
}
}

VORTEX_API std::vector<std::shared_ptr<TemplateInterface>> VortexMaker::FindTemplatesInDirectory(const std::string &directory)
{
// Search modules registered
auto template_files = VortexMaker::SearchFiles(directory, "template.json", 3);

std::vector<std::shared_ptr<TemplateInterface>> interfaces;

// Iterate through each found module file
for (const auto &file : template_files)
{
try
{
// Load JSON data from the module configuration file
auto json_data = VortexMaker::DumpJSON(file);

std::string module_path = file.substr(0, file.find_last_of("/"));

std::shared_ptr<TemplateInterface> new_template = std::make_shared<TemplateInterface>();

new_template->m_name = json_data["name"].get<std::string>();
new_template->m_proper_name = json_data["proper_name"].get<std::string>();
new_template->m_type = json_data["type"].get<std::string>();
new_template->m_description = json_data["description"].get<std::string>();
new_template->m_picture = json_data["picture"].get<std::string>();
new_template->m_logo_path = module_path + "/" + new_template->m_picture;
new_template->m_path = module_path + "/";
new_template->m_author = json_data["author"].get<std::string>();
new_template->m_group = json_data["group"].get<std::string>();
new_template->m_tarball = json_data["tarball"].get<std::string>();
new_template->m_contributors = json_data["contributors"].get<std::vector<std::string>>();

for (auto dep : json_data["deps"])
{
std::shared_ptr<TemplateDep> dependence = std::make_shared<TemplateDep>();
dependence->name = dep["name"].get<std::string>();
dependence->type = dep["type"].get<std::string>();
for (auto version : dep["versions"])
{
dependence->supported_versions.push_back(version);
}
new_template->m_dependencies.push_back(dependence);
}

interfaces.push_back(new_template);
}
catch (std::exception e)
{
VortexMaker::LogError("Core", e.what());
}
}

return interfaces;
}
61 changes: 61 additions & 0 deletions main/src/vortex/filesystem/searcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,45 @@ VORTEX_API std::string VortexMaker::SearchFilesRecursive(const fs::path &path, c
}


/**
* @brief SearchFilesRecursive searches for files recursively in a directory.
*
* This function recursively searches for files in the specified directory and its subdirectories.
* If a file with the specified filename is found, its path is added to the provided vector of filenames.
*
* @param path The path of the directory to search in.
* @param filename The name of the file to search for.
* @param file A vector to store the paths of the found files.
* @return The path of the first found file matching the filename, or "null" if no file is found.
*/
VORTEX_API std::string VortexMaker::SearchFilesRecursive(const fs::path &path, const std::string &filename, std::vector<std::string> &file, int recursions, int counter)
{
if(counter >= recursions)
return "null";

counter++;

// Iterate through each entry in the directory
for (const auto &entry : fs::directory_iterator(path))
{
// If the entry is a regular file and its filename contains the specified filename
if (entry.is_regular_file() && entry.path().filename().string().find(filename) != std::string::npos)
{
// Add the path of the found file to the vector and return its path
file.push_back(entry.path().string());
return entry.path().string();
}
// If the entry is a directory, recursively search in it
else if (entry.is_directory())
{
VortexMaker::SearchFilesRecursive(entry.path(), filename, file, recursions, counter);
}
}
// Return "null" if no file is found
return "null";
}


/**
* @brief SearchFiles searches for files in a directory.
*
Expand All @@ -58,6 +97,28 @@ VORTEX_API std::vector<std::string> VortexMaker::SearchFiles(const std::string &
}


/**
* @brief SearchFiles searches for files in a directory.
*
* This function searches for files in the specified directory and its subdirectories.
* It returns a vector containing the paths of all files found matching the specified filename.
*
* @param path The relative path of the directory to search in.
* @param filename The name of the file to search for.
* @return A vector containing the paths of all files found matching the filename.
*/
VORTEX_API std::vector<std::string> VortexMaker::SearchFiles(const std::string &path, const std::string &filename, int recursions)
{
// Initialize a vector to store the paths of found files
std::vector<std::string> fichiersTest;

// Call the recursive function to search for files
VortexMaker::SearchFilesRecursive(fs::current_path() / path, filename, fichiersTest, recursions, 0);

// Return the vector containing the paths of found files
return fichiersTest;
}

/**
* @brief SearchFiles searches for files in a directory.
*
Expand Down
3 changes: 3 additions & 0 deletions tools/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ add_library(launcher
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/platform/GUI/editor/UI/Spinner.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/platform/GUI/editor/ApplicationGUI.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/platform/GUI/editor/Image.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/components/windows/windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/uikit/components/buttons/buttons.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/core/SystemSettings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/app/core/Details.cpp
${CMAKE_CURRENT_SOURCE_DIR}/app/src/launcher.cpp
)

Expand Down
Loading

0 comments on commit fddad27

Please sign in to comment.