[skip ci] fix file assoc always using internal name, fix menu showing wrong time
fixes #126
This commit is contained in:
@@ -89,6 +89,18 @@ struct FileAssocEntry {
|
|||||||
std::string name{}; // ini name
|
std::string name{}; // ini name
|
||||||
std::vector<std::string> ext{}; // list of ext
|
std::vector<std::string> ext{}; // list of ext
|
||||||
std::vector<std::string> database{}; // list of systems
|
std::vector<std::string> database{}; // list of systems
|
||||||
|
|
||||||
|
auto IsExtension(std::string_view extension, std::string_view internal_extension) const -> bool {
|
||||||
|
for (const auto& assoc_ext : ext) {
|
||||||
|
if (extension.length() == assoc_ext.length() && !strncasecmp(assoc_ext.data(), extension.data(), assoc_ext.length())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (internal_extension.length() == assoc_ext.length() && !strncasecmp(assoc_ext.data(), internal_extension.data(), assoc_ext.length())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LastFile {
|
struct LastFile {
|
||||||
|
|||||||
@@ -942,15 +942,13 @@ auto Menu::FindFileAssocFor() -> std::vector<FileAssocEntry> {
|
|||||||
// only support roms in correctly named folders, sorry!
|
// only support roms in correctly named folders, sorry!
|
||||||
const auto db_indexs = GetRomDatabaseFromPath(m_path);
|
const auto db_indexs = GetRomDatabaseFromPath(m_path);
|
||||||
const auto& entry = GetEntry();
|
const auto& entry = GetEntry();
|
||||||
const auto extension = entry.internal_extension.empty() ? entry.extension : entry.internal_extension;
|
const auto extension = entry.extension;
|
||||||
if (extension.empty()) {
|
const auto internal_extension = entry.internal_extension.empty() ? entry.extension : entry.internal_extension;
|
||||||
|
if (extension.empty() && internal_extension.empty()) {
|
||||||
// log_write("failed to get extension for db: %s path: %s\n", database_entry.c_str(), m_path);
|
// log_write("failed to get extension for db: %s path: %s\n", database_entry.c_str(), m_path);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// log_write("got extension for db: %s path: %s\n", database_entry.c_str(), m_path);
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<FileAssocEntry> out_entries;
|
std::vector<FileAssocEntry> out_entries;
|
||||||
if (!db_indexs.empty()) {
|
if (!db_indexs.empty()) {
|
||||||
// if database isn't empty, then we are in a valid folder
|
// if database isn't empty, then we are in a valid folder
|
||||||
@@ -960,15 +958,14 @@ auto Menu::FindFileAssocFor() -> std::vector<FileAssocEntry> {
|
|||||||
// if (assoc_db == PATHS[db_idx].folder || assoc_db == PATHS[db_idx].database) {
|
// if (assoc_db == PATHS[db_idx].folder || assoc_db == PATHS[db_idx].database) {
|
||||||
for (auto db_idx : db_indexs) {
|
for (auto db_idx : db_indexs) {
|
||||||
if (PATHS[db_idx].IsDatabase(assoc_db)) {
|
if (PATHS[db_idx].IsDatabase(assoc_db)) {
|
||||||
for (const auto& assoc_ext : assoc.ext) {
|
if (assoc.IsExtension(extension, internal_extension)) {
|
||||||
if (assoc_ext == extension) {
|
out_entries.emplace_back(assoc);
|
||||||
log_write("found ext: %s assoc_ext: %s assoc.ext: %s\n", assoc.path.s, assoc_ext.c_str(), extension.c_str());
|
goto jump;
|
||||||
out_entries.emplace_back(assoc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
jump:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// otherwise, if not in a valid folder, find an entry that doesn't
|
// otherwise, if not in a valid folder, find an entry that doesn't
|
||||||
@@ -979,11 +976,9 @@ auto Menu::FindFileAssocFor() -> std::vector<FileAssocEntry> {
|
|||||||
// to be in the correct folder, ie psx, to know what system that .iso is for.
|
// to be in the correct folder, ie psx, to know what system that .iso is for.
|
||||||
for (const auto& assoc : m_assoc_entries) {
|
for (const auto& assoc : m_assoc_entries) {
|
||||||
if (assoc.database.empty()) {
|
if (assoc.database.empty()) {
|
||||||
for (const auto& assoc_ext : assoc.ext) {
|
if (assoc.IsExtension(extension, internal_extension)) {
|
||||||
if (assoc_ext == extension) {
|
log_write("found ext: %s\n", assoc.path.s);
|
||||||
log_write("found ext: %s\n", assoc.path.s);
|
out_entries.emplace_back(assoc);
|
||||||
out_entries.emplace_back(assoc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,18 @@ MenuBase::~MenuBase() {
|
|||||||
|
|
||||||
void MenuBase::Update(Controller* controller, TouchInfo* touch) {
|
void MenuBase::Update(Controller* controller, TouchInfo* touch) {
|
||||||
Widget::Update(controller, touch);
|
Widget::Update(controller, touch);
|
||||||
|
|
||||||
// update every second.
|
|
||||||
if (m_poll_timestamp.GetSeconds() >= 1) {
|
|
||||||
UpdateVars();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBase::Draw(NVGcontext* vg, Theme* theme) {
|
void MenuBase::Draw(NVGcontext* vg, Theme* theme) {
|
||||||
DrawElement(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ThemeEntryID_BACKGROUND);
|
DrawElement(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ThemeEntryID_BACKGROUND);
|
||||||
Widget::Draw(vg, theme);
|
Widget::Draw(vg, theme);
|
||||||
|
|
||||||
|
// update every second, do this in Draw because Update() isn't called if it
|
||||||
|
// doesn't have focus.
|
||||||
|
if (m_poll_timestamp.GetSeconds() >= 1) {
|
||||||
|
UpdateVars();
|
||||||
|
}
|
||||||
|
|
||||||
const float start_y = 70;
|
const float start_y = 70;
|
||||||
const float font_size = 22;
|
const float font_size = 22;
|
||||||
const float spacing = 30;
|
const float spacing = 30;
|
||||||
|
|||||||
Reference in New Issue
Block a user