Skip to content

Commit 9767935

Browse files
committed
Fixed bug with stand item function not being called when triggered from outside the radar view
1 parent dbca5d5 commit 9767935

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

vSMR/SMRPlugin.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,22 @@ void CSMRPlugin::OnFunctionCall(int FunctionId, const char * sItemString, POINT
479479
----------------------------------------------------------------------------------------------- */
480480

481481
switch (FunctionId) {
482+
483+
case TAG_FUNC_STAND_EDIT: {
484+
CFlightPlan fp = FlightPlanSelectASEL();
485+
OpenPopupEdit(Area, TAG_FUNC_STAND_EDITOR, CSMRRadar::GetStandNumber(fp));
486+
CSMRRadar::onFunctionCallDoubleCallHack = true;
487+
break;
488+
}
489+
490+
case TAG_FUNC_STAND_EDITOR: { // when finished editing
491+
if (CSMRRadar::onFunctionCallDoubleCallHack) {
492+
CFlightPlan fp = FlightPlanSelectASEL();
493+
CSMRRadar::SetStandNumber(fp, sItemString);
494+
CSMRRadar::onFunctionCallDoubleCallHack = false;
495+
}
496+
break;
497+
}
482498

483499
case TAG_FUNC_DATALINK_MENU: {
484500
CFlightPlan FlightPlan = FlightPlanSelectASEL();

vSMR/SMRRadar.cpp

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ CPoint mouseLocation(0, 0);
1010
CBString TagBeingDragged;
1111

1212
int tagLineDefaultLength = 50;
13-
14-
bool onFunctionCallDoubleCallHack = false;
13+
bool onFunctionCallDoubleCallHack;
1514

1615
//
1716
// Cursor Things
@@ -35,6 +34,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
3534

3635
set<CBString> CSMRRadar::manuallyCorrelated;
3736
map<CBString, CBString> CSMRRadar::vStripsStands;
37+
bool CSMRRadar::onFunctionCallDoubleCallHack = false;
3838

3939

4040
map<int, CInsetWindow *> appWindows;
@@ -112,8 +112,6 @@ CSMRRadar::CSMRRadar()
112112
correlateCursor = CopyCursor((HCURSOR)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_SMRCORRELATE), IMAGE_CURSOR, 0, 0, LR_SHARED));
113113
mouseCursor = defaultCursor;
114114

115-
ActiveAirport = "LSZH";
116-
117115
// Setting up the data for the 2 approach windows
118116
appWindowDisplays[1] = false;
119117
appWindowDisplays[2] = false;
@@ -963,22 +961,7 @@ void CSMRRadar::OnFunctionCall(int FunctionId, const char * sItemString, POINT P
963961
not sure what the point would be or if it's any good either, just weird all around
964962
----------------------------------------------------------------------------------------------- */
965963

966-
967-
if (FunctionId == TAG_FUNC_STAND_EDIT) {
968-
CFlightPlan fp = GetPlugIn()->FlightPlanSelectASEL();
969-
GetPlugIn()->OpenPopupEdit(Area, TAG_FUNC_STAND_EDITOR, CSMRRadar::GetStandNumber(fp));
970-
onFunctionCallDoubleCallHack = true;
971-
}
972-
973-
else if (FunctionId == TAG_FUNC_STAND_EDITOR) { // when finished editing
974-
if (onFunctionCallDoubleCallHack) {
975-
CFlightPlan fp = GetPlugIn()->FlightPlanSelectASEL();
976-
CSMRRadar::SetStandNumber(fp, sItemString);
977-
onFunctionCallDoubleCallHack = false;
978-
}
979-
}
980-
981-
else if (FunctionId == TAG_FUNC_SCRATCHPAD_EDITOR) { // when finished editing
964+
if (FunctionId == TAG_FUNC_SCRATCHPAD_EDITOR) { // when finished editing
982965
if (onFunctionCallDoubleCallHack) {
983966
CFlightPlan fp = GetPlugIn()->FlightPlanSelectASEL();
984967
fp.GetControllerAssignedData().SetScratchPadString(sItemString);
@@ -988,6 +971,7 @@ void CSMRRadar::OnFunctionCall(int FunctionId, const char * sItemString, POINT P
988971

989972
else if (FunctionId == RIMCAS_ACTIVE_AIRPORT_FUNC) {
990973
ActiveAirport = sItemString;
974+
ActiveAirport.toupper();
991975
LoadProfile(CurrentConfig->getActiveProfile()["name"].GetString());
992976
ReloadActiveRunways();
993977
SaveDataToAsr("Airport", "Active airport", ActiveAirport);
@@ -1804,9 +1788,9 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
18041788
return;
18051789
*/
18061790

1807-
for (int tt = 0; tt < 100000; tt++) {
1791+
//for (int tt = 0; tt < 100000; tt++) {
18081792
// Memory leak checker, put whatever you think might leak here and monitor RAM
1809-
}
1793+
//}
18101794

18111795

18121796
Logger::info(__FUNCSIG__);
@@ -2566,7 +2550,7 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
25662550
// First we need to figure out the tag size
25672551
RectF mesureRect;
25682552
graphics->MeasureString(L" ", wcslen(L" "), customFont, PointF(0, 0), stformat, &mesureRect);
2569-
auto blankWidth = mesureRect.GetRight();
2553+
auto blankWidth = mesureRect.GetRight()*(REAL)0.8;
25702554

25712555
// default font size
25722556
mesureRect = RectF(0, 0, 0, 0);
@@ -2643,8 +2627,8 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
26432627
}
26442628
lineWidth += mesureRect.GetRight();
26452629

2646-
if (j != line.Size() - 1) {
2647-
//lineWidth += blankWidth;
2630+
if (j != line.Size() - 1 && i != 0) {
2631+
lineWidth += blankWidth;
26482632
}
26492633
}
26502634
lineWidth += TAG_PADDING_RIGHT;
@@ -2782,10 +2766,12 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
27822766

27832767
// Draw tag text and clickable zones
27842768
Gdiplus::REAL heightOffset = TAG_PADDING_TOP;
2785-
for (auto&& line : ReplacedLabelLines) {
2769+
for (unsigned int i = 0; i < ReplacedLabelLines.size(); i++) {
27862770

2771+
auto line = ReplacedLabelLines[i];
27872772
Gdiplus::REAL widthOffset = TAG_PADDING_LEFT;
2788-
for (auto&& tagItem : line) {
2773+
for (unsigned int j = 0; j < line.size(); j++) {
2774+
auto tagItem = line[j];
27892775
SolidBrush* color = &FontColor;
27902776
if (TagMap["sqerror"].value.length() > 0 && tagItem.value == TagMap["sqerror"].value)
27912777
color = &SquawkErrorColor;
@@ -2808,9 +2794,7 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
28082794
widthOffset -= blankWidth; // We don't want a space between the callsign and the comm type if it's there
28092795
}
28102796

2811-
if (heightOffset == TAG_PADDING_TOP) { // first line
2812-
heightOffset;
2813-
2797+
if (i == 0) { // first line
28142798
graphics->DrawString(welement.c_str(), wcslen(welement.c_str()), &firstLineFont,
28152799
PointF(Gdiplus::REAL(TagBackgroundRect.left) + widthOffset, Gdiplus::REAL(TagBackgroundRect.top) + heightOffset),
28162800
stformat, color);
@@ -2832,10 +2816,14 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
28322816

28332817
AddScreenObject(tagItem.function, rt.GetCallsign(), ItemRect, true, GetBottomLine(rt.GetCallsign()));
28342818

2835-
widthOffset += mRect.GetRight();
2819+
widthOffset += mRect.GetRight();
2820+
2821+
if (j != line.size() - 1 && i != 0) {
2822+
widthOffset += blankWidth;
2823+
}
28362824
}
28372825

2838-
if (heightOffset == TAG_PADDING_TOP) {
2826+
if (i == 0) {
28392827
heightOffset += firstLineHeight;
28402828
}
28412829
else {

vSMR/SMRRadar.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ template <class T> void SafeRelease(T **ppT)
6767
#define SCRATCHPAD_EMPTY_SPACES " "
6868

6969
namespace SMRPluginSharedData {
70-
static asio::io_service io_service;
70+
static asio::io_service io_service;
7171
}
7272

7373
//using namespace SMRSharedData;
@@ -81,6 +81,7 @@ class CSMRRadar :
8181

8282
static set<CBString> manuallyCorrelated;
8383
static map<CBString, CBString> vStripsStands;
84+
static bool onFunctionCallDoubleCallHack;
8485

8586
bool BLINK = false;
8687

0 commit comments

Comments
 (0)