diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx index 617b532f0..c519d90bf 100644 --- a/src/AIModel/AICarrier.cxx +++ b/src/AIModel/AICarrier.cxx @@ -621,7 +621,7 @@ std::pair FGAICarrier::initialPositionForCarrier(const std::string // this is actually a three-layer search (we want the scenario with the // carrier with the correct penanant or name. Sometimes an XPath for // properties would be quite handy :) - + for (auto s : fgGetNode("/sim/ai/scenarios")->getChildren("scenario")) { auto carriers = s->getChildren("carrier"); auto it = std::find_if(carriers.begin(), carriers.end(), @@ -636,16 +636,16 @@ std::pair FGAICarrier::initialPositionForCarrier(const std::string if (it == carriers.end()) { continue; } - + // mark the scenario for loading (which will happen in post-init of the AIManager) fgGetNode("/sim/ai/")->addChild("scenario")->setStringValue(s->getStringValue("id")); - + // read out the initial-position SGGeod geod = SGGeod::fromDeg((*it)->getDoubleValue("longitude"), (*it)->getDoubleValue("latitude")); return std::make_pair(true, geod); } // of scenarios iteration - + return std::make_pair(false, SGGeod()); } @@ -655,7 +655,7 @@ SGSharedPtr FGAICarrier::findCarrierByNameOrPennant(const std::stri if (!aiManager) { return {}; } - + for (const auto& aiObject : aiManager->get_ai_list()) { if (aiObject->isa(FGAIBase::otCarrier)) { SGSharedPtr c = static_cast(aiObject.get()); @@ -664,7 +664,7 @@ SGSharedPtr FGAICarrier::findCarrierByNameOrPennant(const std::stri } } } // of all objects iteration - + return {}; } @@ -673,19 +673,22 @@ void FGAICarrier::extractCarriersFromScenario(SGPropertyNode_ptr xmlNode, SGProp for (auto c : xmlNode->getChildren("entry")) { if (c->getStringValue("type") != std::string("carrier")) continue; - + const std::string name = c->getStringValue("name"); const std::string pennant = c->getStringValue("pennant-number"); if (name.empty() && pennant.empty()) { continue; } - + SGPropertyNode_ptr carrierNode = scenario->addChild("carrier"); // extract the initial position from the scenario carrierNode->setDoubleValue("longitude", c->getDoubleValue("longitude")); carrierNode->setDoubleValue("latitude", c->getDoubleValue("latitude")); + // A description of the carrier is also available from the entry. Primarily for use by the launcher + carrierNode->setStringValue("description", c->getStringValue("description")); + // the find code above just looks for anything called a name (so alias // are possible, for example) if (!name.empty()) carrierNode->addChild("name")->setStringValue(name); diff --git a/src/GUI/CarriersLocationModel.cxx b/src/GUI/CarriersLocationModel.cxx index 9cebe1246..d60368de5 100644 --- a/src/GUI/CarriersLocationModel.cxx +++ b/src/GUI/CarriersLocationModel.cxx @@ -12,7 +12,7 @@ CarriersLocationModel::CarriersLocationModel(QObject *parent) SGPropertyNode_ptr localRoot(new SGPropertyNode); FGAIManager::registerScenarios(localRoot); -// this code encodes some scenario structre, sorry +// this code encodes some scenario structure, sorry for (auto s : localRoot->getNode("sim/ai/scenarios")->getChildren("scenario")) { const std::string scenarioId = s->getStringValue("id"); for (auto c : s->getChildren("carrier")) { @@ -26,6 +26,7 @@ void CarriersLocationModel::processCarrier(const string &scenario, SGPropertyNod const auto name = QString::fromStdString(carrierNode->getStringValue("name")); const auto pennant = QString::fromStdString(carrierNode->getStringValue("pennant-number")); const auto tacan = QString::fromStdString(carrierNode->getStringValue("TACAN-channel-ID")); + const auto desc = QString::fromStdString(carrierNode->getStringValue("description")); SGGeod geod = SGGeod::fromDeg(carrierNode->getDoubleValue("longitude"), carrierNode->getDoubleValue("latitude")); @@ -38,6 +39,7 @@ void CarriersLocationModel::processCarrier(const string &scenario, SGPropertyNod QString::fromStdString(scenario), pennant, name, + desc, geod, tacan, parkings @@ -65,6 +67,8 @@ QVariant CarriersLocationModel::data(const QModelIndex &index, int role) const case NameRole: return c.mName; // case GeodRole: return QVariant::fromValue(c.mInitialLocation); case IdentRole: return c.mCallsign; + case DescriptionRole: return c.mDescription; + case TypeRole: return "Carrier"; case IconRole: return QPixmap(":/svg/aircraft-carrier"); default: break; @@ -83,6 +87,7 @@ QHash CarriersLocationModel::roleNames() const result[NameRole] = "name"; result[IconRole] = "icon"; result[TypeRole] = "type"; + result[DescriptionRole] = "description"; result[NavFrequencyRole] = "frequency"; return result; } diff --git a/src/GUI/CarriersLocationModel.hxx b/src/GUI/CarriersLocationModel.hxx index 2bc4fa9d8..11a936b04 100644 --- a/src/GUI/CarriersLocationModel.hxx +++ b/src/GUI/CarriersLocationModel.hxx @@ -30,7 +30,8 @@ public: NameRole = Qt::UserRole + 4, IconRole = Qt::UserRole + 5, TypeRole = Qt::UserRole + 6, - NavFrequencyRole = Qt::UserRole + 7 + NavFrequencyRole = Qt::UserRole + 7, + DescriptionRole = Qt::UserRole + 8 }; int indexOf(const QString name) const; @@ -46,6 +47,7 @@ private: QString mScenario; // scenario ID for loading QString mCallsign; // pennant-number QString mName; + QString mDescription; SGGeod mInitialLocation; // icon? QString mTACAN; diff --git a/src/GUI/assets/aircraft-carrier-icon.svg b/src/GUI/assets/aircraft-carrier-icon.svg index 9487e86e7..e594f579c 100644 --- a/src/GUI/assets/aircraft-carrier-icon.svg +++ b/src/GUI/assets/aircraft-carrier-icon.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="172.41008" - height="72.426231" - viewBox="0 0 456.16835 191.62773" + width="87.149193" + height="37.111004" + viewBox="0 0 461.16447 196.37906" version="1.1" id="svg8" inkscape:export-filename="/home/stuart/bitmap.png" @@ -29,8 +29,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="4" - inkscape:cx="118.80392" - inkscape:cy="-5.4573402" + inkscape:cx="82.435073" + inkscape:cy="-17.019439" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="false" @@ -39,10 +39,10 @@ inkscape:window-x="67" inkscape:window-y="27" inkscape:window-maximized="1" - fit-margin-top="10" - fit-margin-left="10" - fit-margin-right="10" - fit-margin-bottom="10" + fit-margin-top="5" + fit-margin-left="5" + fit-margin-right="5" + fit-margin-bottom="5" units="px" scale-x="10" /> + transform="translate(319.16852,-98.581295)"> assets/icons8-menu.svg assets/icons8-hide-50.png assets/icons8-cargo-ship-50.png + assets/icons8-airport-50.png assets/aircraft-carrier-icon.svg