-
Notifications
You must be signed in to change notification settings - Fork 2
/
gui.cpp
92 lines (83 loc) · 2.75 KB
/
gui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <string>
#include <stdio.h>
#include <map>
#include <cstdlib>
#include <cstring>
#include <stdint.h>
#include "include/SDK/XPLMDisplay.h"
#include "include/SDK/XPLMUtilities.h"
#include "include/SDK/XPLMDataAccess.h"
#include "include/SDK/XPLMMenus.h"
#include "include/SDK/XPLMGraphics.h"
#include "include/SDK/XPWidgets.h"
#include "include/SDK/XPStandardWidgets.h"
#include "include/SDK/XPLMDefs.h"
#include "include/gui.h"
#include "include/gui_mfd.h"
#include "include/gui_fms_option.h"
#include "include/gui_fms_status.h"
using namespace std;
using std::map;
using std::string;
static XPLMMenuID myMenu;
static int mySubMenuItem;
static int a_menu_created;
static int a_fms_status_page;
static fms_t* a_fms_ref;
static config_t* a_config_ref;
static mfdpages_t* a_mfdpages_ref;
static out_t* a_out_ref;
static gui_mfd_t* gui_mfd_ref;
static gui_fms_option_t* gui_fms_option_ref;
static gui_fms_status_t* gui_fms_status_ref;
gui_t::gui_t(void)
{
}
gui_t::gui_t(mfdpages_t* mfdpages,fms_t* fms_ref,out_t* out_ref){
a_fms_ref = fms_ref;
a_mfdpages_ref = mfdpages;
a_out_ref = out_ref;
a_config_ref = config_t::getInstance();
a_menu_created = 0;
gui_mfd_ref = new gui_mfd_t(a_out_ref);
gui_fms_option_ref = new gui_fms_option_t(a_config_ref,a_fms_ref);
gui_fms_status_ref = new gui_fms_status_t(a_config_ref,a_fms_ref);
}
gui_t::~gui_t(void) {
disable();
}
// enagle the UI
void gui_t::enable(void) {
// Create a Custom Menu within the Plugin Menu
if (a_menu_created == 0) mySubMenuItem = XPLMAppendMenuItem(XPLMFindPluginsMenu(), "X-Control Enhanced", 0, 1);
myMenu = XPLMCreateMenu("X-Control Enhanced", XPLMFindPluginsMenu(), mySubMenuItem, menu_handler, 0);
a_fms_status_page = 0;
XPLMAppendMenuItem(myMenu,"FMS Settings",(void*)1,1);
XPLMAppendMenuSeparator(myMenu);
XPLMAppendMenuItem(myMenu,"Show FMS Status (CTRL+Shift+B)",(void*)2,1);
XPLMAppendMenuItem(myMenu,"Show Virtual MFD (CTRL+Shift+V)",(void*)3,1);
XPLMAppendMenuSeparator(myMenu);
XPLMAppendMenuItem(myMenu,"Reset the plugin",(void*)4,1);
a_menu_created = 1;
}
// disable the UI
void gui_t::disable(void) {
gui_fms_option_ref->disable();
gui_fms_status_ref->disable();
gui_mfd_ref->disable();
XPLMDestroyMenu(myMenu);
}
// handle the plugin menu events
void gui_t::menu_handler(void *inMenuRef, void *inItemRef) {
intptr_t menuItem = (intptr_t)inItemRef;
if(menuItem == 1) { // customize the FMS
gui_fms_option_ref->enable();
} else if(menuItem == 2) { // Show FMS status
gui_fms_status_ref->enable();
} else if(menuItem == 3) { // Show the MFD
gui_mfd_ref->enable();
} else if(menuItem == 4) { // reset the plugin
a_fms_ref->reset(); // reset the FMS
a_mfdpages_ref->load(); // recreate the MFD pages
}
}