From e55103ccdf891be68108354f35f71d8ba193b8cf Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Tue, 5 Jun 2018 11:53:59 +0200 Subject: [PATCH] Rename all variables and functions to be similar to followPlaneView --- src/xswiftbus/plugin.cpp | 2 +- src/xswiftbus/traffic.cpp | 36 ++++++++++++++++++------------------ src/xswiftbus/traffic.h | 10 +++++----- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/xswiftbus/plugin.cpp b/src/xswiftbus/plugin.cpp index 908ff04fa..02ffdc5f1 100644 --- a/src/xswiftbus/plugin.cpp +++ b/src/xswiftbus/plugin.cpp @@ -33,7 +33,7 @@ namespace XSwiftBus m_toggleMessageWindowMenuItem = m_menu.item("Toggle Message Window", [this] { if(m_service) { m_service->toggleMessageBoxVisibility(); } }); // m_startServerMenuItems.push_back(m_menu.item("Start server on system bus", [this]{ startServer(BlackMisc::CDBusServer::systemBusAddress()); })); // m_startServerMenuItems.push_back(m_menu.item("Start server on localhost P2P", [this]{ startServer(BlackMisc::CDBusServer::p2pAddress("localhost")); })); - m_planeViewSubMenu = m_menu.subMenu("Plane View"); + m_planeViewSubMenu = m_menu.subMenu("Follow Plane View"); planeViewOwnAircraftMenuItem = m_planeViewSubMenu.item("Own Aircraft", [this] { switchToOwnAircraftView(); }); m_dbusThread = std::thread([this]() diff --git a/src/xswiftbus/traffic.cpp b/src/xswiftbus/traffic.cpp index 32796edd7..76ecfa72e 100644 --- a/src/xswiftbus/traffic.cpp +++ b/src/xswiftbus/traffic.cpp @@ -45,7 +45,7 @@ namespace XSwiftBus CTraffic::CTraffic(CDBusConnection *dbusConnection) : CDBusObject(dbusConnection), - m_planeViewNextCommand("org/swift-project/xswiftbus/follow_next_plane", "Changes plane view to follow next plane in sequence", [this] { followNextPlane(); }) + m_followPlaneViewNextCommand("org/swift-project/xswiftbus/follow_next_plane", "Changes plane view to follow next plane in sequence", [this] { followNextPlane(); }) { registerDBusObjectPath(XSWIFTBUS_TRAFFIC_INTERFACENAME, XSWIFTBUS_TRAFFIC_OBJECTPATH); XPLMRegisterDrawCallback(drawCallback, xplm_Phase_Airplanes, 1, this); @@ -61,7 +61,7 @@ namespace XSwiftBus void CTraffic::setPlaneViewMenu(const CMenu &planeViewSubMenu) { - m_planeViewSubMenu = planeViewSubMenu; + m_followPlaneViewSubMenu = planeViewSubMenu; } void CTraffic::initLegacyData() @@ -133,9 +133,9 @@ namespace XSwiftBus sendDBusMessage(signalPlaneAddingFailed); } - void CTraffic::switchToPlaneView(const std::string &callsign) + void CTraffic::enableFollowPlaneView(const std::string &callsign) { - m_planeViewCallsign = callsign; + m_followPlaneViewCallsign = callsign; /* This is the hotkey callback. First we simulate a joystick press and * release to put us in 'free view 1'. This guarantees that no panels @@ -149,15 +149,15 @@ namespace XSwiftBus void CTraffic::followNextPlane() { - if (m_planesByCallsign.empty() || m_planeViewCallsign.empty()) { return; } - auto callsignIt = std::find(m_followPlaneViewSequence.begin(), m_followPlaneViewSequence.end(), m_planeViewCallsign); + if (m_planesByCallsign.empty() || m_followPlaneViewCallsign.empty()) { return; } + auto callsignIt = std::find(m_followPlaneViewSequence.begin(), m_followPlaneViewSequence.end(), m_followPlaneViewCallsign); // If we are not at the end, increase by one if (callsignIt != m_followPlaneViewSequence.end()) { callsignIt++; } // If we were already at the end or reached it now, start from the beginning if (callsignIt == m_followPlaneViewSequence.end()) { callsignIt = m_followPlaneViewSequence.begin(); } - m_planeViewCallsign = *callsignIt; + m_followPlaneViewCallsign = *callsignIt; } int g_maxPlanes = 100; @@ -251,19 +251,19 @@ namespace XSwiftBus m_planesById[id] = plane; // Create view menu item - CMenuItem planeViewMenuItem = m_planeViewSubMenu.item(callsign, [this, callsign] { switchToPlaneView(callsign); }); - m_planeViewMenuItems[callsign] = planeViewMenuItem; + CMenuItem planeViewMenuItem = m_followPlaneViewSubMenu.item(callsign, [this, callsign] { enableFollowPlaneView(callsign); }); + m_followPlaneViewMenuItems[callsign] = planeViewMenuItem; m_followPlaneViewSequence.push_back(callsign); } } void CTraffic::removePlane(const std::string &callsign) { - auto menuItemIt = m_planeViewMenuItems.find(callsign); - if (menuItemIt != m_planeViewMenuItems.end()) + auto menuItemIt = m_followPlaneViewMenuItems.find(callsign); + if (menuItemIt != m_followPlaneViewMenuItems.end()) { - m_planeViewSubMenu.removeItem(menuItemIt->second); - m_planeViewMenuItems.erase(menuItemIt); + m_followPlaneViewSubMenu.removeItem(menuItemIt->second); + m_followPlaneViewMenuItems.erase(menuItemIt); } auto planeIt = m_planesByCallsign.find(callsign); @@ -289,15 +289,15 @@ namespace XSwiftBus delete plane; } - for (const auto &kv : m_planeViewMenuItems) + for (const auto &kv : m_followPlaneViewMenuItems) { CMenuItem item = kv.second; - m_planeViewSubMenu.removeItem(item); + m_followPlaneViewSubMenu.removeItem(item); } m_planesByCallsign.clear(); m_planesById.clear(); - m_planeViewMenuItems.clear(); + m_followPlaneViewMenuItems.clear(); m_followPlaneViewSequence.clear(); } @@ -423,7 +423,7 @@ namespace XSwiftBus auto planeIt = m_planesByCallsign.find(callsign); if (planeIt == m_planesByCallsign.end()) { return; } - switchToPlaneView(callsign); + enableFollowPlaneView(callsign); } const char *introspection_traffic = @@ -819,7 +819,7 @@ namespace XSwiftBus double dz = 50.0 * cos(heading * PI / 180.0); double dy = -50.0 * tan(pitch * PI / 180.0); - auto planeIt = traffic->m_planesByCallsign.find(traffic->m_planeViewCallsign); + auto planeIt = traffic->m_planesByCallsign.find(traffic->m_followPlaneViewCallsign); if (planeIt == traffic->m_planesByCallsign.end()) { return 0; } Plane *plane = planeIt->second; diff --git a/src/xswiftbus/traffic.h b/src/xswiftbus/traffic.h index 4fe366319..1c4163656 100644 --- a/src/xswiftbus/traffic.h +++ b/src/xswiftbus/traffic.h @@ -132,7 +132,7 @@ namespace XSwiftBus void emitSimFrame(); void emitPlaneAdded(const std::string &callsign); void emitPlaneAddingFailed(const std::string &callsign); - void switchToPlaneView(const std::string &callsign); + void enableFollowPlaneView(const std::string &callsign); void followNextPlane(); static int preferences(const char *section, const char *name, int def); @@ -166,14 +166,14 @@ namespace XSwiftBus std::vector m_followPlaneViewSequence; std::chrono::system_clock::time_point m_timestampLastSimFrame = std::chrono::system_clock::now(); - CMenu m_planeViewSubMenu; - std::unordered_map m_planeViewMenuItems; - std::string m_planeViewCallsign; + CMenu m_followPlaneViewSubMenu; + std::unordered_map m_followPlaneViewMenuItems; + std::string m_followPlaneViewCallsign; DataRef m_worldRenderType; bool m_emitSimFrame = true; - CCommand m_planeViewNextCommand; + CCommand m_followPlaneViewNextCommand; int getPlaneData(void *id, int dataType, void *io_data); static int getPlaneData(void *id, int dataType, void *io_data, void *self)