Rename all variables and functions to be similar to followPlaneView

This commit is contained in:
Roland Winklmeier
2018-06-05 11:53:59 +02:00
committed by Klaus Basan
parent 10b8cf5fea
commit e55103ccdf
3 changed files with 24 additions and 24 deletions

View File

@@ -33,7 +33,7 @@ namespace XSwiftBus
m_toggleMessageWindowMenuItem = m_menu.item("Toggle Message Window", [this] { if(m_service) { m_service->toggleMessageBoxVisibility(); } }); 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 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_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(); }); planeViewOwnAircraftMenuItem = m_planeViewSubMenu.item("Own Aircraft", [this] { switchToOwnAircraftView(); });
m_dbusThread = std::thread([this]() m_dbusThread = std::thread([this]()

View File

@@ -45,7 +45,7 @@ namespace XSwiftBus
CTraffic::CTraffic(CDBusConnection *dbusConnection) : CTraffic::CTraffic(CDBusConnection *dbusConnection) :
CDBusObject(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); registerDBusObjectPath(XSWIFTBUS_TRAFFIC_INTERFACENAME, XSWIFTBUS_TRAFFIC_OBJECTPATH);
XPLMRegisterDrawCallback(drawCallback, xplm_Phase_Airplanes, 1, this); XPLMRegisterDrawCallback(drawCallback, xplm_Phase_Airplanes, 1, this);
@@ -61,7 +61,7 @@ namespace XSwiftBus
void CTraffic::setPlaneViewMenu(const CMenu &planeViewSubMenu) void CTraffic::setPlaneViewMenu(const CMenu &planeViewSubMenu)
{ {
m_planeViewSubMenu = planeViewSubMenu; m_followPlaneViewSubMenu = planeViewSubMenu;
} }
void CTraffic::initLegacyData() void CTraffic::initLegacyData()
@@ -133,9 +133,9 @@ namespace XSwiftBus
sendDBusMessage(signalPlaneAddingFailed); 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 /* 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 * release to put us in 'free view 1'. This guarantees that no panels
@@ -149,15 +149,15 @@ namespace XSwiftBus
void CTraffic::followNextPlane() void CTraffic::followNextPlane()
{ {
if (m_planesByCallsign.empty() || m_planeViewCallsign.empty()) { return; } if (m_planesByCallsign.empty() || m_followPlaneViewCallsign.empty()) { return; }
auto callsignIt = std::find(m_followPlaneViewSequence.begin(), m_followPlaneViewSequence.end(), m_planeViewCallsign); auto callsignIt = std::find(m_followPlaneViewSequence.begin(), m_followPlaneViewSequence.end(), m_followPlaneViewCallsign);
// If we are not at the end, increase by one // If we are not at the end, increase by one
if (callsignIt != m_followPlaneViewSequence.end()) { callsignIt++; } if (callsignIt != m_followPlaneViewSequence.end()) { callsignIt++; }
// If we were already at the end or reached it now, start from the beginning // If we were already at the end or reached it now, start from the beginning
if (callsignIt == m_followPlaneViewSequence.end()) { callsignIt = m_followPlaneViewSequence.begin(); } if (callsignIt == m_followPlaneViewSequence.end()) { callsignIt = m_followPlaneViewSequence.begin(); }
m_planeViewCallsign = *callsignIt; m_followPlaneViewCallsign = *callsignIt;
} }
int g_maxPlanes = 100; int g_maxPlanes = 100;
@@ -251,19 +251,19 @@ namespace XSwiftBus
m_planesById[id] = plane; m_planesById[id] = plane;
// Create view menu item // Create view menu item
CMenuItem planeViewMenuItem = m_planeViewSubMenu.item(callsign, [this, callsign] { switchToPlaneView(callsign); }); CMenuItem planeViewMenuItem = m_followPlaneViewSubMenu.item(callsign, [this, callsign] { enableFollowPlaneView(callsign); });
m_planeViewMenuItems[callsign] = planeViewMenuItem; m_followPlaneViewMenuItems[callsign] = planeViewMenuItem;
m_followPlaneViewSequence.push_back(callsign); m_followPlaneViewSequence.push_back(callsign);
} }
} }
void CTraffic::removePlane(const std::string &callsign) void CTraffic::removePlane(const std::string &callsign)
{ {
auto menuItemIt = m_planeViewMenuItems.find(callsign); auto menuItemIt = m_followPlaneViewMenuItems.find(callsign);
if (menuItemIt != m_planeViewMenuItems.end()) if (menuItemIt != m_followPlaneViewMenuItems.end())
{ {
m_planeViewSubMenu.removeItem(menuItemIt->second); m_followPlaneViewSubMenu.removeItem(menuItemIt->second);
m_planeViewMenuItems.erase(menuItemIt); m_followPlaneViewMenuItems.erase(menuItemIt);
} }
auto planeIt = m_planesByCallsign.find(callsign); auto planeIt = m_planesByCallsign.find(callsign);
@@ -289,15 +289,15 @@ namespace XSwiftBus
delete plane; delete plane;
} }
for (const auto &kv : m_planeViewMenuItems) for (const auto &kv : m_followPlaneViewMenuItems)
{ {
CMenuItem item = kv.second; CMenuItem item = kv.second;
m_planeViewSubMenu.removeItem(item); m_followPlaneViewSubMenu.removeItem(item);
} }
m_planesByCallsign.clear(); m_planesByCallsign.clear();
m_planesById.clear(); m_planesById.clear();
m_planeViewMenuItems.clear(); m_followPlaneViewMenuItems.clear();
m_followPlaneViewSequence.clear(); m_followPlaneViewSequence.clear();
} }
@@ -423,7 +423,7 @@ namespace XSwiftBus
auto planeIt = m_planesByCallsign.find(callsign); auto planeIt = m_planesByCallsign.find(callsign);
if (planeIt == m_planesByCallsign.end()) { return; } if (planeIt == m_planesByCallsign.end()) { return; }
switchToPlaneView(callsign); enableFollowPlaneView(callsign);
} }
const char *introspection_traffic = const char *introspection_traffic =
@@ -819,7 +819,7 @@ namespace XSwiftBus
double dz = 50.0 * cos(heading * PI / 180.0); double dz = 50.0 * cos(heading * PI / 180.0);
double dy = -50.0 * tan(pitch * 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; } if (planeIt == traffic->m_planesByCallsign.end()) { return 0; }
Plane *plane = planeIt->second; Plane *plane = planeIt->second;

View File

@@ -132,7 +132,7 @@ namespace XSwiftBus
void emitSimFrame(); void emitSimFrame();
void emitPlaneAdded(const std::string &callsign); void emitPlaneAdded(const std::string &callsign);
void emitPlaneAddingFailed(const std::string &callsign); void emitPlaneAddingFailed(const std::string &callsign);
void switchToPlaneView(const std::string &callsign); void enableFollowPlaneView(const std::string &callsign);
void followNextPlane(); void followNextPlane();
static int preferences(const char *section, const char *name, int def); static int preferences(const char *section, const char *name, int def);
@@ -166,14 +166,14 @@ namespace XSwiftBus
std::vector<std::string> m_followPlaneViewSequence; std::vector<std::string> m_followPlaneViewSequence;
std::chrono::system_clock::time_point m_timestampLastSimFrame = std::chrono::system_clock::now(); std::chrono::system_clock::time_point m_timestampLastSimFrame = std::chrono::system_clock::now();
CMenu m_planeViewSubMenu; CMenu m_followPlaneViewSubMenu;
std::unordered_map<std::string, CMenuItem> m_planeViewMenuItems; std::unordered_map<std::string, CMenuItem> m_followPlaneViewMenuItems;
std::string m_planeViewCallsign; std::string m_followPlaneViewCallsign;
DataRef<xplane::data::sim::graphics::view::world_render_type> m_worldRenderType; DataRef<xplane::data::sim::graphics::view::world_render_type> m_worldRenderType;
bool m_emitSimFrame = true; bool m_emitSimFrame = true;
CCommand m_planeViewNextCommand; CCommand m_followPlaneViewNextCommand;
int getPlaneData(void *id, int dataType, void *io_data); int getPlaneData(void *id, int dataType, void *io_data);
static int getPlaneData(void *id, int dataType, void *io_data, void *self) static int getPlaneData(void *id, int dataType, void *io_data, void *self)