Skip to content

Commit

Permalink
Feat/Labels: Show for parked a/c; channel
Browse files Browse the repository at this point in the history
  • Loading branch information
TwinFan committed Nov 30, 2024
1 parent 807270c commit 9147f75
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
14 changes: 9 additions & 5 deletions Include/DataRefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ enum dataRefsLT {
DR_CFG_LABEL_SHOWN,
DR_CFG_LABEL_MAX_DIST,
DR_CFG_LABEL_VISIBILITY_CUT_OFF,
DR_CFG_LABEL_FOR_PARKED,
DR_CFG_LABEL_COL_DYN,
DR_CFG_LABEL_COLOR,
DR_CFG_LOG_LEVEL,
Expand Down Expand Up @@ -593,7 +594,8 @@ class DataRefs
bAlt : 1, // default
bHeightAGL : 1,
bSpeed : 1, // default
bVSI : 1;
bVSI : 1,
bChannel : 1;

// this is a bit ugly but avoids a wrapper union with an int
inline unsigned GetUInt() const { return *reinterpret_cast<const unsigned*>(this); }
Expand Down Expand Up @@ -697,11 +699,12 @@ class DataRefs
bool bAwaitingAIControl = false; ///< have in vain tried acquiring AI control and are waiting for callback now?
int bAINotOnGnd = false; ///< shall a/c on the ground be hidden from TCAS/AI?
// which elements make up an a/c label?
LabelCfgTy labelCfg = { 0,1,0,0,0,0,0,0, 0,0,0,0,0,0 };
LabelCfgTy labelCfg = { 0,1,0,0,0,0,0,0, 0,0,0,0,0,0,0 };
LabelShowCfgTy labelShown = { 1, 1, 1, 1 }; ///< when to show? (default: always)
int labelMaxDist = 3; ///< [nm] max label distance
bool bLabelVisibilityCUtOff = true; ///< cut off labels at reported visibility?
bool bLabelColDynamic = false; // dynamic label color?
int bLabelVisibilityCUtOff = true; ///< cut off labels at reported visibility?
int bLabelForParked = true; ///< show labels for parked aircraft?
int bLabelColDynamic = false; ///< dynamic label color?
int labelColor = COLOR_YELLOW; ///< label color, by default yellow
int maxNumAc = DEF_MAX_NUM_AC; ///< how many aircraft to create at most?
int fdStdDistance = DEF_FD_STD_DISTANCE; ///< nm: miles to look for a/c around myself
Expand All @@ -724,7 +727,7 @@ class DataRefs
int contrailAltMin_ft = DEF_CONTR_ALT_MIN; ///< [ft] Auto Contrails: Minimum altitude
int contrailAltMax_ft = DEF_CONTR_ALT_MAX; ///< [ft] Auto Contrails: Maximum altitude
int contrailLifeTime = DEF_CONTR_LIFETIME; ///< [s] Contrail default time to live
bool contrailMulti = DEF_CONTR_MULTI; ///< Auto-create multiple or just a single contrail?
int contrailMulti = DEF_CONTR_MULTI; ///< Auto-create multiple or just a single contrail?
int remoteSupport = 0; ///< support XPMP2 Remote Client? (3-way: -1 off, 0 auto, 1 on)
int bUseExternalCamera = false; ///< Do not activate LiveTraffic's camera view when hitting the camera button (intended for a 3rd party camera plugin to activate instead based on reading livetraffic/camera/... dataRefs or using LTAPI)

Expand Down Expand Up @@ -947,6 +950,7 @@ class DataRefs
inline LabelCfgTy GetLabelCfg() const { return labelCfg; }
inline LabelShowCfgTy GetLabelShowCfg() const { return labelShown; }
inline bool IsLabelColorDynamic() const { return bLabelColDynamic; }
bool LabelShowForParked() const { return bLabelForParked; }
inline int GetLabelColor() const { return labelColor; }
void GetLabelColor (float outColor[4]) const;
inline int GetMaxNumAc() const { return maxNumAc; }
Expand Down
2 changes: 1 addition & 1 deletion Include/LTFlightData.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class LTFlightData
int sig; // signal level

std::string labelStat; // static part of the a/c label
DataRefs::LabelCfgTy labelCfg = { 0,0,0,0,0,0,0,0, 0,0,0,0,0,0 }; // the configuration the label was saved for
DataRefs::LabelCfgTy labelCfg = { 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0 }; // the configuration the label was saved for

protected:
// DYNAMIC DATA (protected, access will be mutex-controlled for thread-safety)
Expand Down
2 changes: 2 additions & 0 deletions Src/DataRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ DataRefs::dataRefDefinitionT DATA_REFS_LT[CNT_DATAREFS_LT] = {
{"livetraffic/cfg/label_shown", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
{"livetraffic/cfg/label_max_dist", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
{"livetraffic/cfg/label_visibility_cut_off", DataRefs::LTGetInt, DataRefs::LTSetBool, GET_VAR, true },
{"livetraffic/cfg/label_for_parked", DataRefs::LTGetInt, DataRefs::LTSetBool, GET_VAR, true },
{"livetraffic/cfg/label_col_dyn", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
{"livetraffic/cfg/label_color", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
{"livetraffic/cfg/log_level", DataRefs::LTGetInt, DataRefs::LTSetLogLevel, GET_VAR, true },
Expand Down Expand Up @@ -611,6 +612,7 @@ void* DataRefs::getVarAddr (dataRefsLT dr)
case DR_CFG_LABEL_SHOWN: return &labelShown;
case DR_CFG_LABEL_MAX_DIST: return &labelMaxDist;
case DR_CFG_LABEL_VISIBILITY_CUT_OFF: return &bLabelVisibilityCUtOff;
case DR_CFG_LABEL_FOR_PARKED: return &bLabelForParked;
case DR_CFG_LABEL_COL_DYN: return &bLabelColDynamic;
case DR_CFG_LABEL_COLOR: return &labelColor;
case DR_CFG_LOG_LEVEL: return &iLogLevel;
Expand Down
12 changes: 12 additions & 0 deletions Src/LTFlightData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ std::string LTFlightData::ComposeLabel() const

// only possible if we have an aircraft
if (pAc) {
// If aircraft is parked and we shall not show labels for parked a/c, then return nothing
if (!dataRefs.LabelShowForParked() &&
pAc->GetFlightPhase() == FPH_PARKED)
return "";

// current position of a/c
const positionTy& pos = pAc->GetPPos();
// add more items as per configuration
Expand All @@ -544,6 +549,13 @@ std::string LTFlightData::ComposeLabel() const
}
ADD_LABEL_NUM(cfg.bSpeed, pAc->GetSpeed_kt());
ADD_LABEL_NUM(cfg.bVSI, pAc->GetVSI_ft());
if (cfg.bChannel) {
const LTChannel* pChn = nullptr;
if (GetCurrChannel(pChn) && pChn) {
label += pChn->ChName();
label += ' ';
}
}
}

// remove the trailing space
Expand Down
2 changes: 2 additions & 0 deletions Src/SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ void LTSettingsUI::buildInterface()
// Label cut off: distance / visibility
ImGui::FilteredCfgNumber ("Max Distance", sFilter, DR_CFG_LABEL_MAX_DIST, 1, 50, 1, "%d nm");
ImGui::FilteredCfgCheckbox("Cut off at Visibility", sFilter, DR_CFG_LABEL_VISIBILITY_CUT_OFF);
ImGui::FilteredCfgCheckbox("Labels for Parked a/c", sFilter, DR_CFG_LABEL_FOR_PARKED);

// Static / dynamic info
c = dataRefs.GetLabelCfg().GetUInt();
Expand All @@ -906,6 +907,7 @@ void LTSettingsUI::buildInterface()
ImGui::FilteredCheckboxFlags("Height AGL [ft]", sFilter, &c, (1 << 11));
ImGui::FilteredCheckboxFlags("Speed [kn]", sFilter, &c, (1 << 12));
ImGui::FilteredCheckboxFlags("VSI [ft/min]", sFilter, &c, (1 << 13));
ImGui::FilteredCheckboxFlags("Channel", sFilter, &c, (1 << 14));
if (!*sFilter) ImGui::TreePop();
}

Expand Down
38 changes: 38 additions & 0 deletions docs/readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,44 @@ <h1 id="release-notes">Release Notes</h1>

<h2>v4</h2>

<h3>v4.1.1</h3>

<P>
<b>Update:</b> In case of doubt you can always just copy all files from the archive
over the files of your existing installation.
</P>

<P>At least copy the following files, which have changed compared to v4.1.0:</P>
<ul>
<li><code>lin|mac|win_x64/LiveTraffic.xpl</code></li>
</ul>

<P>Change log:</P>

<ul>
<li>
Added two options to <a href="https://twinfan.gitbook.io/livetraffic/setup/configuration/settings-a-c-labels">Settings &gt; Aircraft Labels</a>:
<ul>
<li><i>Labels for Parked a/c</i> allows to switch off labels for parked aircraft as they can quite clutter the screen on larger airports</li>
<li><i>Dynamic Information &gt; Channel</i> adds the name of the channel currently driving the plane's data to the label</li>
</ul>
</li>
<li>Fixed checking for new versions after a change to the X-Plane.org
forum no longer allows providing version number information for
uploads.<br>
<strong>This means that LiveTraffic v4.1.0 and earlier cannot
inform you about this update to v4.1.1!</strong>
</li>
<li>Fixed processing OpenSky Masterdata File download and processing
after changes to both download location and format.
</li>
<li>Fixed a bug preventing parked aircraft from disappearing when a
taxiing aircraft comes too close. Is a very rare event when watching
real world traffic, but is more likely with virtual traffic added
to the mix.
</li>
</ul>

<h3>v4.1.0</h3>

<P>
Expand Down

0 comments on commit 9147f75

Please sign in to comment.