mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Support loading backgrounds from the sd
This commit is contained in:
parent
001442fd8a
commit
8c77633767
@ -2,6 +2,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <nds.h>
|
#include <nds.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -11,19 +12,28 @@ static const auto& getBackgroundList()
|
|||||||
{
|
{
|
||||||
static auto bgs = []{
|
static auto bgs = []{
|
||||||
std::vector<std::pair<std::string,std::string>> bgs;
|
std::vector<std::pair<std::string,std::string>> bgs;
|
||||||
static const std::string bgstr{"nitro:/backgrounds/"};
|
|
||||||
auto* pdir = opendir("nitro:/backgrounds");
|
for(const auto* bgstr : {"nitro:/backgrounds/", "sd:/backgrounds/"}) {
|
||||||
if(!pdir) return bgs;
|
auto* pdir = opendir(bgstr);
|
||||||
dirent* pent;
|
if(!pdir) continue;
|
||||||
while((pent = readdir(pdir))) {
|
dirent* pent;
|
||||||
if(pent->d_type == DT_DIR)
|
while((pent = readdir(pdir))) {
|
||||||
continue;
|
if(pent->d_type == DT_DIR)
|
||||||
std::string name{pent->d_name};
|
continue;
|
||||||
if(!name.ends_with(".gif") && !name.ends_with(".GIF"))
|
std::string name{pent->d_name};
|
||||||
continue;
|
if(!name.ends_with(".gif") && !name.ends_with(".GIF"))
|
||||||
bgs.emplace_back(name.substr(0, name.size() - 4), bgstr + name);
|
continue;
|
||||||
|
bgs.emplace_back(name.substr(0, name.size() - 4), bgstr + name);
|
||||||
|
}
|
||||||
|
closedir(pdir);
|
||||||
}
|
}
|
||||||
closedir(pdir);
|
std::sort(bgs.begin(), bgs.end(), [](const auto& lhs, const auto& rhs){
|
||||||
|
const auto& [lhs_name, lhs_fullpath] = lhs;
|
||||||
|
const auto& [rhs_name, rhs_fullpath] = rhs;
|
||||||
|
if(lhs_fullpath[0] != rhs_fullpath[0])
|
||||||
|
return lhs_fullpath[0] < rhs_fullpath[0];
|
||||||
|
return lhs_name < rhs_name;
|
||||||
|
});
|
||||||
return bgs;
|
return bgs;
|
||||||
}();
|
}();
|
||||||
return bgs;
|
return bgs;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user