@@ -10,51 +10,10 @@ CESTrackFunctions::CESTrackFunctions()
10
10
RegisterTagItemFunction (" Clean FP" , ITEM_FUNCTION_CLEAN_FP);
11
11
}
12
12
13
-
14
13
CESTrackFunctions::~CESTrackFunctions ()
15
14
{
16
15
}
17
16
18
- bool CESTrackFunctions::OnCompileCommand (const char * sCommandLine )
19
- {
20
- if (!strcmp (sCommandLine , " .fpt" ))
21
- {
22
- CleanFlightPlan (FlightPlanSelectASEL ());
23
- return true ;
24
- }
25
- if (!strcmp (sCommandLine , " .autodrop" ))
26
- {
27
- autoDrop = (autoDrop == 1 ? 0 : 1 );
28
- SaveDataToSettings (" AutoDrop" , " Drop Track for landing AC" , (autoDrop == 1 ? " 1" : " 0" ));
29
- return true ;
30
- }
31
- return false ;
32
- }
33
-
34
- void CESTrackFunctions::OnTimer (int Counter)
35
- {
36
- if (!ControllerMyself ().IsValid () || !ControllerMyself ().IsController ())
37
- return ;
38
- if (GetConnectionType () != EuroScopePlugIn::CONNECTION_TYPE_DIRECT)
39
- return ;
40
- if (autoDrop)
41
- {
42
- for (auto flightplan = FlightPlanSelectFirst ();
43
- flightplan.IsValid ();
44
- flightplan = FlightPlanSelectNext (flightplan))
45
- {
46
- if (flightplan.GetSimulated ()) continue ;
47
- if (CheckDrop (flightplan))
48
- flightplan.EndTracking ();
49
- }
50
- }
51
- }
52
-
53
- void CESTrackFunctions::PostDebugMessage (std::string message)
54
- {
55
- DisplayUserMessage (" Debug" , " Debug" , message.c_str (), true , true , true , false , false );
56
- }
57
-
58
17
bool CESTrackFunctions::CheckDrop (const EuroScopePlugIn::CFlightPlan & flightplan) const
59
18
{
60
19
if (!flightplan.GetTrackingControllerIsMe ())
@@ -72,25 +31,69 @@ bool CESTrackFunctions::CheckDrop(const EuroScopePlugIn::CFlightPlan & flightpla
72
31
return false ;
73
32
}
74
33
75
- void CESTrackFunctions::CleanFlightPlan (EuroScopePlugIn::CFlightPlan & flightplan )
34
+ void CESTrackFunctions::CleanFlightPlan ()
76
35
{
77
- if (!flightplan.IsValid ()) return ;
78
- std::string route{ FlightPlanFunctions.StripRouteString (flightplan.GetFlightPlanData ().GetRoute (), flightplan) };
36
+ auto flightplan{ FlightPlanSelectASEL () };
37
+ if (!flightplan.IsValid ())
38
+ return ;
39
+ auto route{ FlightPlanFunctions.StripRouteString (flightplan.GetFlightPlanData ().GetRoute (), flightplan) };
79
40
flightplan.GetFlightPlanData ().SetRoute (route.c_str ());
80
41
flightplan.GetFlightPlanData ().AmendFlightPlan ();
81
42
}
82
43
44
+ void CESTrackFunctions::DisplayMessage (const std::string message, const std::string handler)
45
+ {
46
+ DisplayUserMessage (MY_PLUGIN_NAME, handler.c_str (), message.c_str (), true , true , true , false , false );
47
+ }
48
+
83
49
void CESTrackFunctions::LoadSettings ()
84
50
{
85
- auto ad = GetDataFromSettings (" AutoDrop " ) ;
86
- if (ad != NULL )
51
+ auto ad{ GetDataFromSettings (SETTING_AUTODROP) } ;
52
+ if (ad != nullptr )
87
53
autoDrop = (strcmp (ad, " 1" ) ? 1 : 0 );
88
54
}
89
55
56
+ bool CESTrackFunctions::OnCompileCommand (const char * sCommandLine )
57
+ {
58
+ if (!strcmp (sCommandLine , " .fpt" ))
59
+ {
60
+ CleanFlightPlan ();
61
+ return true ;
62
+ }
63
+ if (!strcmp (sCommandLine , " .autodrop" ))
64
+ {
65
+ autoDrop = (autoDrop == 1 ? 0 : 1 );
66
+ SaveDataToSettings (SETTING_AUTODROP, " Drop Track for landing AC" , (autoDrop == 1 ? " 1" : " 0" ));
67
+ if (autoDrop == 1 )
68
+ DisplayMessage (" AutoDrop ON" , " Info" );
69
+ else
70
+ DisplayMessage (" AutoDrop OFF" , " Info" );
71
+ return true ;
72
+ }
73
+ return false ;
74
+ }
75
+
90
76
void CESTrackFunctions::OnFunctionCall (int FunctionId, const char * sItemString , POINT Pt, RECT Area)
91
77
{
92
- PostDebugMessage (sItemString );
93
78
if (FunctionId == ITEM_FUNCTION_CLEAN_FP)
94
- CleanFlightPlan (FlightPlanSelectASEL () );
79
+ CleanFlightPlan ();
95
80
}
96
81
82
+ void CESTrackFunctions::OnTimer (int Counter)
83
+ {
84
+ if (!ControllerMyself ().IsValid () || !ControllerMyself ().IsController ())
85
+ return ;
86
+ if (GetConnectionType () != EuroScopePlugIn::CONNECTION_TYPE_DIRECT)
87
+ return ;
88
+ if (autoDrop)
89
+ {
90
+ for (auto flightplan = FlightPlanSelectFirst ();
91
+ flightplan.IsValid ();
92
+ flightplan = FlightPlanSelectNext (flightplan))
93
+ {
94
+ if (flightplan.GetSimulated ()) continue ;
95
+ if (CheckDrop (flightplan))
96
+ flightplan.EndTracking ();
97
+ }
98
+ }
99
+ }
0 commit comments