forked from 400plus/400plus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu_cmodes.c
163 lines (132 loc) · 4.76 KB
/
menu_cmodes.c
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <vxworks.h>
#include "firmware.h"
#include "macros.h"
#include "main.h"
#include "cmodes.h"
#include "display.h"
#include "languages.h"
#include "menu.h"
#include "menupage.h"
#include "menuitem.h"
#include "menu_rename.h"
#include "menu_settings.h"
#include "utils.h"
#include "intercom.h"
#include "menu_cmodes.h"
void menu_cmodes_open(menu_t *menu);
void menu_cmodes_save (const menuitem_t *item);
void menu_cmodes_load (const menuitem_t *item);
void menu_cmodes_free (const menuitem_t *item);
void menu_cmodes_rename (const menuitem_t *item);
void menu_cmodes_delete (const menuitem_t *item);
// One sub-menu for each custom mode, and 3 / 4 items on each sub-menu
menuitem_t menupage_cmodes_subitems[CMODES_MAX][4];
menupage_t menupage_cmodes_submenus[CMODES_MAX];
menuitem_t menupage_cmodes_items[CMODES_MAX];
menupage_t menupage_cmodes = {
name : LP_WORD(L_P_CMODES),
sibilings : TRUE,
items : LIST(menupage_cmodes_items),
show_id : TRUE,
ordering : cmodes_config.order,
actions : {
[MENU_EVENT_OPEN] = menu_cmodes_open,
}
};
void menu_cmodes_open(menu_t *menu) {
int i, length;
int current_cmode = get_current_cmode();
menupage_cmodes.highlight = status.cmode_active;
menupage_cmodes.highlighted_item = current_cmode;
for (i = 0; i < CMODES_MAX; i++) {
if (AE_IS_AUTO(status.main_dial_ae)) {
if(status.cmode_active && i == current_cmode) {
length = 4;
// Current custom mode: create first item in sub-menu: UPDATE
menupage_cmodes_subitems[i][0].id = i;
menupage_cmodes_subitems[i][0].display = menuitem_display;
menupage_cmodes_subitems[i][0].name = LP_WORD(L_I_UPDATE);
menupage_cmodes_subitems[i][0].action = menu_cmodes_save;
// Current custom mode: create extra item in sub-menu: UNASSIGN
menupage_cmodes_subitems[i][3].id = i;
menupage_cmodes_subitems[i][3].display = menuitem_display;
menupage_cmodes_subitems[i][3].name = LP_WORD(L_I_UNASSIGN);
menupage_cmodes_subitems[i][3].action = menu_cmodes_free;
} else {
length = 3;
// Other custom mode: create first item in sub-menu: ASSIGN
menupage_cmodes_subitems[i][0].id = i;
menupage_cmodes_subitems[i][0].display = menuitem_display;
menupage_cmodes_subitems[i][0].name = LP_WORD(L_I_ASSIGN);
menupage_cmodes_subitems[i][0].action = menu_cmodes_load;
}
} else {
length = 3;
// Creative mode: create first item in sub-menu: SAVE
menupage_cmodes_subitems[i][0].id = i;
menupage_cmodes_subitems[i][0].display = menuitem_display;
menupage_cmodes_subitems[i][0].name = LP_WORD(L_I_SAVE);
menupage_cmodes_subitems[i][0].action = menu_cmodes_save;
}
// Create second item in sub-menu: RENAME
menupage_cmodes_subitems[i][1].id = i;
menupage_cmodes_subitems[i][1].display = menuitem_display;
menupage_cmodes_subitems[i][1].name = LP_WORD(L_I_RENAME);
menupage_cmodes_subitems[i][1].action = menu_cmodes_rename;
// Create third item in sub-menu: DELETE
menupage_cmodes_subitems[i][2].id = i;
menupage_cmodes_subitems[i][2].display = menuitem_display;
menupage_cmodes_subitems[i][2].name = LP_WORD(L_I_DELETE);
menupage_cmodes_subitems[i][2].action = menu_cmodes_delete;
// Configure sub-menu
menupage_cmodes_submenus[i].name = cmodes_config.names[i];
menupage_cmodes_submenus[i].items.size = length;
menupage_cmodes_submenus[i].items.data = menupage_cmodes_subitems[i];
menupage_cmodes_submenus[i].actions[MENU_EVENT_AV] = menu_return;
// Add sub-menu to page
menupage_cmodes_items[i].id = i;
menupage_cmodes_items[i].name = cmodes_config.names[i];
menupage_cmodes_items[i].display = menuitem_display_sub;
menupage_cmodes_items[i].inc = menuitem_inc_sub;
menupage_cmodes_items[i].action = menupage_cmodes_subitems[i][0].action;
menupage_cmodes_items[i].parm.menuitem_submenu.page = &menupage_cmodes_submenus[i];
}
}
void menu_cmodes_save(const menuitem_t *item) {
if (AE_IS_CREATIVE(status.main_dial_ae) || status.cmode_active)
if (cmode_write(item->id)) {
beep();
menu_close();
}
}
void menu_cmodes_load(const menuitem_t *item) {
snapshot_t cmode;
if (AE_IS_AUTO(status.main_dial_ae)) {
if (cmode_read(item->id, &cmode)) {
snapshot_recall(&cmode);
snapshot_apply (&cmode);
set_current_cmode(item->id);
beep();
menu_close();
cmodes_write();
}
}
}
void menu_cmodes_free(const menuitem_t *item) {
if (AE_IS_AUTO(status.main_dial_ae)) {
set_current_cmode(CMODE_NONE);
send_to_intercom(IC_SET_AE, status.main_dial_ae);
beep();
menu_close();
cmodes_write();
}
}
void menu_cmodes_rename(const menuitem_t *item) {
rename_create(cmodes_config.names[item->id]);
}
void menu_cmodes_delete(const menuitem_t *item) {
if (cmode_delete(item->id)) {
beep();
menu_close();
}
}