mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Add new command to jump to previous plane in follow plane view
ref T269
This commit is contained in:
committed by
Klaus Basan
parent
e55103ccdf
commit
87ba7183cc
@@ -45,7 +45,8 @@ namespace XSwiftBus
|
||||
|
||||
CTraffic::CTraffic(CDBusConnection *dbusConnection) :
|
||||
CDBusObject(dbusConnection),
|
||||
m_followPlaneViewNextCommand("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(); }),
|
||||
m_followPlaneViewPreviousCommand("org/swift-project/xswiftbus/follow_previous_plane", "Changes plane view to follow previous plane in sequence", [this] { followPreviousPlane(); })
|
||||
{
|
||||
registerDBusObjectPath(XSWIFTBUS_TRAFFIC_INTERFACENAME, XSWIFTBUS_TRAFFIC_OBJECTPATH);
|
||||
XPLMRegisterDrawCallback(drawCallback, xplm_Phase_Airplanes, 1, this);
|
||||
@@ -160,6 +161,19 @@ namespace XSwiftBus
|
||||
m_followPlaneViewCallsign = *callsignIt;
|
||||
}
|
||||
|
||||
void CTraffic::followPreviousPlane()
|
||||
{
|
||||
if (m_planesByCallsign.empty() || m_followPlaneViewCallsign.empty()) { return; }
|
||||
auto callsignIt = std::find(m_followPlaneViewSequence.rbegin(), m_followPlaneViewSequence.rend(), m_followPlaneViewCallsign);
|
||||
|
||||
// If we are not at the end, increase by one
|
||||
if (callsignIt != m_followPlaneViewSequence.rend()) { callsignIt++; }
|
||||
// If we were already at the end or reached it now, start from the beginning
|
||||
if (callsignIt == m_followPlaneViewSequence.rend()) { callsignIt = m_followPlaneViewSequence.rbegin(); }
|
||||
|
||||
m_followPlaneViewCallsign = *callsignIt;
|
||||
}
|
||||
|
||||
int g_maxPlanes = 100;
|
||||
float g_drawDistance = 50.0f;
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace XSwiftBus
|
||||
void emitPlaneAddingFailed(const std::string &callsign);
|
||||
void enableFollowPlaneView(const std::string &callsign);
|
||||
void followNextPlane();
|
||||
void followPreviousPlane();
|
||||
|
||||
static int preferences(const char *section, const char *name, int def);
|
||||
static float preferences(const char *section, const char *name, float def);
|
||||
@@ -169,12 +170,12 @@ namespace XSwiftBus
|
||||
CMenu m_followPlaneViewSubMenu;
|
||||
std::unordered_map<std::string, CMenuItem> m_followPlaneViewMenuItems;
|
||||
std::string m_followPlaneViewCallsign;
|
||||
CCommand m_followPlaneViewNextCommand;
|
||||
CCommand m_followPlaneViewPreviousCommand;
|
||||
|
||||
DataRef<xplane::data::sim::graphics::view::world_render_type> m_worldRenderType;
|
||||
bool m_emitSimFrame = true;
|
||||
|
||||
CCommand m_followPlaneViewNextCommand;
|
||||
|
||||
int getPlaneData(void *id, int dataType, void *io_data);
|
||||
static int getPlaneData(void *id, int dataType, void *io_data, void *self)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user