Pkg: initial support for Variants
- aircraft init code can deal with a variant ID - Nasal API can return a hash with variant IDs and names
This commit is contained in:
parent
26a4948642
commit
7e8d713b28
2 changed files with 21 additions and 3 deletions
|
@ -523,7 +523,8 @@ int fgInitAircraft(bool reinit)
|
|||
flightgear::Options::sharedInstance()->initAircraft();
|
||||
}
|
||||
|
||||
PackageRef acftPackage = pkgRoot->getPackageById(aircraftProp->getStringValue());
|
||||
string aircraftId(aircraftProp->getStringValue());
|
||||
PackageRef acftPackage = pkgRoot->getPackageById(aircraftId);
|
||||
if (acftPackage) {
|
||||
if (acftPackage->isInstalled()) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Loading aircraft from package:" << acftPackage->qualifiedId());
|
||||
|
@ -538,15 +539,20 @@ int fgInitAircraft(bool reinit)
|
|||
|
||||
// overwrite the fully qualified ID with the aircraft one, so the
|
||||
// code in FindAndCacheAircraft works as normal
|
||||
// note since we may be using a variant, we can't use the package ID
|
||||
size_t lastDot = aircraftId.rfind('.');
|
||||
if (lastDot != std::string::npos) {
|
||||
aircraftId = aircraftId.substr(lastDot + 1);
|
||||
aircraftProp->setStringValue(aircraftId);
|
||||
|
||||
aircraftProp->setStringValue(acftPackage->id());
|
||||
}
|
||||
// run the traditional-code path below
|
||||
} else {
|
||||
#if 0
|
||||
// naturally the better option would be to on-demand install it!
|
||||
flightgear::fatalMessageBox("Aircraft not installed",
|
||||
"Requested aircraft is not currently installed.",
|
||||
aircraftProp->getStringValue());
|
||||
aircraftId);
|
||||
|
||||
return flightgear::FG_OPTIONS_ERROR;
|
||||
#endif
|
||||
|
|
|
@ -207,6 +207,17 @@ static naRef f_catalog_search(pkg::Catalog& cat, const nasal::CallContext& ctx)
|
|||
return ctx.to_nasal(result);
|
||||
}
|
||||
|
||||
static naRef f_package_variants(pkg::Package& pack, naContext c)
|
||||
{
|
||||
nasal::Hash h(c);
|
||||
string_list vars(pack.variants());
|
||||
for (string_list_iterator it = vars.begin(); it != vars.end(); ++it) {
|
||||
h.set(*it, pack.nameForVariant(*it));
|
||||
}
|
||||
|
||||
return h.get_naRef();
|
||||
}
|
||||
|
||||
void FGHTTPClient::postinit()
|
||||
{
|
||||
#ifdef ENABLE_PACKAGE_SYSTEM
|
||||
|
@ -237,6 +248,7 @@ void FGHTTPClient::postinit()
|
|||
.member("description", &pkg::Package::description)
|
||||
.member("installed", &pkg::Package::isInstalled)
|
||||
.member("thumbnails", &pkg::Package::thumbnailUrls)
|
||||
.member("variants", &f_package_variants)
|
||||
.member("revision", &pkg::Package::revision)
|
||||
.member("catalog", &pkg::Package::catalog)
|
||||
.method("install", &pkg::Package::install)
|
||||
|
|
Loading…
Add table
Reference in a new issue