Make the Latest and installed version labels dynamic

This commit is contained in:
SoftFever
2026-07-17 16:25:10 +08:00
parent 9d9bb9cdbd
commit 6767ab5ae0
5 changed files with 55 additions and 8 deletions

View File

@@ -219,9 +219,14 @@ void NetworkPluginDownloadDialog::setup_version_selector()
label = wxString::FromUTF8("\xE2\x94\x94 ") + wxString::FromUTF8(ver.display_name);
} else {
label = wxString::FromUTF8(ver.display_name);
if (ver.is_latest) {
label += wxString(" ") + _L("(Latest)");
}
}
// Same labeling as the Preferences selector: "(Latest)" = highest listed
// version, "(installed)" = library already on disk; both can apply.
if (ver.is_latest) {
label += wxString(" ") + _L("(Latest)");
}
if (ver.is_installed) {
label += wxString(" ") + _L("(installed)");
}
m_version_combo->Append(label);
}

View File

@@ -1270,10 +1270,12 @@ wxBoxSizer *PreferencesDialog::create_item_network_plugin_version(wxString title
label = wxString::FromUTF8(ver.display_name);
}
// "(Latest)" marks the highest listed version; "(installed)" marks versions
// whose library is already on disk. One entry can carry both.
if (ver.is_latest) {
label += " " + _L("(Latest)");
} else if (ver.is_discovered && ver.suffix.empty()) {
// A same-series build found on disk (usually installed by the OTA update).
}
if (ver.is_installed) {
label += " " + _L("(installed)");
}
m_network_version_combo->Append(label);

View File

@@ -885,6 +885,24 @@ std::vector<NetworkLibraryVersionInfo> get_all_available_versions()
NetworkLibraryVersionInfo::from_discovered(full, full, ""));
}
// Final pass: record what is actually present on disk, and put the "(Latest)"
// label on the truly highest full version in the list - an OTA-installed build
// can be newer than the newest whitelisted entry. get_latest_network_version()
// intentionally keeps returning the static whitelist default, which drives the
// download and update-check decisions.
size_t highest = result.size();
for (size_t i = 0; i < result.size(); ++i) {
auto& info = result[i];
info.is_installed = info.is_discovered ||
BBLNetworkPlugin::versioned_library_exists(info.version);
info.is_latest = false;
if (info.suffix.empty() &&
(highest == result.size() || info.version > result[highest].version))
highest = i;
}
if (highest < result.size())
result[highest].is_latest = true;
return result;
}

View File

@@ -386,6 +386,8 @@ struct NetworkLibraryVersionInfo {
bool is_latest;
std::string warning;
bool is_discovered;
// Whether the versioned library file for this entry is present on disk.
bool is_installed = false;
static NetworkLibraryVersionInfo from_static(const NetworkLibraryVersion& v) {
return {