Skip to content

Commit 44f2cfd

Browse files
authored
Merge pull request #197 from TwinFan/Next
v2.10
2 parents a1809cd + b975e0c commit 44f2cfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1050
-225
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Set up to be used in a Visual Studio environment to build win (File > Open > Folder, then VS recognized the CMAKE configuration)
44

55
cmake_minimum_required(VERSION 3.16)
6-
project(LiveTraffic VERSION 2.09 DESCRIPTION "LiveTraffic X-Plane plugin" LANGUAGES C CXX)
6+
project(LiveTraffic VERSION 2.10 DESCRIPTION "LiveTraffic X-Plane plugin" LANGUAGES C CXX)
77

88
# By default, use optimized release configuration.
99
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
@@ -68,6 +68,7 @@ set(Header_Files
6868
Include/LTImgWindow.h
6969
Include/LTOpenSky.h
7070
Include/LTRealTraffic.h
71+
Include/LTWeather.h
7172
Include/Network.h
7273
Include/SettingsUI.h
7374
Include/TextIO.h
@@ -109,6 +110,7 @@ set(Source_Files
109110
Src/LTOpenSky.cpp
110111
Src/LTRealTraffic.cpp
111112
Src/LTVersion.cpp
113+
Src/LTWeather.cpp
112114
Src/Network.cpp
113115
Src/SettingsUI.cpp
114116
Src/TextIO.cpp

Include/ACInfoWnd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class ACIWnd : public LTImgWindow
119119
// hide/show all windows, returns new state
120120
static bool ToggleHideShowAll();
121121
static bool AreShown() { return bAreShown; }
122+
static ACIWnd* GetWnd (const LTFlightData::FDKeyTy& _key);
122123
static void CloseAll();
123124

124125
};

Include/ACTable.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum ACTColumnsTy {
6060
ACT_COL_GEAR, ///< gear deployment ratio
6161
ACT_COL_FLAPS, ///< flap deployment ratio
6262
ACT_COL_LIGHTS, ///< which lights are on?
63+
ACT_COL_TCAS_IDX, ///< TCAS Idx (1-63) of plane - if any
6364

6465
// these must stay last
6566
ACT_COL_ACTIONS, ///< actions like a/c info wnd, camera, visibility
@@ -99,8 +100,8 @@ class FDInfo {
99100
/// @warning Can return `nullptr`!
100101
LTFlightData* GetFD () const;
101102

102-
/// @brief Does _any_ value match this filter string?
103-
/// @param _s Substring to be searched for, expected in _upper case_
103+
/// @brief Does any value match this filter string?
104+
/// @param _s Substring to be searched for, expected in upper case
104105
bool matches (const std::string& _s) const;
105106
};
106107

Include/Constants.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
//
3030
// MARK: Version Information (CHANGE VERSION HERE)
3131
//
32-
constexpr float VERSION_NR = 2.09f;
33-
constexpr bool VERSION_BETA = true;
32+
constexpr float VERSION_NR = 2.10f;
33+
constexpr bool VERSION_BETA = false;
3434
extern float verXPlaneOrg; // version on X-Plane.org
3535
extern int verDateXPlaneOrg; // and its date
3636

@@ -58,7 +58,7 @@ constexpr double PI = 3.141592653589793238462643383279502884197169399375
5858
constexpr double EARTH_D_M = 6371.0 * 2 * 1000; // earth diameter in meter
5959
constexpr double JAN_FIRST_2019 = 1546344000; // 01.01.2019
6060
constexpr double HPA_STANDARD = 1013.25; // air pressure
61-
constexpr double INCH_STANDARD = 2992.126;
61+
constexpr double INCH_STANDARD = 29.92126;
6262
constexpr double HPA_per_INCH = HPA_STANDARD/INCH_STANDARD;
6363
// The pressure drops approximately by 11.3 Pa per meter in first 1000 meters above sea level.
6464
constexpr double PA_per_M = 11.3; // https://en.wikipedia.org/wiki/Barometric_formula
@@ -157,7 +157,7 @@ constexpr int LT_NEW_VER_CHECK_TIME = 48; // [h] between two checks of a new
157157
#define MSG_WELCOME "LiveTraffic %s successfully loaded!"
158158
#define MSG_REINIT "LiveTraffic is re-initializing itself"
159159
#define MSG_DISABLE_MYSELF "LiveTraffic disables itself due to unhandable exceptions"
160-
#define MSG_LT_NEW_VER_AVAIL "The new version %01.2f of LiveTraffic is available at X-Plane.com!"
160+
#define MSG_LT_NEW_VER_AVAIL "The new version %01.2f of LiveTraffic is available at X-Plane.org!"
161161
#define MSG_TIMESTAMPS "Current System time is %sZ, current simulated time is %s"
162162
#define MSG_AI_LOAD_ACF "Changing AI control: X-Plane is now loading AI Aircraft models..."
163163
#define MSG_REQUESTING_LIVE_FD "Requesting live flight data online..."
@@ -166,6 +166,7 @@ constexpr int LT_NEW_VER_CHECK_TIME = 48; // [h] between two checks of a new
166166
#define MSG_NUM_AC_ZERO "No more aircraft displayed"
167167
#define MSG_BUF_FILL_COUNTDOWN "Filling buffer: seeing %d aircraft, displaying %d, still %ds to buffer"
168168
#define MSG_HIST_WITH_SYS_TIME "When using historic data you cannot run X-Plane with 'always track system time',\ninstead, choose the historic date in X-Plane's date/time settings."
169+
#define INFO_WEATHER_UPDATED "Weather updated: QNH %.f hPa at %s (%.2f°, %.2f°)"
169170
#define INFO_AC_ADDED "Added aircraft %s, operator '%s', a/c model '%s', flight model [%s], bearing %.0f, distance %.1fnm, from channel %s"
170171
#define INFO_AC_MDL_CHANGED "Changed CSL model for aircraft %s, operator '%s': a/c model now '%s'"
171172
#define INFO_GND_VEHICLE_APT "Vehicle %s: Decided for ground vehicle based on operator name '%s'"
@@ -218,6 +219,7 @@ constexpr int LT_NEW_VER_CHECK_TIME = 48; // [h] between two checks of a new
218219
#define MENU_HELP_DOCUMENTATION "Documentation"
219220
#define MENU_HELP_FAQ "FAQ"
220221
#define MENU_HELP_MENU_ITEMS "Menu Items"
222+
#define MENU_HELP_INFO_LIST_WND "Status / Info Window"
221223
#define MENU_HELP_AC_INFO_WND "A/C Info Window"
222224
#define MENU_HELP_SETTINGS "Settings"
223225
#define MENU_NEWVER "New Version %01.2f available!"
@@ -230,6 +232,11 @@ constexpr int LT_NEW_VER_CHECK_TIME = 48; // [h] between two checks of a new
230232
#define HELP_URL "https://twinfan.gitbook.io/livetraffic/"
231233
#define HELP_FAQ "reference/faq"
232234
#define HELP_MENU_ITEMS "using-lt/menu-items"
235+
#define HELP_ILW "using-lt/info-list-window"
236+
#define HELP_ILW_AC_LIST "using-lt/info-list-window/aircraft-list"
237+
#define HELP_ILW_MESSAGES "using-lt/info-list-window/messages"
238+
#define HELP_ILW_STATUS "using-lt/info-list-window/status-about"
239+
#define HELP_ILW_SETTINGS "using-lt/info-list-window/ui-settings"
233240
#define HELP_AC_INFO_WND "using-lt/aircraft-information-window"
234241
#define HELP_SETTINGS "setup/configuration#settings-ui"
235242
#define HELP_SET_BASICS "setup/configuration/settings-basics"
@@ -243,7 +250,6 @@ constexpr int LT_NEW_VER_CHECK_TIME = 48; // [h] between two checks of a new
243250
#define HELP_SET_ADVANCED "setup/configuration/settings-advanced"
244251
#define HELP_SET_CSL "setup/configuration/settings-csl"
245252
#define HELP_SET_DEBUG "setup/configuration/settings-debug"
246-
#define HELP_ILW "using-lt/info-list-window"
247253

248254
//MARK: File Paths
249255
// these are under the plugins directory
@@ -289,7 +295,8 @@ constexpr int SERR_LEN = 100; // size of buffer for IO error t
289295
#define ERR_CURL_DISABLE_REV_QU "%s: Querying revocation list failed - have set CURLSSLOPT_NO_REVOKE and am trying again"
290296
#define ERR_HTTP_NOT_OK "HTTP response was not HTTP_OK"
291297
#define ERR_FOUND_NO_VER_INFO "Found no version info in response"
292-
#define ERR_CH_NONE_ACTIVE "No enabled active channel for tracking data! Check Basic Settings and enable channels."
298+
#define ERR_CH_NONE_ACTIVE1 "No enabled active channel for tracking data!"
299+
#define ERR_CH_NONE_ACTIVE ERR_CH_NONE_ACTIVE1 " Check Basic Settings and enable channels."
293300
#define ERR_CH_UNKNOWN_NAME "(unknown channel)"
294301
#define ERR_CH_INVALID "%s: Channel invalid and disabled"
295302
#define ERR_CH_MAX_ERR_INV "%s: Channel invalid and disabled after too many errors"

Include/DataRefs.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ enum dataRefsLT {
358358
DR_CFG_HIDE_TAXIING,
359359
DR_CFG_HIDE_NEARBY_GND,
360360
DR_CFG_HIDE_NEARBY_AIR,
361+
DR_CFG_COPY_OBJ_FILES,
361362
DR_CFG_LAST_CHECK_NEW_VER,
362363

363364
// debug options
@@ -616,6 +617,7 @@ class DataRefs
616617
int hideTaxiing = 0; // hide a/c while taxiing?
617618
int hideNearbyGnd = 0; // [m] hide a/c if closer than this to user's aircraft on the ground
618619
int hideNearbyAir = 0; // [m] hide a/c if closer than this to user's aircraft in the air
620+
int cpyObjFiles = 1; ///< copy `.obj` files for replacing dataRefs and textures
619621

620622
// channel config options
621623
int rtListenPort = 10747; // port opened for RT to connect
@@ -639,6 +641,14 @@ class DataRefs
639641
std::string keyAc; // key (transpIcao) for a/c whose data is returned
640642
const LTAircraft* pAc = nullptr; // ptr to that a/c
641643

644+
// Weather
645+
double altPressCorr_ft = 0.0; ///< [ft] barometric correction for pressure altitude, in meter
646+
float lastWeatherUpd = 0.0f; ///< last time the weather was updated? (in XP's network time)
647+
float lastWeatherHPA = HPA_STANDARD; ///< last barometric pressure received
648+
positionTy lastWeatherPos; ///< last position for which weather was retrieved
649+
std::string lastWeatherStationId; ///< last weather station we got weather from
650+
std::string lastWeatherMETAR; ///< last full METAR string
651+
642652
//MARK: Debug helpers (public)
643653
public:
644654
std::string cslFixAcIcaoType; // set of fixed values to use for...
@@ -688,7 +698,7 @@ class DataRefs
688698
public:
689699
void ThisThreadIsXP() { xpThread = std::this_thread::get_id(); }
690700
bool IsXPThread() const { return std::this_thread::get_id() == xpThread; }
691-
inline float GetMiscNetwTime() const { return lastNetwTime; }
701+
float GetMiscNetwTime() const;
692702
inline bool IsViewExternal() const { return XPLMGetDatai(adrXP[DR_VIEW_EXTERNAL]) != 0; }
693703
inline XPViewTypes GetViewType () const { return (XPViewTypes)XPLMGetDatai(adrXP[DR_VIEW_TYPE]); }
694704
inline bool UsingModernDriver () const { return bUsingModernDriver; }
@@ -786,6 +796,7 @@ class DataRefs
786796
inline bool IsAutoHidingActive() const ///< any auto-hiding activated?
787797
{ return hideBelowAGL > 0 || hideTaxiing != 0 ||
788798
hideNearbyGnd > 0 || hideNearbyAir > 0; }
799+
bool ShallCpyObjFiles () const { return cpyObjFiles != 0; }
789800

790801
bool NeedNewVerCheck () const;
791802
void SetLastCheckedNewVerNow ();
@@ -799,7 +810,7 @@ class DataRefs
799810
bool SetDefaultCarIcaoType(const std::string type);
800811

801812
// livetraffic/channel/...
802-
inline void SetChannelEnabled (dataRefsLT ch, bool bEnable) { bChannel[ch - DR_CHANNEL_FIRST] = bEnable; }
813+
void SetChannelEnabled (dataRefsLT ch, bool bEnable);
803814
inline bool IsChannelEnabled (dataRefsLT ch) const { return bChannel[ch - DR_CHANNEL_FIRST]; }
804815
int CntChannelEnabled () const;
805816

@@ -864,6 +875,19 @@ class DataRefs
864875
bool ShallDrawLabels() const;
865876
bool ShallDrawMapLabels() const { return labelShown.bMap; }
866877
bool ToggleLabelDraw(); // returns new value
878+
879+
// Weather
880+
bool WeatherUpdate (); ///< check if weather updated needed, then do
881+
/// @brief set/update current weather
882+
/// @details if lat/lon ar NAN, then location of provided station is taken if found, else current camera pos
883+
void SetWeather (float hPa, float lat, float lon, const std::string& stationId,
884+
const std::string& METAR);
885+
/// Compute geometric altitude [ft] from pressure altitude and current weather in a very simplistic manner good enough for the first 3,000ft
886+
double WeatherAltCorr_ft (double pressureAlt_ft) { return pressureAlt_ft + altPressCorr_ft; }
887+
/// Compute geometric altitude [m] from pressure altitude and current weather in a very simplistic manner good enough for the first 3,000ft
888+
double WeatherAltCorr_m (double pressureAlt_m) { return pressureAlt_m + altPressCorr_ft * M_per_FT; }
889+
/// Thread-safely gets current weather info
890+
void GetWeather (float& hPa, std::string& stationId, std::string& METAR);
867891
};
868892

869893
extern DataRefs::dataRefDefinitionT DATA_REFS_LT[CNT_DATAREFS_LT];

Include/InfoListWnd.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ class InfoListWnd : public LTImgWindow
4545
LogMsgListTy::const_iterator lastEnd;
4646

4747
// Info/Status
48+
float lastStatusUpdate = 0.0f; ///< when last updates periodic status info?
4849
std::string verText; ///< version information
4950
std::string aiCtrlPlugin; ///< name of plugin controlling AI planes
50-
float lastAIPluginCheck = 0.0f; ///< when last checked for AI-controlling plugin name?
51+
float weatherHPA = HPA_STANDARD;///< Weather: QNH
52+
std::string weatherStationId; ///< Weather: reporting station
53+
std::string weatherMETAR; ///< Weather: full METAR
5154

5255
public:
5356
/// Constructor shows the window

Include/LTADSBEx.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include "LTChannel.h"
3535

3636
//MARK: ADS-B Exchange Constants
37+
#define ADSBEX_CHECK_NAME "ADSBX Radar View"
38+
#define ADSBEX_CHECK_URL "https://globe.adsbexchange.com/"
39+
#define ADSBEX_CHECK_POPUP "Check ADS-B Exchange's coverage"
40+
3741
#define ADSBEX_NAME "ADS-B Exchange Online"
3842
#define ADSBEX_URL "https://adsbexchange.com/api/aircraft/json/lat/%f/lon/%f/dist/%d/"
3943
#define ADSBEX_API_AUTH "api-auth:" // additional HTTP header
@@ -55,7 +59,7 @@
5559
#define ADSBEX_LAT "lat"
5660
#define ADSBEX_LON "lon"
5761
#define ADSBEX_ELEVATION "galt" // geometric altitude
58-
// #define ADSBEX_ALT "alt" // barometric altitude
62+
#define ADSBEX_ALT "alt" // barometric altitude
5963
#define ADSBEX_HEADING "trak"
6064
#define ADSBEX_GND "gnd"
6165
// #define ADSBEX_IN_HG "InHg"
@@ -116,10 +120,7 @@ class ADSBExchangeConnection : public LTOnlineChannel, LTFlightDataChannel
116120
keyTypeE keyTy = ADSBEX_KEY_NONE;
117121
struct curl_slist* slistKey = NULL;
118122
public:
119-
ADSBExchangeConnection () :
120-
LTChannel(DR_CHANNEL_ADSB_EXCHANGE_ONLINE),
121-
LTOnlineChannel(),
122-
LTFlightDataChannel() {}
123+
ADSBExchangeConnection ();
123124
virtual std::string GetURL (const positionTy& pos);
124125
virtual bool ProcessFetchedData (mapLTFlightDataTy& fdMap);
125126
virtual bool IsLiveFeed() const { return true; }

Include/LTChannel.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class LTChannel
5454
CHT_MASTER_DATA,
5555
CHT_TRAFFIC_SENDER, // sends out data (not receiving)
5656
};
57+
58+
public:
59+
std::string urlLink; ///< an URL related to that channel, eg. a radar view for testing coverage, or a home page
60+
std::string urlName; ///< Name for the URL, could show on link buttons
61+
std::string urlPopup; ///< more detailed text, shows eg. as popup when hovering over the link button
62+
5763
protected:
5864
dataRefsLT channel; // id of channel (see dataRef)
5965

@@ -237,6 +243,9 @@ void LTFlightDataHideAircraft();
237243
void LTFlightDataDisable();
238244
void LTFlightDataStop();
239245

246+
/// Is at least one tracking data channel enabled?
247+
bool LTFlightDataAnyTrackingChEnabled ();
248+
240249
//
241250
//MARK: Aircraft Maintenance (called from flight loop callback)
242251
//

Include/LTForeFlight.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
// MARK: ForeFlight Constants
3232
//
3333

34+
#define FF_CHECK_NAME "ForeFlight Mobile EFB"
35+
#define FF_CHECK_URL "https://foreflight.com/products/foreflight-mobile/"
36+
#define FF_CHECK_POPUP "Open ForeFlight's web site about the Mobile EFB"
37+
3438
#define FOREFLIGHT_NAME "ForeFlight"
3539
#define FF_LOCALHOST "0.0.0.0"
3640
constexpr size_t FF_NET_BUF_SIZE = 512;

Include/LTImgWindow.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,34 @@ IMGUI_API bool ButtonURL(const char* label,
106106
ImU32 colBg = IM_COL32(1,1,1,0),
107107
const ImVec2& size = ImVec2(0,0));
108108

109+
/// @brief Selectable with handling of disabled and with tooltip
110+
/// @param label Text on Button
111+
/// @param p_selected Passes in and receives the selected state
112+
/// @param bEnabled Is the selectable enabled or disabled (greyed out)?
113+
/// @param tip Tooltip text when hovering over the button (or NULL of none)
114+
/// @param flags are ImGui's standard set of Selectable flags
115+
/// @param size button size, 0 for either axis means: auto size
116+
IMGUI_API bool SelectableTooltip(const char* label,
117+
bool* p_selected,
118+
bool bEnabled = true,
119+
const char* tip = nullptr,
120+
ImGuiSelectableFlags flags = 0,
121+
const ImVec2& size = ImVec2(0, 0));
122+
123+
/// @brief Selectable with handling of disabled and with tooltip
124+
/// @param label Text on Button
125+
/// @param bSelected Currently selected?
126+
/// @param bEnabled Is the selectable enabled or disabled (greyed out)?
127+
/// @param tip Tooltip text when hovering over the button (or NULL of none)
128+
/// @param flags are ImGui's standard set of Selectable flags
129+
/// @param size button size, 0 for either axis means: auto size
130+
IMGUI_API bool SelectableTooltip(const char* label,
131+
bool bSelected,
132+
bool bEnabled = true,
133+
const char* tip = nullptr,
134+
ImGuiSelectableFlags flags = 0,
135+
const ImVec2& size = ImVec2(0, 0));
136+
109137
/// @brief A checkbox toggling a defined integer dataRef
110138
/// @param label Checkbox's label
111139
/// @param idx Index into `DATA_REFS_LT`, defining the integer dataRef to toggle between 0 and 1. Can be -1 for an always deactivated checkbox

0 commit comments

Comments
 (0)