Skip to content

Commit

Permalink
Launcher : Some logo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed May 7, 2024
1 parent e9e6617 commit 4c6b846
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
Binary file modified build/bin/vortex
Binary file not shown.
3 changes: 3 additions & 0 deletions main/src/templates/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace VortexMaker
fs::create_directories(path);
}

// Clear actual templates array
sys_templates.clear();

// Search for module files recursively in the directory
auto module_files = VortexMaker::SearchSystemFiles(path, "template.json");

Expand Down
46 changes: 32 additions & 14 deletions tools/launcher/app/core/ProjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,48 @@ static std::vector<std::string> syslabels;

static void logo(const std::string &path, int index, int total)
{
uint32_t w, h;
sleep(0.1);
uint32_t w = 0, h = 0;
// Vérifier si le chemin du fichier est valide
if (path.empty())
{
std::cerr << "Chemin de fichier invalide." << std::endl;
return;
}

// Chargez le contenu hexadécimal du fichier .png
std::vector<uint8_t> hexTable = loadPngHex(path);
const uint8_t *hexData = hexTable.data();

if (total > logos.size())
if (total > logos.size() && !hexTable.empty())
{
void *data = UIKit::Image::Decode(hexData, hexTable.size(), w, h);
std::shared_ptr<UIKit::Image> _icon = std::make_shared<UIKit::Image>(w, h, UIKit::ImageFormat::RGBA, data);
logos.push_back(_icon);
VX_FREE(data);
ImTextureID addIcon = logos[index]->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
textures.push_back(addIcon);
if (data)
{
std::shared_ptr<UIKit::Image> _icon = std::make_shared<UIKit::Image>(w, h, UIKit::ImageFormat::RGBA, data);
logos.push_back(_icon);
VX_FREE(data);
ImTextureID addIcon = _icon->GetImGuiTextureID(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
textures.push_back(addIcon);
}
else
{
// Gérer l'échec de décodage de l'image
std::cerr << "Échec du décodage de l'image." << std::endl;
// Vous pouvez logger une erreur ou effectuer une autre action appropriée
}
}

if (index <= textures.size())
if (index >= 0 && index < textures.size())
{
ImGui::Image(textures[index], ImVec2(50, 50));
}
else
{
// Gérer l'index hors limites
std::cerr << "Index hors limites." << std::endl;
// Vous pouvez logger une erreur ou effectuer une autre action appropriée
}
}

ProjectManager::ProjectManager(VxContext *_ctx)
Expand Down Expand Up @@ -214,16 +237,11 @@ void ProjectManager::OnImGuiRender()
ImGui::BeginChild("LOGO_", ImVec2(70, 70), true);
try
{

if (!project_templates[i]->m_logo_path.empty())
{
logo(project_templates[i]->m_logo_path, i, project_templates.size());
}

}
catch (std::exception e)
{
std::cout << e.what() << std::endl;
sleep(5);
}
ImGui::EndChild();
ImGui::SameLine();
Expand Down

0 comments on commit 4c6b846

Please sign in to comment.