From e0fb27037b39b549fcc5086187525c891a45b5ec Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Fri, 3 Apr 2020 21:43:19 +0100 Subject: [PATCH] Carrier launcher: Usability improvements - Support for under in AI scenario - Carrier icon consistent with UI - Location "ship" icon toggles between ships and airports. --- src/AIModel/AICarrier.cxx | 19 +++++----- src/GUI/CarriersLocationModel.cxx | 7 +++- src/GUI/CarriersLocationModel.hxx | 4 ++- src/GUI/assets/aircraft-carrier-icon.svg | 44 +++++++++++------------ src/GUI/assets/icons8-airport-50.png | Bin 0 -> 1681 bytes src/GUI/qml/Location.qml | 12 ++++++- src/GUI/resources.qrc | 1 + 7 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 src/GUI/assets/icons8-airport-50.png 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)"> bsZRm{i%0a>M1?y^lbNW(R48kn#DtzbLI40I`y8PKB^^+ec0>wM zk$KwZ%c;!fiTUT6JWet}$XweVO6F0Yu~&I(E-0u86C$YxA{B0JCxtMJGN9!8A!?{? zb0LyeBUHGx9nMu9ivw|{0Yp@-Oeu*%rrQ<@Hy)yGW;=d%P-UXyDoKE-@E0~^azQ~2 zE!&wcfjAq+*r9>Y!u8pK5E1n}E!&xngD3nGt~uR4EQruRXyN*7oJ~L8B#7vkGofZf zqT4S;*R(-e_6eV{OZzMy-@lqnw-prj=YLjp2c9d6KoZ@g9u@qMoUbZ(u|k*5z1hOnG9 zAdIF9QvOm!B%a)k1937K!d(r*=-OEfts>J@E(u7W+|H@YmO{iTJINuO&p>>qezNUU$(mngfYRhX+DgS5QJ$e4InaVI?ExPPXWGLeEvaIa8;%ld( zj0O;%+$PghpbV|5w>#zXj1k8r>GTPJv4W|Dbv2(OY6Tc?`5WhL4{g_qC%2^#5w${6 z*dK#%k6kz zPYJ$nSyu;yQX_#P&y(B1k*KXo2l&Cdl)+ZkHPtKnsQ|#bwg?1W zcvb91ma{K8AWC*r3K3DuB@pj|@Q{%AWo&49UQNsc@dC2kT>!vyw0U5%1@+jSEN6Ep z7b~)yJs|XyS5&Jjc-HNQB@oL&cvvuPV_h5K)x-->Fhc;`bzzGo%b5$pbYH#bTAzd> z!iIJO7{MWqRbMHEu${Mk5RC105U%Zms9nCkWV>H_W6nklO9bzYWIH<&PAxXH-eB6> z03tH#kfgBR1n`Kk+F!Au4fY~oLg87$aKfq2w~*y*1OSd`Q^9y$=(Z2p&bEYWgbnp3 zF!lfd(qdQ1A)Ge=epE2+U_%|`6?Oy)o)e<<1M7L60jw12VldfGiMN0g0D4F0YXDj9 z=1?9VDC&0QsQR}g60ZULxG>S3Y-qQ7fCd0VX#OMXS})&02^P zbyZ8sD+<}ps{oz|EMD8418`IT{D}>%XRs3XiOA1c*TzafOE1Wp&_Kv?UIF1rpUBg- z0p8?h1F(eFKeMj(koV=T_Fu4Q73*q&1hklS?XFNj$Z}o=;b~#DzhOh`@2%oYfS(t9 zzp$ZoZ$xz00T>~eK4M)P=Yj48aSx%-d6StAV6M>oSJt)b zn~E!fXLzKO5S$2}Oh~XAuaKf(|XR-Dv>N7Y6)|4eh$7*PXiw;M*kb zi!RJXLC7jy2%^ctME9_v-R!O86aa-n>)%;dyER*8SZ*1J>tCvTJ6`jyx|UPug8=QV zgK#JNAQ<}-f$+|+L15Y?^trDw5Ep-ZAWZT7omMl_i^L>=7Yd#~;^l7>VFrR}ckLZT z>mAx_JlW29zkwoPHicC?z=n1WTKH>RvDb&G^Zd!WdNoquYt;J@>srG{3dUcl0?}-V bl8WCyxB_5Z&wDzJ00000NkvXXu0mjfnML&# literal 0 HcmV?d00001 diff --git a/src/GUI/qml/Location.qml b/src/GUI/qml/Location.qml index 9fb4ed5f9..7a03ff937 100644 --- a/src/GUI/qml/Location.qml +++ b/src/GUI/qml/Location.qml @@ -109,6 +109,10 @@ Item { return "%1 - %2 (%3 MHz)".arg(model.ident).arg(model.name).arg(freq); } + if (model.type === "Carrier") { + return "%1 - %2\n%3".arg(model.ident).arg(model.name).arg(model.description); + } + // general case return "%1 - %2".arg(model.ident).arg(model.name); } @@ -225,7 +229,13 @@ Item { icon: "qrc:///svg/icon-carrier" onClicked: { - root.showCarriers = true; + root.showCarriers = ! root.showCarriers; + + if (root.showCarriers) { + this.icon = "qrc:///svg/icon-airport" + } else { + this.icon = "qrc:///svg/icon-carrier" + } } } diff --git a/src/GUI/resources.qrc b/src/GUI/resources.qrc index cdbd2babf..97b9edbca 100644 --- a/src/GUI/resources.qrc +++ b/src/GUI/resources.qrc @@ -155,6 +155,7 @@ 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