source: trunk/core/gui.c @ 698

Revision 698, 122.2 KB checked in by phyrephox, 4 years ago (diff)

for strobists:
+ option to manually override flash (for all cameras). even for ixus cams. no need for a script anymore.
important: when enabled, this will not only override flash power, but also enable the CHECK if flash is needed. in other words: your camera will use flash even in bright sunlight and even if you disabled the flash. of course the flash will not fire on cameras with popup flashs when the flash is not popped up. there are three values for the flash to be set: low, middle and POWERFUL. be careful, dont flash at home, kids.
For cameras with dedicated movie buttons, there is an extra menu item: force flash only in moviemode. when this is checked, the flash will be forced only when recording a video.

todo: do flash ev correction for cams that dont support it and also maybe DISABLE flash for cams that cannot disable it (on s5is when flash is popped up, it is ALWAYS enabled, the flash button doesnt do anything for example... also maybe for those situations you are in a church or a museum where flash is absolutely forbidden...)

feature more or less created by ewavr, thanks

  • makefile: small edit (thx to ewavr)
  • Property svn:eol-style set to native
Line 
1#include "stdlib.h"
2#include "platform.h"
3#include "core.h"
4#include "keyboard.h"
5#include "conf.h"
6#include "camera.h"
7#include "ubasic.h"
8#include "font.h"
9#include "lang.h"
10#include "gui.h"
11#include "gui_lang.h"
12#include "gui_draw.h"
13#include "gui_menu.h"
14#include "gui_palette.h"
15#include "gui_mbox.h"
16#include "gui_mpopup.h"
17#include "gui_reversi.h"
18#include "gui_sokoban.h"
19#include "gui_4wins.h"
20#include "gui_mastermind.h"
21#ifdef OPT_DEBUGGING
22#include "gui_debug.h"
23#endif
24#include "gui_fselect.h"
25#include "gui_batt.h"
26#include "gui_space.h"
27#include "gui_osd.h"
28#ifdef OPT_TEXTREADER
29        #include "gui_read.h"
30#endif
31#ifdef OPT_CALENDAR
32        #include "gui_calendar.h"
33#endif
34#ifdef OPT_DEBUGGING
35#include "gui_bench.h"
36#endif
37#include "gui_grid.h"
38#include "histogram.h"
39#include "script.h"
40#include "motion_detector.h"
41#include "raw.h"
42#ifdef OPT_CURVES
43        #include "curves.h"
44#endif
45#include "edgeoverlay.h"
46//-------------------------------------------------------------------
47
48#define OPTIONS_AUTOSAVE
49#define SPLASH_TIME               20
50
51int script_params_has_changed=0;
52//shortcuts
53//------------------------------------------------------------------
54// #define KEY_NONE (KEY_DUMMY+1)
55
56#if !CAM_HAS_ERASE_BUTTON
57//Alt mode
58 #define SHORTCUT_TOGGLE_RAW          KEY_DISPLAY
59 #define SHORTCUT_MF_TOGGLE           KEY_UP
60//Half press shoot button   
61 #define SHORTCUT_TOGGLE_HISTO        KEY_DOWN
62 #define SHORTCUT_TOGGLE_ZEBRA        KEY_MENU
63 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
64 #define SHORTCUT_DISABLE_OVERRIDES KEY_LEFT
65//Alt mode & Manual mode   
66 #define SHORTCUT_SET_INFINITY        KEY_DISPLAY
67 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
68 // For models without ZOOM_LEVER  (#if !CAM_HAS_ZOOM_LEVER)
69 // SHORTCUT_SET_INFINITY is not used
70 // KEY_DISPLAY is used for gui_subj_dist_override_koef_enum;
71 // KEY_LEFT/KEY_RIGHT is used for gui_subj_dist_override_value_enum (because of no separate ZOOM_IN/OUT)
72 
73#elif defined(CAMERA_g7) 
74//Alt mode
75 #define SHORTCUT_TOGGLE_RAW          KEY_ERASE
76//Half press shoot button   
77 #define SHORTCUT_TOGGLE_HISTO        KEY_DOWN
78 #define SHORTCUT_TOGGLE_ZEBRA        KEY_LEFT
79 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
80 #define SHORTCUT_DISABLE_OVERRIDES KEY_UP
81//Alt mode & Manual mode 
82 #define SHORTCUT_SET_INFINITY        KEY_UP
83 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
84
85#elif defined(CAMERA_sx100is)
86//Alt mode
87 #define SHORTCUT_TOGGLE_RAW          KEY_ERASE
88//Half press shoot button   
89 #define SHORTCUT_TOGGLE_HISTO        KEY_UP
90 #define SHORTCUT_TOGGLE_ZEBRA        KEY_DOWN
91 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
92 #define SHORTCUT_DISABLE_OVERRIDES KEY_LEFT
93//Alt mode & Manual mode 
94 #define SHORTCUT_SET_INFINITY        KEY_UP
95 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
96
97
98#else
99
100//Alt mode
101 #define SHORTCUT_TOGGLE_RAW          KEY_ERASE
102//Half press shoot button   
103 #define SHORTCUT_TOGGLE_HISTO        KEY_UP
104 #define SHORTCUT_TOGGLE_ZEBRA        KEY_LEFT
105 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
106 #define SHORTCUT_DISABLE_OVERRIDES KEY_DOWN
107//Alt mode & Manual mode 
108 #define SHORTCUT_SET_INFINITY        KEY_UP
109 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
110#endif
111
112
113// forward declarations
114//-------------------------------------------------------------------
115extern void dump_memory();
116
117static void gui_draw_osd();
118
119static void gui_draw_splash(char* logo, int logo_size);
120
121void user_menu_save();
122void user_menu_restore();
123// Menu procs
124//-------------------------------------------------------------------
125static void gui_show_build_info(int arg);
126static void gui_show_memory_info(int arg);
127static void gui_draw_palette(int arg);
128static void gui_draw_reversi(int arg);
129static void gui_draw_sokoban(int arg);
130static void gui_draw_4wins(int arg);
131static void gui_draw_mastermind(int arg);
132#ifdef OPT_DEBUGGING
133        static void gui_draw_debug(int arg);
134        static void gui_draw_bench(int arg);
135#endif
136static void gui_draw_fselect(int arg);
137static void gui_draw_osd_le(int arg);
138static void gui_load_script(int arg);
139static void gui_load_script_default(int arg);
140#ifdef OPT_TEXTREADER
141static void gui_draw_read(int arg);
142static void gui_draw_read_last(int arg);
143#endif
144static void gui_draw_load_menu_rbf(int arg);
145static void gui_draw_load_symbol_rbf(int arg);          //AKA
146#ifdef OPT_TEXTREADER
147        static void gui_draw_load_rbf(int arg);
148#endif
149#ifdef OPT_CALENDAR
150static void gui_draw_calendar(int arg);
151#endif
152static void gui_draw_load_lang(int arg);
153static void gui_menuproc_mkbootdisk(int arg);
154static void gui_menuproc_edge_save(int arg);
155static void gui_menuproc_edge_load(int arg);
156static void gui_menuproc_edge_free(int arg);
157#ifdef OPT_DEBUGGING
158void gui_compare_props(int arg);
159#endif
160#ifndef OPTIONS_AUTOSAVE
161static void gui_menuproc_save(int arg);
162#endif
163static void gui_menuproc_reset(int arg);
164static void gui_grid_lines_load(int arg);
165static void gui_raw_develop(int arg);
166#ifdef OPT_DEBUGGING
167static void gui_menuproc_break_card(int arg);
168#endif
169static void gui_menuproc_swap_patitons(int arg);
170static void gui_menuproc_reset_files(int arg);
171#ifdef OPT_CURVES
172        static void gui_load_curve_selected(const char *fn);
173        static void gui_load_curve(int arg);
174#endif
175static const char* gui_histo_show_enum(int change, int arg);
176static const char* gui_histo_mode_enum(int change, int arg);
177static const char* gui_temp_mode_enum(int change, int arg);
178static const char* gui_histo_layout_enum(int change, int arg);
179static const char* gui_zebra_mode_enum(int change, int arg);
180static const char* gui_zebra_draw_osd_enum(int change, int arg);
181static const char* gui_font_enum(int change, int arg);
182static const char* gui_raw_prefix_enum(int change, int arg);
183static const char* gui_raw_ext_enum(int change, int arg);
184static const char* gui_sub_batch_prefix_enum(int change, int arg);
185static const char* gui_sub_batch_ext_enum(int change, int arg);
186
187static const char* gui_raw_nr_enum(int change, int arg);
188static const char* gui_autoiso_shutter_enum(int change, int arg);
189#ifdef OPT_TEXTREADER
190        static const char* gui_reader_codepage_enum(int change, int arg);
191#endif
192static const char* gui_zoom_value_enum(int change, int arg);
193static const char* gui_show_values_enum(int change, int arg);
194static const char* gui_dof_show_value_enum(int change, int arg);
195#if CAM_ADJUSTABLE_ALT_BUTTON
196static const char* gui_alt_mode_button_enum(int change, int arg);
197#endif
198static const char* gui_alt_power_enum(int change, int arg);
199static const char* gui_video_mode_enum(int change, int arg);
200static const char* gui_fast_ev_step(int change, int arg);
201static const char* gui_video_bitrate_enum(int change, int arg);
202static const char* gui_tv_bracket_values_enum(int change, int arg);
203static const char* gui_av_bracket_values_enum(int change, int arg);
204static const char* gui_iso_bracket_koef_enum(int change, int arg);
205static const char* gui_subj_dist_bracket_koef_enum(int change, int arg);
206static const char* gui_bracket_type_enum(int change, int arg);
207static const char* gui_av_override_enum(int change, int arg);
208#if ZOOM_OVERRIDE
209static const char* gui_zoom_override_enum(int change, int arg);
210#endif
211static const char* gui_iso_override_koef_enum(int change, int arg);
212static const char* gui_tv_override_koef_enum(int change, int arg);
213static const char* gui_tv_override_value_enum(int change, int arg);
214static const char* gui_tv_enum_type_enum(int change, int arg);
215static const char* gui_subj_dist_override_value_enum(int change, int arg);
216static const char* gui_subj_dist_override_koef_enum(int change, int arg);
217/*
218static const char* gui_tv_exposure_order_enum(int change, int arg);
219static const char* gui_av_exposure_order_enum(int change, int arg);
220static const char* gui_iso_exposure_order_enum(int change, int arg);
221*/
222static const char* gui_nd_filter_state_enum(int change, int arg);
223//static const char* gui_tv_enum(int change, int arg);
224const char* gui_user_menu_show_enum(int change, int arg);
225static const char* gui_hide_osd_enum(int change, int arg);
226static const char* gui_show_clock_enum(int change, int arg);
227static const char* gui_clock_format_enum(int change, int arg);
228static const char* gui_clock_indicator_enum(int change, int arg);
229static const char* gui_clock_halfpress_enum(int change, int arg);
230static const char* gui_space_bar_enum(int change, int arg);
231static const char* gui_space_bar_size_enum(int change, int arg);
232static const char* gui_space_bar_width_enum(int change, int arg);
233static const char* gui_space_warn_type_enum(int change, int arg);
234static const char* gui_bad_pixel_enum(int change, int arg);
235static const char* gui_video_af_key_enum(int change, int arg);
236static const char* gui_show_movie_time(int change, int arg);
237static const char* gui_script_autostart_enum(int change, int arg);
238static const char* gui_script_param_set_enum(int change, int arg);
239static const char* gui_override_disable_enum(int change, int arg);
240#ifdef OPT_CURVES
241        static const char* gui_conf_curve_enum(int change, int arg);
242#endif
243#ifdef OPT_DEBUGGING
244        static const char* gui_debug_shortcut_enum(int change, int arg);
245        static const char* gui_debug_display_enum(int change, int arg);
246        static void gui_debug_shortcut(void);
247#endif
248void rinit();
249
250
251// Menu callbacks
252//-------------------------------------------------------------------
253static void cb_step_25();
254static void cb_perc();
255static void cb_volts();
256static void cb_space_perc();
257static void cb_space_mb();
258static void cb_battery_menu_change(unsigned int item);
259static void cb_zebra_restore_screen();
260static void cb_zebra_restore_osd();
261#if DNG_SUPPORT
262static void cb_change_dng();
263#endif
264#if defined (DNG_EXT_FROM)
265static void cb_change_dng_usb_ext();
266#endif
267
268// for memory info, duplicated from lowlevel
269extern const char _start,_end;
270
271#ifdef OPT_DEBUGGING
272static int debug_tasklist_start;
273static int debug_display_direction=1;
274#endif
275// Menu definition
276//-------------------------------------------------------------------
277static CMenuItem remote_submenu_items[] = {
278    {0x71,LANG_MENU_REMOTE_ENABLE,            MENUITEM_BOOL,                    &conf.remote_enable},
279    {0x0,LANG_MENU_SYNCHABLE_REMOTE,          MENUITEM_SEPARATOR },
280        {0x71,LANG_MENU_SYNCHABLE_REMOTE_ENABLE,  MENUITEM_BOOL,                    &conf.ricoh_ca1_mode            },   
281    {0x5c,LANG_MENU_SYNCH_ENABLE,             MENUITEM_BOOL,                    &conf.synch_enable              },   
282    {0x5c,LANG_MENU_SYNCH_DELAY_ENABLE,       MENUITEM_BOOL,                    &conf.synch_delay_enable        },   
283    {0x5c,LANG_MENU_SYNCH_DELAY_VALUE,        MENUITEM_INT|MENUITEM_F_UNSIGNED, &conf.synch_delay_value         },   
284    {0x5c,LANG_MENU_SYNCH_DELAY_COARSE_VALUE, MENUITEM_INT|MENUITEM_F_UNSIGNED, &conf.synch_delay_coarse_value  },   
285    {0x5c,LANG_MENU_REMOTE_ZOOM_ENABLE,       MENUITEM_BOOL,                    &conf.remote_zoom_enable        },
286    {0x5f,LANG_MENU_REMOTE_ZOOM_TIMEOUT,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.zoom_timeout, MENU_MINMAX(2,10)},
287    {0x51,LANG_MENU_BACK,                     MENUITEM_UP },
288    {0}
289};
290static CMenu remote_submenu = {0x86,LANG_MENU_REMOTE_PARAM_TITLE, NULL, remote_submenu_items };
291
292static CMenuItem script_submenu_items_top[] = {
293    {0x35,LANG_MENU_SCRIPT_LOAD,             MENUITEM_PROC,                      (int*)gui_load_script },
294    {0x5f,LANG_MENU_SCRIPT_DELAY,            MENUITEM_INT|MENUITEM_F_UNSIGNED,   &conf.script_shoot_delay },
295        // remote autostart
296        {0x5f,LANG_MENU_SCRIPT_AUTOSTART,               MENUITEM_ENUM,                                          (int*)gui_script_autostart_enum },
297
298#if CAM_REMOTE
299    {0x86,LANG_MENU_REMOTE_PARAM,            MENUITEM_SUBMENU,   (int*)&remote_submenu },
300        //{0x71,LANG_MENU_SCRIPT_REMOTE_ENABLE, MENUITEM_BOOL,                                          &conf.remote_enable},
301#endif
302    {0x5d,LANG_MENU_SCRIPT_DEFAULT_VAL,     MENUITEM_PROC,                      (int*)gui_load_script_default },
303    {0x5e,LANG_MENU_SCRIPT_PARAM_SET,     MENUITEM_ENUM,                         (int*)gui_script_param_set_enum },
304    {0x5c,LANG_MENU_SCRIPT_PARAM_SAVE,             MENUITEM_BOOL,                    &conf.script_param_save              },   
305    {0x0,(int)script_title,                 MENUITEM_SEPARATOR },
306//    {0x0,LANG_MENU_SCRIPT_CURRENT,          MENUITEM_SEPARATOR },
307//    {0x0,(int)script_title,                 MENUITEM_TEXT },
308//    {0x0,LANG_MENU_SCRIPT_PARAMS,           MENUITEM_SEPARATOR }
309};
310
311static CMenuItem script_submenu_items_bottom[] = {
312    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
313    {0}
314};
315
316static CMenuItem script_submenu_items[sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0])+SCRIPT_NUM_PARAMS+
317                               sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0])];
318static CMenu script_submenu = {0x27,LANG_MENU_SCRIPT_TITLE, NULL, script_submenu_items };
319
320
321static CMenuItem games_submenu_items[] = {
322#ifdef OPT_GAME_REVERSI
323    {0x38,LANG_MENU_GAMES_REVERSI,           MENUITEM_PROC,  (int*)gui_draw_reversi },
324#endif
325#ifdef OPT_GAME_SOKOBAN
326    {0x38,LANG_MENU_GAMES_SOKOBAN,           MENUITEM_PROC,  (int*)gui_draw_sokoban },
327#endif
328#ifdef OPT_GAME_CONNECT4
329    {0x38,LANG_MENU_GAMES_CONNECT4,             MENUITEM_PROC,  (int*)gui_draw_4wins },
330#endif
331#ifdef OPT_GAME_MASTERMIND
332    {0x38,LANG_MENU_GAMES_MASTERMIND,           MENUITEM_PROC,  (int*)gui_draw_mastermind },
333#endif
334    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
335    {0}
336};
337static CMenu games_submenu = {0x38,LANG_MENU_GAMES_TITLE, NULL, games_submenu_items };
338
339static CMenuItem autoiso_submenu_items[] = {
340    {0x5c,LANG_MENU_AUTOISO_ENABLED,          MENUITEM_BOOL,    &conf.autoiso_enable},
341    {0x5f,LANG_MENU_AUTOISO_MIN_SHUTTER,   MENUITEM_ENUM,    (int*)gui_autoiso_shutter_enum },
342    {0x5f,LANG_MENU_AUTOISO_USER_FACTOR,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_user_factor, MENU_MINMAX(1, 8)  },
343#if CAM_HAS_IS   
344    {0x5f,LANG_MENU_AUTOISO_IS_FACTOR,       MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_is_factor, MENU_MINMAX(1, 8)  },
345#endif   
346    {0x5f,LANG_MENU_AUTOISO_MAX_ISO_HI,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_max_iso_hi, MENU_MINMAX(20, 160)  },
347    {0x5f,LANG_MENU_AUTOISO_MAX_ISO_AUTO, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_max_iso_auto, MENU_MINMAX(10, 80)  },
348    {0x5f,LANG_MENU_AUTOISO_MIN_ISO,           MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_min_iso, MENU_MINMAX(1, 20)  },
349    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
350    {0}
351};
352static CMenu autoiso_submenu = {0x2d,LANG_MENU_AUTOISO_TITLE, NULL, autoiso_submenu_items };
353
354
355#ifdef OPT_TEXTREADER
356static CMenuItem reader_submenu_items[] = {
357    {0x35,LANG_MENU_READ_OPEN_NEW,           MENUITEM_PROC,    (int*)gui_draw_read },
358    {0x35,LANG_MENU_READ_OPEN_LAST,          MENUITEM_PROC,    (int*)gui_draw_read_last },
359    {0x35,LANG_MENU_READ_SELECT_FONT,        MENUITEM_PROC,    (int*)gui_draw_load_rbf },
360    {0x5f,LANG_MENU_READ_CODEPAGE,           MENUITEM_ENUM,    (int*)gui_reader_codepage_enum },
361    {0x5c,LANG_MENU_READ_WORD_WRAP,          MENUITEM_BOOL,    &conf.reader_wrap_by_words },
362    {0x5c,LANG_MENU_READ_AUTOSCROLL,         MENUITEM_BOOL,    &conf.reader_autoscroll },
363    {0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.reader_autoscroll_delay, MENU_MINMAX(0, 60) },
364    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
365    {0}
366};
367static CMenu reader_submenu = {0x37,LANG_MENU_READ_TITLE, NULL, reader_submenu_items };
368#endif
369
370#ifdef OPT_DEBUGGING
371static CMenuItem debug_submenu_items[] = {
372    {0x5c,LANG_MENU_DEBUG_DISPLAY,           MENUITEM_ENUM,          (int*)gui_debug_display_enum },
373    {0x2a,LANG_MENU_DEBUG_PROPCASE_PAGE,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &debug_propcase_page, MENU_MINMAX(0, 128) },
374    {0x2a,LANG_MENU_DEBUG_TASKLIST_START,    MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &debug_tasklist_start, MENU_MINMAX(0, 63) },
375    {0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS,    MENUITEM_BOOL,          &debug_vals_show },
376    {0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER,    MENUITEM_PROC,          (int*)gui_draw_debug },
377    {0x2a,LANG_MENU_DEBUG_BENCHMARK,         MENUITEM_PROC,          (int*)gui_draw_bench },
378    {0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION,   MENUITEM_ENUM,          (int*)gui_debug_shortcut_enum },
379    {0x5c,LANG_MENU_RAW_TIMER,               MENUITEM_BOOL,          &conf.raw_timer },
380#if CAM_MULTIPART
381    {0x33,LANG_MENU_DEBUG_CREATE_MULTIPART , MENUITEM_PROC,             (int*)gui_menuproc_break_card },
382#endif
383    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
384    {0}
385};
386static CMenu debug_submenu = {0x2a,LANG_MENU_DEBUG_TITLE, NULL, debug_submenu_items };
387#endif
388
389
390static CMenuItem misc_submenu_items[] = {
391    {0x35,LANG_MENU_MISC_FILE_BROWSER,       MENUITEM_PROC,    (int*)gui_draw_fselect },
392#ifdef OPT_CALENDAR
393    {0x36,LANG_MENU_MISC_CALENDAR,           MENUITEM_PROC,    (int*)gui_draw_calendar },
394#endif
395#ifdef OPT_TEXTREADER
396    {0x37,LANG_MENU_MISC_TEXT_READER,        MENUITEM_SUBMENU, (int*)&reader_submenu },
397#endif
398#if defined (OPT_GAME_REVERSI) || (OPT_GAME_SOKOBAN || (OPT_GAME_CONNECT4) || OPT_GAME_MASTERMIND)
399    {0x38,LANG_MENU_MISC_GAMES,              MENUITEM_SUBMENU, (int*)&games_submenu },
400#endif
401#if CAM_SWIVEL_SCREEN
402    {0x28,LANG_MENU_MISC_FLASHLIGHT,         MENUITEM_BOOL,    &conf.flashlight },
403#endif
404    {0x5c,LANG_MENU_MISC_SHOW_SPLASH,        MENUITEM_BOOL,    &conf.splash_show },
405                {0x5c,LANG_MENU_MISC_START_SOUND,        MENUITEM_BOOL,    &conf.start_sound },
406#if CAM_USE_ZOOM_FOR_MF
407    {0x59,LANG_MENU_MISC_ZOOM_FOR_MF,        MENUITEM_BOOL,    &conf.use_zoom_mf },
408#endif
409#if CAM_ADJUSTABLE_ALT_BUTTON
410    {0x22,LANG_MENU_MISC_ALT_BUTTON,         MENUITEM_ENUM,    (int*)gui_alt_mode_button_enum },
411#endif
412    {0x5d,LANG_MENU_MISC_DISABLE_LCD_OFF,    MENUITEM_ENUM,    (int*)gui_alt_power_enum },
413    {0x65,LANG_MENU_MISC_PALETTE,            MENUITEM_PROC,    (int*)gui_draw_palette },
414    {0x80,LANG_MENU_MISC_BUILD_INFO,         MENUITEM_PROC,    (int*)gui_show_build_info },
415    {0x80,LANG_MENU_MISC_MEMORY_INFO,        MENUITEM_PROC,    (int*)gui_show_memory_info },
416    {0x33,LANG_MENU_DEBUG_MAKE_BOOTABLE,     MENUITEM_PROC,    (int*)gui_menuproc_mkbootdisk },
417#if CAM_MULTIPART
418    {0x33,LANG_MENU_DEBUG_SWAP_PART,         MENUITEM_PROC,             (int*)gui_menuproc_swap_patitons },
419#endif
420    {0x2b,LANG_MENU_MAIN_RESET_OPTIONS,      MENUITEM_PROC,      (int*)gui_menuproc_reset },
421#ifdef OPT_DEBUGGING
422    {0x2a,LANG_MENU_MAIN_DEBUG,              MENUITEM_SUBMENU,   (int*)&debug_submenu },
423#endif
424    {0x86,LANG_MENU_REMOTE_PARAM,            MENUITEM_SUBMENU,   (int*)&remote_submenu },
425#if defined (DNG_EXT_FROM)
426    {0x71,LANG_MENU_DNG_VIA_USB,        MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.dng_usb_ext , (int)cb_change_dng_usb_ext},
427#endif
428    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
429    {0},
430};
431static CMenu misc_submenu = {0x29,LANG_MENU_MISC_TITLE, NULL, misc_submenu_items };
432
433static int voltage_step;
434static CMenuItem battery_submenu_items[] = {
435    {0x66,LANG_MENU_BATT_VOLT_MAX,           MENUITEM_INT|MENUITEM_ARG_ADDR_INC,     &conf.batt_volts_max,   (int)&voltage_step },
436    {0x67,LANG_MENU_BATT_VOLT_MIN,           MENUITEM_INT|MENUITEM_ARG_ADDR_INC,     &conf.batt_volts_min,   (int)&voltage_step },
437    {0x68,LANG_MENU_BATT_STEP_25,            MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.batt_step_25,     (int)cb_step_25 },
438    {0x0,(int)"",                           MENUITEM_SEPARATOR },
439    {0x73,LANG_MENU_BATT_SHOW_PERCENT,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.batt_perc_show,   (int)cb_perc },
440    {0x73,LANG_MENU_BATT_SHOW_VOLTS,         MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.batt_volts_show,  (int)cb_volts },
441    {0x32,LANG_MENU_BATT_SHOW_ICON,          MENUITEM_BOOL,                          &conf.batt_icon_show },   
442    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
443    {0}
444};
445static CMenu battery_submenu = {0x32,LANG_MENU_BATT_TITLE, cb_battery_menu_change, battery_submenu_items };
446
447static CMenuItem space_submenu_items[] = {
448    {0x5c,LANG_MENU_SPACE_SHOW_ICON,         MENUITEM_BOOL,                          &conf.space_icon_show },
449    {0x69,LANG_MENU_SPACE_SHOW_BAR,      MENUITEM_ENUM,                       (int*)gui_space_bar_enum },
450    {0x6a,LANG_MENU_SPACE_BAR_SIZE,      MENUITEM_ENUM,                       (int*)gui_space_bar_size_enum }, 
451    {0x6b,LANG_MENU_SPACE_BAR_WIDTH,      MENUITEM_ENUM,                       (int*)gui_space_bar_width_enum },
452    {0x5c,LANG_MENU_SPACE_SHOW_PERCENT,      MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.space_perc_show,   (int)cb_space_perc },
453    {0x5c,LANG_MENU_SPACE_SHOW_MB,           MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.space_mb_show,  (int)cb_space_mb },
454    {0x5f,LANG_MENU_SPACE_WARN_TYPE,      MENUITEM_ENUM,                       (int*)gui_space_warn_type_enum },
455    {0x58,LANG_MENU_SPACE_WARN_PERCENT,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &conf.space_perc_warn, MENU_MINMAX(1, 99) },
456    {0x58,LANG_MENU_SPACE_WARN_MB,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &conf.space_mb_warn, MENU_MINMAX(1, 4000) },
457    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
458    {0}
459};
460static CMenu space_submenu = {0x33,LANG_MENU_OSD_SPACE_PARAMS_TITLE, NULL, space_submenu_items};
461
462static CMenuItem dof_submenu_items[] = {
463          {0x5f,LANG_MENU_OSD_SHOW_DOF_CALC,            MENUITEM_ENUM,      (int*)gui_dof_show_value_enum },
464          {0x5c,LANG_MENU_DOF_SUBJ_DIST_AS_NEAR_LIMIT,  MENUITEM_BOOL,      &conf.dof_subj_dist_as_near_limit},
465          {0x5c,LANG_MENU_DOF_USE_EXIF_SUBJ_DIST,       MENUITEM_BOOL,      &conf.dof_use_exif_subj_dist},       
466          {0x5c,LANG_MENU_DOF_SUBJ_DIST_IN_MISC,        MENUITEM_BOOL,      &conf.dof_subj_dist_in_misc},       
467          {0x5c,LANG_MENU_DOF_NEAR_LIMIT_IN_MISC,       MENUITEM_BOOL,      &conf.dof_near_limit_in_misc},     
468      {0x5c,LANG_MENU_DOF_FAR_LIMIT_IN_MISC,        MENUITEM_BOOL,                       &conf.dof_far_limit_in_misc}, 
469      {0x5c,LANG_MENU_DOF_HYPERFOCAL_IN_MISC,       MENUITEM_BOOL,      &conf.dof_hyperfocal_in_misc},                         
470      {0x5c,LANG_MENU_DOF_DEPTH_LIMIT_IN_MISC,      MENUITEM_BOOL,      &conf.dof_depth_in_misc},                       
471#if !CAM_DRYOS
472      {0x5c,LANG_MENU_DOF_DIST_FROM_LENS,           MENUITEM_BOOL,      &conf.dof_dist_from_lens},                     
473#endif     
474          {0x51,LANG_MENU_BACK,                            MENUITEM_UP },
475    {0}
476};
477static CMenu dof_submenu = {0x31,LANG_MENU_DOF_TITLE, /*cb_dof_menu_change*/ NULL, dof_submenu_items };
478
479static CMenuItem values_submenu_items[] = {
480          {0x5f,LANG_MENU_OSD_SHOW_MISC_VALUES,           MENUITEM_ENUM,      (int*)gui_show_values_enum },
481         // {0x43,LANG_MENU_VALUES_SHOW_IN_REVIEW,   MENUITEM_BOOL,      &conf.values_show_in_review},
482          {0x5c,LANG_MENU_SHOW_VALUES_IN_VIDEO,           MENUITEM_BOOL,      &conf.show_values_in_video},
483          {0x5c,LANG_MENU_VALUES_SHOW_ZOOM,               MENUITEM_BOOL,      &conf.values_show_zoom}, 
484          {0x5f,LANG_MENU_OSD_ZOOM_VALUE,                 MENUITEM_ENUM,      (int*)gui_zoom_value_enum },     
485          {0x60,LANG_MENU_OSD_ZOOM_SCALE,                 MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zoom_scale,   MENU_MINMAX(0, 1000)},       
486      {0x62,LANG_MENU_VALUES_SHOW_REAL_APERTURE,      MENUITEM_BOOL,      &conf.values_show_real_aperture},             
487      {0x74,LANG_MENU_VALUES_SHOW_REAL_ISO,           MENUITEM_BOOL,      &conf.values_show_real_iso},                 
488      {0x74,LANG_MENU_VALUES_SHOW_MARKET_ISO,         MENUITEM_BOOL,      &conf.values_show_market_iso},                               
489          {0x2d,LANG_MENU_SHOW_ISO_ONLY_IN_AUTOISO_MODE,  MENUITEM_BOOL,             &conf.values_show_iso_only_in_autoiso_mode},                       
490      {0x5c,LANG_MENU_VALUES_SHOW_EV_SETED,                      MENUITEM_BOOL,      &conf.values_show_ev_seted},
491      {0x5c,LANG_MENU_VALUES_SHOW_EV_MEASURED,        MENUITEM_BOOL,             &conf.values_show_ev_measured},                               
492      {0x5c,LANG_MENU_VALUES_SHOW_BV_SETED,                      MENUITEM_BOOL,      &conf.values_show_bv_seted},                                       
493      {0x5c,LANG_MENU_VALUES_SHOW_BV_MEASURED,           MENUITEM_BOOL,      &conf.values_show_bv_measured},                                   
494      {0x5c,LANG_MENU_VALUES_SHOW_OVEREXPOSURE,      MENUITEM_BOOL,      &conf.values_show_overexposure},       
495      {0x5c,LANG_MENU_SHOW_CANON_OVEREXPOSURE,       MENUITEM_BOOL,      &conf.values_show_canon_overexposure},                                                 
496      {0x5c,LANG_MENU_VALUES_SHOW_LUMINANCE,         MENUITEM_BOOL,      &conf.values_show_luminance},                                                 
497          {0x51,LANG_MENU_BACK,                           MENUITEM_UP },
498    {0}
499};
500static CMenu values_submenu = {0x28,LANG_MENU_OSD_VALUES_TITLE, /*cb_values_menu_change*/ NULL, values_submenu_items };
501
502static CMenuItem clock_submenu_items[] = {
503    {0x5f,LANG_MENU_OSD_SHOW_CLOCK,          MENUITEM_ENUM,      (int*)gui_show_clock_enum },
504    {0x6d,LANG_MENU_OSD_CLOCK_FORMAT,          MENUITEM_ENUM,      (int*)gui_clock_format_enum },
505    {0x6c,LANG_MENU_OSD_CLOCK_INDICATOR,          MENUITEM_ENUM,      (int*)gui_clock_indicator_enum },
506    {0x6e,LANG_MENU_OSD_CLOCK_HALFPRESS,          MENUITEM_ENUM,      (int*)gui_clock_halfpress_enum },
507    {0x51,LANG_MENU_BACK,                           MENUITEM_UP },
508    {0}
509};
510static CMenu clock_submenu = {0x34,LANG_MENU_OSD_CLOCK_PARAMS_TITLE, NULL, clock_submenu_items };
511
512
513static CMenuItem video_submenu_items[] = {
514          {0x23,LANG_MENU_VIDEO_MODE,              MENUITEM_ENUM,    (int*)gui_video_mode_enum},
515      {0x5e,LANG_MENU_VIDEO_BITRATE,           MENUITEM_ENUM,    (int*)gui_video_bitrate_enum},
516      {0x60,LANG_MENU_VIDEO_QUALITY,           MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.video_quality, MENU_MINMAX(1, 99)},
517      {0x5c,LANG_MENU_CLEAR_VIDEO_VALUES,    MENUITEM_BOOL,    (int*)&conf.clear_video},
518#if CAM_VIDEO_CONTROL
519      {0x5c,LANG_MENU_FAST_SWITCH_VIDEO,   MENUITEM_BOOL,  &conf.fast_movie_control},
520#endif
521#if CAM_CHDK_HAS_EXT_VIDEO_MENU
522      {0x5c,LANG_MENU_FAST_SWITCH_QUALITY_VIDEO,   MENUITEM_BOOL,  &conf.fast_movie_quality_control},
523#endif
524#if CAM_CAN_UNLOCK_OPTICAL_ZOOM_IN_VIDEO
525      {0x5c,LANG_MENU_OPTICAL_ZOOM_IN_VIDEO,   MENUITEM_BOOL,  &conf.unlock_optical_zoom_for_video},                                                   
526#endif
527#if CAM_CAN_MUTE_MICROPHONE
528      {0x83,LANG_MENU_MUTE_ON_ZOOM,   MENUITEM_BOOL,  &conf.mute_on_zoom},
529#endif
530#if CAM_AF_SCAN_DURING_VIDEO_RECORD
531      {0x82,LANG_MENU_VIDEO_AF_KEY,   MENUITEM_ENUM,    (int*)gui_video_af_key_enum},
532#endif
533                {0x5c,LANG_MENU_OSD_SHOW_VIDEO_TIME,         MENUITEM_ENUM,      (int*)gui_show_movie_time },
534    {0x60,LANG_MENU_OSD_SHOW_VIDEO_REFRESH,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.show_movie_refresh,   MENU_MINMAX(1, 20)},
535      {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
536      {0}
537};
538static CMenu video_submenu = {0x23,LANG_MENU_VIDEO_PARAM_TITLE, NULL, video_submenu_items };
539
540static CMenuItem bracketing_in_continuous_submenu_items[] = {
541          {0x63,LANG_MENU_TV_BRACKET_VALUE,             MENUITEM_ENUM,    (int*)gui_tv_bracket_values_enum },
542#if CAM_HAS_IRIS_DIAPHRAGM
543          {0x62,LANG_MENU_AV_BRACKET_VALUE,             MENUITEM_ENUM,    (int*)gui_av_bracket_values_enum },
544#endif   
545#if CAM_CAN_SD_OVERRIDE
546          {0x5e,LANG_MENU_SUBJ_DIST_BRACKET_VALUE,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.subj_dist_bracket_value, MENU_MINMAX(0, 100)},
547          {0x5f,LANG_MENU_SUBJ_DIST_BRACKET_KOEF,       MENUITEM_ENUM,    (int*)gui_subj_dist_bracket_koef_enum},
548#endif   
549          {0x74,LANG_MENU_ISO_BRACKET_VALUE,            MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.iso_bracket_value, MENU_MINMAX(0, 100)},
550          {0x5f,LANG_MENU_ISO_BRACKET_KOEF,             MENUITEM_ENUM,    (int*)gui_iso_bracket_koef_enum},
551          {0x60,LANG_MENU_BRACKET_TYPE,                 MENUITEM_ENUM,    (int*)gui_bracket_type_enum },
552          {0x5b,LANG_MENU_CLEAR_BRACKET_VALUES,        MENUITEM_BOOL,        (int*)&conf.clear_bracket},
553     {0x5c,LANG_MENU_BRACKETING_ADD_RAW_SUFFIX,                MENUITEM_BOOL,      &conf.bracketing_add_raw_suffix },
554      {0x51,LANG_MENU_BACK,                         MENUITEM_UP },
555      {0}
556};
557static CMenu bracketing_in_continuous_submenu = {0x2c,LANG_MENU_BRACKET_IN_CONTINUOUS_TITLE, NULL, bracketing_in_continuous_submenu_items };
558
559
560/*
561static CMenuItem exposure_submenu_items[] = {
562          {0x59,LANG_MENU_RECALC_EXPOSURE,         MENUITEM_BOOL,    &conf.recalc_exposure},
563          {0x63,LANG_MENU_TV_EXPOSURE_ORDER,       MENUITEM_ENUM,    (int*)gui_tv_exposure_order_enum},
564          {0x62,LANG_MENU_AV_EXPOSURE_ORDER,       MENUITEM_ENUM,    (int*)gui_av_exposure_order_enum},
565          {0x74,LANG_MENU_ISO_EXPOSURE_ORDER,      MENUITEM_ENUM,    (int*)gui_iso_exposure_order_enum},
566          {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
567      {0}
568};
569static CMenu exposure_submenu = {0x2a,LANG_MENU_EXPOSURE_TITLE, NULL, exposure_submenu_items };
570*/
571
572static CMenuItem operation_submenu_items[] = {
573      {0x5c,LANG_MENU_OVERRIDE_DISABLE,         MENUITEM_ENUM,    (int*)gui_override_disable_enum},//&conf.override_disable }, 
574      {0x5c,LANG_MENU_OVERRIDE_DISABLE_ALL,     MENUITEM_BOOL,    &conf.override_disable_all },
575          {0x61,LANG_MENU_OVERRIDE_TV_VALUE,        MENUITEM_ENUM,    (int*)gui_tv_override_value_enum},
576          {0x5f,LANG_MENU_OVERRIDE_TV_KOEF,         MENUITEM_ENUM,    (int*)gui_tv_override_koef_enum},
577          {0x59,LANG_MENU_TV_ENUM_TYPE,             MENUITEM_ENUM,    (int*)gui_tv_enum_type_enum},
578#if CAM_HAS_IRIS_DIAPHRAGM
579          {0x62,LANG_MENU_OVERRIDE_AV_VALUE,        MENUITEM_ENUM,    (int*)gui_av_override_enum },
580#endif   
581#if CAM_HAS_ND_FILTER
582      {0x62,LANG_MENU_OVERRIDE_ND_FILTER,       MENUITEM_ENUM,    (int*)gui_nd_filter_state_enum },
583#endif     
584#if CAM_CAN_SD_OVERRIDE 
585      {0x5e,LANG_MENU_OVERRIDE_SUBJ_DIST_VALUE, MENUITEM_ENUM,    (int*)gui_subj_dist_override_value_enum},
586          {0x5f,LANG_MENU_OVERRIDE_SUBJ_DIST_KOEF,  MENUITEM_ENUM,    (int*)gui_subj_dist_override_koef_enum},
587#endif   
588          {0x74,LANG_MENU_OVERRIDE_ISO_VALUE,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.iso_override_value, MENU_MINMAX(0, 800)},
589          {0x5f,LANG_MENU_OVERRIDE_ISO_KOEF,        MENUITEM_ENUM,    (int*)gui_iso_override_koef_enum},
590#if ZOOM_OVERRIDE
591    {0x5c,LANG_MENU_OVERRIDE_ZOOM,         MENUITEM_BOOL,    &conf.zoom_override},
592    {0x5f,LANG_MENU_OVERRIDE_ZOOM_VALUE,          MENUITEM_ENUM,    (int*)gui_zoom_override_enum },   
593         
594          {0x5c,LANG_MENU_CLEAR_ZOOM_OVERRIDE_VALUES,    MENUITEM_BOOL,    (int*)&conf.clear_zoom_override},
595#endif
596          {0x2c,LANG_MENU_BRACKET_IN_CONTINUOUS,           MENUITEM_SUBMENU, (int*)&bracketing_in_continuous_submenu },
597          {0x2d,LANG_MENU_AUTOISO,                  MENUITEM_SUBMENU, (int*)&autoiso_submenu },
598      //{LANG_MENU_EXPOSURE,               MENUITEM_SUBMENU, (int*)&exposure_submenu },
599          {0x5b,LANG_MENU_CLEAR_OVERRIDE_VALUES,    MENUITEM_BOOL,    (int*)&conf.clear_override},
600 
601      {0x5c,LANG_MENU_MISC_FAST_EV,         MENUITEM_BOOL,    &conf.fast_ev },
602      {0x5f,LANG_MENU_MISC_FAST_EV_STEP,    MENUITEM_ENUM,    (int*)gui_fast_ev_step },
603#if CAM_REAR_CURTAIN
604      {0x5c, LANG_MENU_REAR_CURTAIN, MENUITEM_BOOL, &conf.flash_sync_curtain },
605#endif
606          {0x5c, LANG_MENU_FLASH_MANUAL_OVERRIDE, MENUITEM_BOOL,   &conf.flash_manual_override},
607    {0x5f, LANG_MENU_FLASH_VIDEO_OVERRIDE_POWER,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.flash_video_override_power, MENU_MINMAX(0, 2)},
608#if CAM_HAS_VIDEO_BUTTON
609    {0x5c, LANG_MENU_FLASH_VIDEO_OVERRIDE, MENUITEM_BOOL,   &conf.flash_video_override},
610#endif
611
612    {0x51,LANG_MENU_BACK,                     MENUITEM_UP },
613    {0}
614};
615static CMenu operation_submenu = {0x21,LANG_MENU_OPERATION_PARAM_TITLE, NULL, operation_submenu_items };
616
617#ifdef OPT_EDGEOVERLAY
618static CMenuItem edge_overlay_submenu_items[] = {
619    {0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE,     MENUITEM_BOOL,          &conf.edge_overlay_enable },
620    {0x33,LANG_MENU_EDGE_SAVE,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_save },
621    {0x5c,LANG_MENU_EDGE_ZOOM,     MENUITEM_BOOL,          &conf.edge_overlay_zoom },
622    {0x5c,LANG_MENU_EDGE_LOCK,     MENUITEM_BOOL,          &conf.edge_overlay_lock },
623    {0x7f,LANG_MENU_EDGE_OVERLAY_TRESH,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255)},
624    {0x65,LANG_MENU_EDGE_OVERLAY_COLOR,      MENUITEM_COLOR_FG,      (int*)&conf.edge_overlay_color },
625    {0x5c,LANG_MENU_EDGE_PLAY,                  MENUITEM_BOOL,          &conf.edge_overlay_play }, //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button
626    {0x33,LANG_MENU_EDGE_FREE,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_free },
627    {0x33,LANG_MENU_EDGE_LOAD,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_load },
628    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
629    {0}
630};
631static CMenu edge_overlay_submenu = {0x7f,LANG_MENU_EDGE_OVERLAY_TITLE, NULL, edge_overlay_submenu_items };
632#endif
633
634static CMenuItem grid_submenu_items[] = {
635    {0x2f,LANG_MENU_SHOW_GRID,               MENUITEM_BOOL,             &conf.show_grid_lines },
636    {0x35,LANG_MENU_GRID_LOAD,               MENUITEM_PROC,             (int*)gui_grid_lines_load },
637    {0x0,LANG_MENU_GRID_CURRENT,            MENUITEM_SEPARATOR },
638    {0x0,(int)grid_title,                   MENUITEM_TEXT },
639    {0x0,(int)"",                           MENUITEM_SEPARATOR },
640    {0x5c,LANG_MENU_GRID_FORCE_COLOR,        MENUITEM_BOOL,          &conf.grid_force_color },
641    {0x65,LANG_MENU_GRID_COLOR_LINE,         MENUITEM_COLOR_FG,      (int*)&conf.grid_color },
642    {0x65,LANG_MENU_GRID_COLOR_FILL,         MENUITEM_COLOR_BG,      (int*)&conf.grid_color },
643    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
644    {0}
645};
646static CMenu grid_submenu = {0x2f,LANG_MENU_GRID_TITLE, NULL, grid_submenu_items };
647
648static CMenuItem visual_submenu_items[] = {
649    {0x35,LANG_MENU_VIS_LANG,                MENUITEM_PROC,      (int*)gui_draw_load_lang },
650    {0x5f,LANG_MENU_VIS_OSD_FONT,            MENUITEM_ENUM,      (int*)gui_font_enum },
651    {0x35,LANG_MENU_VIS_MENU_FONT,           MENUITEM_PROC,      (int*)gui_draw_load_menu_rbf },
652    {0x35,LANG_MENU_VIS_MENU_SYMBOL_FONT,    MENUITEM_PROC,      (int*)gui_draw_load_symbol_rbf },
653    {0x80,LANG_MENU_RESET_FILES          ,         MENUITEM_PROC,          (int*)gui_menuproc_reset_files },
654    {0x0,LANG_MENU_VIS_COLORS,              MENUITEM_SEPARATOR },
655    {0x65,LANG_MENU_VIS_OSD_TEXT,            MENUITEM_COLOR_FG,  (int*)&conf.osd_color },
656    {0x65,LANG_MENU_VIS_OSD_BKG,             MENUITEM_COLOR_BG,  (int*)&conf.osd_color },
657    {0x65,LANG_MENU_VIS_OSD_WARNING,         MENUITEM_COLOR_FG,  (int*)&conf.osd_color_warn },
658    {0x65,LANG_MENU_VIS_OSD_WARNING_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.osd_color_warn },
659    {0x65,LANG_MENU_VIS_HISTO,               MENUITEM_COLOR_FG,  (int*)&conf.histo_color },
660    {0x65,LANG_MENU_VIS_HISTO_BKG,           MENUITEM_COLOR_BG,  (int*)&conf.histo_color },
661    {0x65,LANG_MENU_VIS_HISTO_BORDER,        MENUITEM_COLOR_FG,  (int*)&conf.histo_color2 },
662    {0x65,LANG_MENU_VIS_HISTO_MARKERS,       MENUITEM_COLOR_BG,  (int*)&conf.histo_color2 },
663    {0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  (int*)&conf.zebra_color },
664    {0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  (int*)&conf.zebra_color },
665    {0x65,LANG_MENU_VIS_BATT_ICON,           MENUITEM_COLOR_FG,  (int*)&conf.batt_icon_color },
666    {0x65,LANG_MENU_VIS_SPACE_ICON,          MENUITEM_COLOR_FG,  (int*)&conf.space_color },
667    {0x65,LANG_MENU_VIS_SPACE_ICON_BKG,      MENUITEM_COLOR_BG,  (int*)&conf.space_color },   
668    {0x65,LANG_MENU_VIS_MENU_TEXT,           MENUITEM_COLOR_FG,  (int*)&conf.menu_color },
669    {0x65,LANG_MENU_VIS_MENU_BKG,            MENUITEM_COLOR_BG,  (int*)&conf.menu_color },
670    {0x65,LANG_MENU_VIS_MENU_TITLE_TEXT,     MENUITEM_COLOR_FG,  (int*)&conf.menu_title_color },
671    {0x65,LANG_MENU_VIS_MENU_TITLE_BKG,      MENUITEM_COLOR_BG,  (int*)&conf.menu_title_color },
672    {0x65,LANG_MENU_VIS_MENU_CURSOR_TEXT,    MENUITEM_COLOR_FG,  (int*)&conf.menu_cursor_color },
673    {0x65,LANG_MENU_VIS_MENU_CURSOR_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.menu_cursor_color },
674    {0x65,LANG_MENU_VIS_MENU_SYMBOL_TEXT,    MENUITEM_COLOR_FG,  (int*)&conf.menu_symbol_color },
675    {0x65,LANG_MENU_VIS_MENU_SYMBOL_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.menu_symbol_color },
676    {0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  (int*)&conf.reader_color },
677    {0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  (int*)&conf.reader_color },
678    {0x65,LANG_MENU_VIS_OSD_OVERRIDE,         MENUITEM_COLOR_FG,  (int*)&conf.osd_color_override },
679    {0x65,LANG_MENU_VIS_OSD_OVERRIDE_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.osd_color_override },
680    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
681    {0}
682};
683static CMenu visual_submenu = {0x28,LANG_MENU_VIS_TITLE, NULL, visual_submenu_items };
684
685/*
686 * 1 extra entry for the "Main menu" and 1 for null when the menu is full with user selections
687 * Compiler will zero init remaining portion of array so no there is no hidden relationship between
688 * this structure and the value of USER_MENU_ITEMS. The value of USER_MENU_ITEMS can be anything you
689 * wish and everything automagically works.
690*/
691 
692static CMenuItem user_submenu_items[USER_MENU_ITEMS + 2] = {
693        {0x20,LANG_MENU_MAIN_TITLE,     MENUITEM_PROC,  (int*)rinit}
694};
695 
696static CMenu user_submenu = {0x2e,LANG_MENU_USER_MENU, NULL, user_submenu_items };
697
698static CMenuItem raw_state_submenu_items[] = {
699    {0x5c,LANG_MENU_OSD_SHOW_RAW_STATE,      MENUITEM_BOOL,      &conf.show_raw_state },   
700    {0x5c,LANG_MENU_OSD_SHOW_REMAINING_RAW,  MENUITEM_BOOL,      &conf.show_remaining_raw },   
701    {0x60,LANG_MENU_OSD_RAW_TRESHOLD,        MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.remaining_raw_treshold,   MENU_MINMAX(0, 200)},
702    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
703    {0}
704};
705
706static CMenu raw_state_submenu = {0x24,LANG_MENU_OSD_RAW_STATE_PARAMS_TITLE, NULL, raw_state_submenu_items };
707
708
709static CMenuItem osd_submenu_items[] = {
710    {0x5c,LANG_MENU_OSD_SHOW,                MENUITEM_BOOL,      &conf.show_osd },
711    {0x5c,LANG_MENU_OSD_HIDE_PLAYBACK,       MENUITEM_ENUM,      (int*)gui_hide_osd_enum },
712    {0x81,LANG_MENU_VIS_MENU_CENTER,         MENUITEM_BOOL,         &conf.menu_center },
713    {0x81,LANG_MENU_SELECT_FIRST_ENTRY,         MENUITEM_BOOL,      &conf.menu_select_first_entry },       
714    {0x64,LANG_MENU_VIS_SYMBOL,             MENUITEM_BOOL,          &conf.menu_symbol_enable },   
715    {0x2e,LANG_MENU_USER_MENU,                          MENUITEM_SUBMENU,   (int*)&user_submenu},
716    {0x5f,LANG_MENU_USER_MENU_ENABLE,           MENUITEM_ENUM,      (int*)gui_user_menu_show_enum },
717    {0x5c,LANG_MENU_USER_MENU_AS_ROOT,       MENUITEM_BOOL,      &conf.user_menu_as_root },
718    {0x5f,LANG_MENU_OSD_SHOW_STATES,         MENUITEM_BOOL,      &conf.show_state },
719    {0x5f,LANG_MENU_OSD_SHOW_TEMP,         MENUITEM_ENUM,      (int*)gui_temp_mode_enum },
720    {0x59,LANG_MENU_OSD_TEMP_FAHRENHEIT,      MENUITEM_BOOL,      &conf.temperature_unit},
721    {0x72,LANG_MENU_OSD_LAYOUT_EDITOR,       MENUITEM_PROC,      (int*)gui_draw_osd_le },
722    {0x2f,LANG_MENU_OSD_GRID_PARAMS,         MENUITEM_SUBMENU,   (int*)&grid_submenu },
723    {0x22,LANG_MENU_OSD_VALUES,                 MENUITEM_SUBMENU,   (int*)&values_submenu },
724    {0x31,LANG_MENU_OSD_DOF_CALC,            MENUITEM_SUBMENU,   (int*)&dof_submenu },
725    {0x24,LANG_MENU_OSD_RAW_STATE_PARAMS,    MENUITEM_SUBMENU,   (int*)&raw_state_submenu },
726    {0x32,LANG_MENU_OSD_BATT_PARAMS,         MENUITEM_SUBMENU,   (int*)&battery_submenu },
727    {0x33,LANG_MENU_OSD_SPACE_PARAMS,        MENUITEM_SUBMENU,   (int*)&space_submenu },
728    {0x34,LANG_MENU_OSD_CLOCK_PARAMS,           MENUITEM_SUBMENU,   (int*)&clock_submenu },
729    {0x59,LANG_MENU_OSD_SHOW_IN_REVIEW,      MENUITEM_BOOL,      &conf.show_osd_in_review},
730#ifndef OPTIONS_AUTOSAVE
731    {0x5c,LANG_MENU_MAIN_SAVE_OPTIONS,       MENUITEM_PROC,      (int*)gui_menuproc_save },
732#endif
733    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
734    {0}
735};
736
737static CMenu osd_submenu = {0x22,LANG_MENU_OSD_TITLE, NULL, osd_submenu_items };
738
739static CMenuItem histo_submenu_items[] = {
740    {0x5f,LANG_MENU_HISTO_SHOW,              MENUITEM_ENUM,      (int*)gui_histo_show_enum },
741    {0x6f,LANG_MENU_HISTO_LAYOUT,            MENUITEM_ENUM,      (int*)gui_histo_layout_enum },
742    {0x5f,LANG_MENU_HISTO_MODE,              MENUITEM_ENUM,      (int*)gui_histo_mode_enum },
743    {0x5c,LANG_MENU_HISTO_EXP,               MENUITEM_BOOL,       &conf.show_overexp },
744    {0x70,LANG_MENU_HISTO_IGNORE_PEAKS,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.histo_ignore_boundary,   MENU_MINMAX(0, 32)},
745    {0x5c,LANG_MENU_HISTO_MAGNIFY,           MENUITEM_BOOL,       &conf.histo_auto_ajust },
746    {0x5c,LANG_MENU_HISTO_SHOW_EV_GRID,      MENUITEM_BOOL,       &conf.histo_show_ev_grid },
747    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
748    {0}
749};
750static CMenu histo_submenu = {0x25,LANG_MENU_HISTO_TITLE, NULL, histo_submenu_items };
751
752static CMenuItem raw_exceptions_submenu_items[] = {
753    #if defined CAM_HAS_VIDEO_BUTTON
754     {0x5c,LANG_MENU_RAW_SAVE_IN_VIDEO,                MENUITEM_BOOL,      &conf.save_raw_in_video },
755    #endif
756    #if defined(CAMERA_s3is)
757        {0x5c,LANG_MENU_RAW_SAVE_IN_SPORTS,                MENUITEM_BOOL,      &conf.save_raw_in_sports },
758    #endif
759    {0x5c,LANG_MENU_RAW_SAVE_IN_BURST,                MENUITEM_BOOL,      &conf.save_raw_in_burst },
760    {0x5c,LANG_MENU_RAW_SAVE_IN_TIMER,                MENUITEM_BOOL,      &conf.save_raw_in_timer },
761    {0x5c,LANG_MENU_RAW_SAVE_IN_EDGEOVERLAY,          MENUITEM_BOOL,      &conf.save_raw_in_edgeoverlay },
762    {0x5c,LANG_MENU_RAW_SAVE_IN_AUTO,                 MENUITEM_BOOL,      &conf.save_raw_in_auto },
763                #if CAM_BRACKETING
764        {0x5c,LANG_MENU_RAW_SAVE_IN_EV_BRACKETING,                MENUITEM_BOOL,      &conf.save_raw_in_ev_bracketing },
765                #endif
766    {0x5c,LANG_MENU_RAW_WARN,                MENUITEM_BOOL,      &conf.raw_exceptions_warn },
767    {0x51,LANG_MENU_BACK,                           MENUITEM_UP },
768    {0}
769};
770static CMenu raw_exceptions_submenu = {0x59,LANG_MENU_OSD_RAW_EXCEPTIONS_PARAMS_TITLE, NULL, raw_exceptions_submenu_items };
771
772
773static CMenuItem raw_submenu_items[] = {
774    {0x5c,LANG_MENU_RAW_SAVE,                MENUITEM_BOOL,      &conf.save_raw },
775    {0x59,LANG_MENU_OSD_RAW_EXCEPTIONS_PARAMS,          MENUITEM_SUBMENU,   (int*)&raw_exceptions_submenu },
776    {0x5f,LANG_MENU_RAW_NOISE_REDUCTION,     MENUITEM_ENUM,      (int*)gui_raw_nr_enum },
777    {0x5c,LANG_MENU_RAW_FIRST_ONLY,          MENUITEM_BOOL,      &conf.raw_save_first_only },
778    {0x5c,LANG_MENU_RAW_SAVE_IN_DIR,         MENUITEM_BOOL,      &conf.raw_in_dir },
779    {0x5f,LANG_MENU_RAW_PREFIX,              MENUITEM_ENUM,      (int*)gui_raw_prefix_enum },
780    {0x5f,LANG_MENU_RAW_EXTENSION,           MENUITEM_ENUM,      (int*)gui_raw_ext_enum },
781    {0x5f,LANG_MENU_SUB_PREFIX,              MENUITEM_ENUM,      (int*)gui_sub_batch_prefix_enum },
782    {0x5f,LANG_MENU_SUB_EXTENSION,           MENUITEM_ENUM,      (int*)gui_sub_batch_ext_enum },
783    {0x60,LANG_MENU_SUB_IN_DARK_VALUE,       MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.sub_in_dark_value, MENU_MINMAX(0, 1023)},
784    {0x60,LANG_MENU_SUB_OUT_DARK_VALUE,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.sub_out_dark_value, MENU_MINMAX(0, 1023)},
785    {0x2a,LANG_MENU_RAW_DEVELOP,             MENUITEM_PROC,      (int*)gui_raw_develop },
786    {0x5c,LANG_MENU_BAD_PIXEL_REMOVAL,       MENUITEM_ENUM,      (int*)gui_bad_pixel_enum },
787#if DNG_SUPPORT
788    {0x5c,LANG_MENU_DNG_FORMAT,              MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.dng_raw , (int)cb_change_dng },
789    {0x5c,LANG_MENU_RAW_DNG_EXT,             MENUITEM_BOOL,      &conf.raw_dng_ext},
790#endif
791    {0x5c,LANG_MENU_RAW_CACHED,              MENUITEM_BOOL,      &conf.raw_cache },
792    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
793    {0}
794};
795static CMenu raw_submenu = {0x24,LANG_MENU_RAW_TITLE, NULL, raw_submenu_items };
796
797
798static CMenuItem zebra_submenu_items[] = {
799    {0x5c,LANG_MENU_ZEBRA_DRAW,              MENUITEM_BOOL,                            &conf.zebra_draw },
800    {0x5f,LANG_MENU_ZEBRA_MODE,              MENUITEM_ENUM,                            (int*)gui_zebra_mode_enum },
801    {0x58,LANG_MENU_ZEBRA_UNDER,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_under,   MENU_MINMAX(0, 32)},
802    {0x57,LANG_MENU_ZEBRA_OVER,              MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_over,    MENU_MINMAX(0, 32)},
803    {0x28,LANG_MENU_ZEBRA_RESTORE_SCREEN,    MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_screen,     (int)cb_zebra_restore_screen },
804    {0x5c,LANG_MENU_ZEBRA_RESTORE_OSD,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_osd,        (int)cb_zebra_restore_osd },
805    {0x5f,LANG_MENU_ZEBRA_DRAW_OVER,         MENUITEM_ENUM,                            (int*)gui_zebra_draw_osd_enum },
806    {0x5c,LANG_MENU_ZEBRA_MULTICHANNEL,      MENUITEM_BOOL,                            &conf.zebra_multichannel},   
807    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
808    {0}
809};
810static CMenu zebra_submenu = {0x26,LANG_MENU_ZEBRA_TITLE, NULL, zebra_submenu_items };
811
812#ifdef OPT_CURVES
813static CMenuItem curve_submenu_items[] = {
814    {0x5f,LANG_MENU_CURVE_ENABLE,        MENUITEM_ENUM,      (int*)gui_conf_curve_enum },   
815    {0x35,LANG_MENU_CURVE_LOAD,          MENUITEM_PROC,      (int*)gui_load_curve },   
816    {0x51,LANG_MENU_BACK,                MENUITEM_UP },
817    {0}
818};
819static CMenu curve_submenu = {0x85,LANG_MENU_CURVE_PARAM_TITLE, NULL, curve_submenu_items };
820#endif
821
822static CMenuItem root_menu_items[] = {
823    {0x21,LANG_MENU_OPERATION_PARAM,         MENUITEM_SUBMENU,   (int*)&operation_submenu },
824#if CAM_CHDK_HAS_EXT_VIDEO_MENU
825    {0x23,LANG_MENU_VIDEO_PARAM,             MENUITEM_SUBMENU,   (int*)&video_submenu },
826#endif
827    {0x24,LANG_MENU_MAIN_RAW_PARAM,          MENUITEM_SUBMENU,   (int*)&raw_submenu },
828#ifdef OPT_EDGEOVERLAY
829    {0x7f,LANG_MENU_EDGE_OVERLAY,         MENUITEM_SUBMENU,   (int*)&edge_overlay_submenu },
830#endif
831#ifdef OPT_CURVES
832    {0x85,LANG_MENU_CURVE_PARAM,             MENUITEM_SUBMENU,   (int*)&curve_submenu },
833#endif
834    {0x25,LANG_MENU_MAIN_HISTO_PARAM,        MENUITEM_SUBMENU,   (int*)&histo_submenu },
835    {0x26,LANG_MENU_MAIN_ZEBRA_PARAM,        MENUITEM_SUBMENU,   (int*)&zebra_submenu },
836    {0x22,LANG_MENU_MAIN_OSD_PARAM,          MENUITEM_SUBMENU,   (int*)&osd_submenu },
837    {0x28,LANG_MENU_MAIN_VISUAL_PARAM,       MENUITEM_SUBMENU,   (int*)&visual_submenu },
838    {0x27,LANG_MENU_MAIN_SCRIPT_PARAM,       MENUITEM_SUBMENU,   (int*)&script_submenu },
839    {0x29,LANG_MENU_MAIN_MISC,               MENUITEM_SUBMENU,   (int*)&misc_submenu },
840#ifndef OPTIONS_AUTOSAVE
841    {0x33,LANG_MENU_MAIN_SAVE_OPTIONS,       MENUITEM_PROC,      (int*)gui_menuproc_save },
842#endif
843    {0}
844};
845
846static CMenu root_menu = {0x20,LANG_MENU_MAIN_TITLE, NULL, root_menu_items };
847
848static int gui_user_menu_flag;
849
850void rinit(){
851        gui_menu_init(&root_menu);
852}
853
854//-------------------------------------------------------------------
855void
856mod_user_menu(CMenuItem curr_menu_item, int* cur_memnu_item_indx, int mod) {
857int i;
858CMenuItem tmp_menu_item;
859        switch(mod) {
860
861                case 0:
862                        /*
863                         * Delete user menu entry by sliding all the lower valid/existing entries up.
864                         */
865
866                        if (*cur_memnu_item_indx == 0) /* don't allow deleting "user menu" */
867                                break;
868                        for(i = *cur_memnu_item_indx; user_submenu_items[i].text; i++) {
869                                user_submenu_items[i] = user_submenu_items[i+1];
870                        }
871 
872                        /*
873                         * there were no valid entries below this one, so
874                         * the index pointer must be decremented.
875                         */
876                        if(!user_submenu_items[*cur_memnu_item_indx].text)
877                                *cur_memnu_item_indx -= 1;
878 
879                        break;
880 
881                case 1:
882                        /*
883                         * Insert new Item at end of existing entries
884                         */
885                        for(i = 1; i < USER_MENU_ITEMS + 1; i++) {
886                                if(!user_submenu_items[i].text) {
887                                        user_submenu_items[i] = curr_menu_item;
888                                        break;
889                                }
890                        }
891                        break;
892 
893                case 2:
894                        /*
895                         * Move entry up
896                         */
897 
898                        if((*cur_memnu_item_indx > 1)) {
899                                tmp_menu_item = user_submenu_items[*cur_memnu_item_indx -1];
900                                user_submenu_items[*cur_memnu_item_indx -1] = user_submenu_items[*cur_memnu_item_indx];
901                                user_submenu_items[*cur_memnu_item_indx] = tmp_menu_item;
902                                *cur_memnu_item_indx -=1;
903                        }
904                        break;
905
906                case 3:
907                        /*
908                         * Move entry down below next entry if next entry is not empty
909                         */
910                        if (*cur_memnu_item_indx == 0) /* don't allow moving "user menu" */
911                                break;
912                        if((*cur_memnu_item_indx < (USER_MENU_ITEMS)) && (user_submenu_items[*cur_memnu_item_indx +1].text)) {
913                                tmp_menu_item = user_submenu_items[*cur_memnu_item_indx +1];
914                                user_submenu_items[*cur_memnu_item_indx + 1] = user_submenu_items[*cur_memnu_item_indx];
915                                user_submenu_items[*cur_memnu_item_indx] = tmp_menu_item;
916                                *cur_memnu_item_indx +=1;
917                        }
918                        break;
919 
920        }       
921}
922
923//-------------------------------------------------------------------
924void cb_step_25() {
925    voltage_step = (conf.batt_step_25)?25:1;
926}
927
928void cb_perc() {
929    conf.batt_volts_show=0;
930}
931
932void cb_volts() {
933    conf.batt_perc_show=0;
934}
935
936void cb_space_perc() {
937    conf.space_mb_show=0;
938}
939
940void cb_space_mb() {
941    conf.space_perc_show=0;
942}
943
944void cb_battery_menu_change(unsigned int item) {
945    switch (item) {
946        case 0: //Voltage MAX
947            if (conf.batt_volts_max<conf.batt_volts_min+25) {
948                conf.batt_volts_min = conf.batt_volts_max-25;
949            }
950            break;
951        case 1: //Voltage MIN
952            if (conf.batt_volts_min>conf.batt_volts_max-25) {
953                conf.batt_volts_max = conf.batt_volts_min+25;
954            }
955            break;
956        default:
957            break;
958    }
959}
960
961void cb_zebra_restore_screen() {
962    if (!conf.zebra_restore_screen)
963        conf.zebra_restore_osd = 0;
964}
965
966void cb_zebra_restore_osd() {
967    if (conf.zebra_restore_osd)
968        conf.zebra_restore_screen = 1;
969}
970
971#if DNG_SUPPORT
972void cb_change_dng(){
973 int old=conf.dng_raw;
974 conf_change_dng();
975 if ((old==1) && (conf.dng_raw==0)) gui_mbox_init(LANG_ERROR, LANG_CANNOT_OPEN_BADPIXEL_FILE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
976}
977#endif
978
979#if defined (DNG_EXT_FROM)
980void cb_change_dng_usb_ext(){
981 if (conf.dng_usb_ext) change_ext_to_dng(); else change_ext_to_default();
982}
983#endif
984
985
986//-------------------------------------------------------------------
987#ifdef OPT_CURVES
988const char* gui_conf_curve_enum(int change, int arg) {
989    static const char* modes[]={ "None", "Custom", "+1EV", "+2EV", "Auto DR" };
990
991    conf.curve_enable+=change;
992    if (conf.curve_enable<0)
993        conf.curve_enable=(sizeof(modes)/sizeof(modes[0]))-1;
994    else if (conf.curve_enable>=(sizeof(modes)/sizeof(modes[0])))
995        conf.curve_enable=0;
996
997        if(change)
998                curve_init_mode();
999    return modes[conf.curve_enable];
1000}
1001#endif
1002//-------------------------------------------------------------------
1003const char* gui_script_autostart_enum(int change, int arg) {
1004    static const char* modes[]={ "Off", "On", "Once"};
1005
1006    conf.script_startup+=change;
1007    if (conf.script_startup<0)
1008        conf.script_startup=(sizeof(modes)/sizeof(modes[0]))-1;
1009    else if (conf.script_startup>=(sizeof(modes)/sizeof(modes[0])))
1010        conf.script_startup=0;
1011
1012    return modes[conf.script_startup];
1013}
1014
1015//-------------------------------------------------------------------
1016const char* gui_script_param_set_enum(int change, int arg) {
1017    static const char* modes[]={ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
1018
1019    if (change != 0) {
1020        if (conf.script_param_save) {
1021            save_params_values(0);
1022        }
1023        conf.script_param_set += change;
1024        if (conf.script_param_set < 0)
1025            conf.script_param_set = (sizeof(modes)/sizeof(modes[0]))-1;
1026        else if (conf.script_param_set >= (sizeof(modes)/sizeof(modes[0])))
1027            conf.script_param_set=0;
1028
1029        if (!load_params_values(conf.script_file, 1, 0))
1030            script_load(conf.script_file, 0);
1031        gui_update_script_submenu();
1032    }
1033
1034    return modes[conf.script_param_set];
1035}
1036
1037
1038//-------------------------------------------------------------------
1039const char* gui_override_disable_enum(int change, int arg) {
1040    static const char* modes[]={ "Off", "On", "Disabled"};
1041
1042    conf.override_disable+=change;
1043    if (conf.override_disable<0)
1044        conf.override_disable=(sizeof(modes)/sizeof(modes[0]))-1;
1045    else if (conf.override_disable>=(sizeof(modes)/sizeof(modes[0])))
1046        conf.override_disable=0;
1047
1048    return modes[conf.override_disable];
1049}
1050
1051//-------------------------------------------------------------------
1052const char* gui_histo_mode_enum(int change, int arg) {
1053    static const char* modes[]={ "Linear", "Log" };
1054
1055    conf.histo_mode+=change;
1056    if (conf.histo_mode<0)
1057        conf.histo_mode=(sizeof(modes)/sizeof(modes[0]))-1;
1058    else if (conf.histo_mode>=(sizeof(modes)/sizeof(modes[0])))
1059        conf.histo_mode=0;
1060
1061    histogram_set_mode(conf.histo_mode);
1062
1063    return modes[conf.histo_mode];
1064}
1065
1066//-------------------------------------------------------------------
1067const char* gui_temp_mode_enum(int change, int arg) {
1068    static const char* modes[]={ "Off", "Optical","CCD","Battery","all" };
1069
1070    conf.show_temp+=change;
1071    if (conf.show_temp<0)
1072        conf.show_temp=(sizeof(modes)/sizeof(modes[0]))-1;
1073    else if (conf.show_temp>=(sizeof(modes)/sizeof(modes[0])))
1074        conf.show_temp=0;
1075
1076    return modes[conf.show_temp];
1077}
1078
1079//-------------------------------------------------------------------
1080const char* gui_histo_layout_enum(int change, int arg) {
1081    static const char* modes[]={ "RGB", "Y", "RGB Y",  "R G B", "RGB all", "Y all", "Blend", "Blend Y"};
1082
1083    conf.histo_layout+=change;
1084    if (conf.histo_layout<0)
1085        conf.histo_layout=(sizeof(modes)/sizeof(modes[0]))-1;
1086    else if (conf.histo_layout>=(sizeof(modes)/sizeof(modes[0])))
1087        conf.histo_layout=0;
1088
1089    if (conf.histo_layout==OSD_HISTO_LAYOUT_Y || conf.histo_layout==OSD_HISTO_LAYOUT_Y_argb) {
1090        histogram_set_main(HISTO_Y);
1091    } else {
1092        histogram_set_main(HISTO_RGB);
1093    }
1094
1095    return modes[conf.histo_layout];
1096}
1097
1098//-------------------------------------------------------------------
1099const char* gui_font_enum(int change, int arg) {
1100    static const char* fonts[]={ "Win1250", "Win1251", "Win1252", "Win1254", "Win1257"};
1101
1102    conf.font_cp+=change;
1103    if (conf.font_cp<0)
1104        conf.font_cp=(sizeof(fonts)/sizeof(fonts[0]))-1;
1105    else if (conf.font_cp>=(sizeof(fonts)/sizeof(fonts[0])))
1106        conf.font_cp=0;
1107
1108    if (change != 0) {
1109        font_set(conf.font_cp);
1110        if (!rbf_load(conf.menu_rbf_file))
1111            rbf_load_from_8x16(current_font);
1112        rbf_set_codepage(FONT_CP_WIN);
1113        gui_menu_init(NULL);
1114    }
1115
1116    return fonts[conf.font_cp];
1117}
1118
1119//-------------------------------------------------------------------
1120const char* gui_raw_prefix_enum(int change, int arg) {
1121    conf.raw_prefix+=change;
1122    if (conf.raw_prefix<0)
1123        conf.raw_prefix=NUM_IMG_PREFIXES-1;
1124    else if (conf.raw_prefix>=NUM_IMG_PREFIXES)
1125        conf.raw_prefix=0;
1126
1127    return img_prefixes[conf.raw_prefix];
1128}
1129
1130//-------------------------------------------------------------------
1131const char* gui_raw_ext_enum(int change, int arg) {
1132    conf.raw_ext+=change;
1133    if (conf.raw_ext<0)
1134        conf.raw_ext=NUM_IMG_EXTS-1;
1135    else if (conf.raw_ext>=NUM_IMG_EXTS)
1136        conf.raw_ext=0;
1137
1138    return img_exts[conf.raw_ext];
1139}
1140
1141//-------------------------------------------------------------------
1142const char* gui_sub_batch_prefix_enum(int change, int arg) {
1143    conf.sub_batch_prefix+=change;
1144    if (conf.sub_batch_prefix<0)
1145        conf.sub_batch_prefix=NUM_IMG_PREFIXES-1;
1146    else if (conf.sub_batch_prefix>=NUM_IMG_PREFIXES)
1147        conf.sub_batch_prefix=0;
1148
1149    return img_prefixes[conf.sub_batch_prefix];
1150}
1151
1152//-------------------------------------------------------------------
1153const char* gui_sub_batch_ext_enum(int change, int arg) {
1154    conf.sub_batch_ext+=change;
1155    if (conf.sub_batch_ext<0)
1156        conf.sub_batch_ext=NUM_IMG_EXTS-1;
1157    else if (conf.sub_batch_ext>=NUM_IMG_EXTS)
1158        conf.sub_batch_ext=0;
1159
1160    return img_exts[conf.sub_batch_ext];
1161}
1162
1163//-------------------------------------------------------------------
1164const char* gui_raw_nr_enum(int change, int arg) {
1165    static const char* modes[]={ "Auto", "Off", "On"};
1166
1167    conf.raw_nr+=change;
1168    if (conf.raw_nr<0)
1169        conf.raw_nr=(sizeof(modes)/sizeof(modes[0]))-1;
1170    else if (conf.raw_nr>=(sizeof(modes)/sizeof(modes[0])))
1171        conf.raw_nr=0;
1172
1173    return modes[conf.raw_nr];
1174}
1175
1176//-------------------------------------------------------------------
1177#ifdef OPT_TEXTREADER
1178const char* gui_reader_codepage_enum(int change, int arg) {
1179    static const char* cps[]={ "Win1251", "DOS"};
1180
1181    conf.reader_codepage+=change;
1182    if (conf.reader_codepage<0)
1183        conf.reader_codepage=(sizeof(cps)/sizeof(cps[0]))-1;
1184    else if (conf.reader_codepage>=(sizeof(cps)/sizeof(cps[0])))
1185        conf.reader_codepage=0;
1186
1187    return cps[conf.reader_codepage];
1188}
1189#endif
1190//-------------------------------------------------------------------
1191const char* gui_autoiso_shutter_enum(int change, int arg) {
1192    static const char* shutter[]={ "Auto", "1/8s", "1/15s", "1/30s", "1/60s", "1/125s", "1/250s", "1/500s", "1/1000s"};
1193
1194    conf.autoiso_shutter+=change;
1195    if (conf.autoiso_shutter<0)
1196        conf.autoiso_shutter=(sizeof(shutter)/sizeof(shutter[0]))-1;
1197    else if (conf.autoiso_shutter>=(sizeof(shutter)/sizeof(shutter[0])))
1198        conf.autoiso_shutter=0;
1199
1200    return shutter[conf.autoiso_shutter];
1201}
1202
1203//-------------------------------------------------------------------
1204const char* gui_zebra_mode_enum(int change, int arg) {
1205    static const char* modes[]={ "Blink 1", "Blink 2", "Blink 3", "Solid", "Zebra 1", "Zebra 2" };
1206
1207    conf.zebra_mode+=change;
1208    if (conf.zebra_mode<0)
1209        conf.zebra_mode=(sizeof(modes)/sizeof(modes[0]))-1;
1210    else if (conf.zebra_mode>=(sizeof(modes)/sizeof(modes[0])))
1211        conf.zebra_mode=0;
1212
1213    return modes[conf.zebra_mode];
1214}
1215
1216//-------------------------------------------------------------------
1217const char* gui_zebra_draw_osd_enum(int change, int arg) {
1218    static const char* modes[]={ "Nothing", "Histo", "OSD" };
1219
1220    conf.zebra_draw_osd+=change;
1221    if (conf.zebra_draw_osd<0)
1222        conf.zebra_draw_osd=(sizeof(modes)/sizeof(modes[0]))-1;
1223    else if (conf.zebra_draw_osd>=(sizeof(modes)/sizeof(modes[0])))
1224        conf.zebra_draw_osd=0;
1225
1226    return modes[conf.zebra_draw_osd];
1227}
1228
1229//-------------------------------------------------------------------
1230const char* gui_zoom_value_enum(int change, int arg) {
1231    static const char* modes[]={ "X", "FL", "EFL" };
1232
1233    conf.zoom_value+=change;
1234    if (conf.zoom_value<0)
1235        conf.zoom_value=(sizeof(modes)/sizeof(modes[0]))-1;
1236    else if (conf.zoom_value>=(sizeof(modes)/sizeof(modes[0])))
1237        conf.zoom_value=0;
1238
1239    return modes[conf.zoom_value];
1240}
1241
1242const char* gui_show_values_enum(int change, int arg) {
1243    static const char* modes[]={ "Don't", "Always", "Shoot" };
1244
1245    conf.show_values+=change;
1246    if (conf.show_values<0)
1247        conf.show_values=(sizeof(modes)/sizeof(modes[0]))-1;
1248    else if (conf.show_values>=(sizeof(modes)/sizeof(modes[0])))
1249        conf.show_values=0;
1250
1251    return modes[conf.show_values];
1252}
1253
1254const char* gui_nd_filter_state_enum(int change, int arg) {
1255    static const char* modes[]={ "Off", "In", "Out" };
1256
1257    conf.nd_filter_state+=change;
1258    if (conf.nd_filter_state<0)
1259        conf.nd_filter_state=(sizeof(modes)/sizeof(modes[0]))-1;
1260    else if (conf.nd_filter_state>=(sizeof(modes)/sizeof(modes[0])))
1261        conf.nd_filter_state=0;
1262
1263    return modes[conf.nd_filter_state];
1264}
1265
1266
1267
1268const char* gui_dof_show_value_enum(int change, int arg) {
1269    static const char* modes[]={ "Don't", "Separate", "In Misc" };
1270
1271    conf.show_dof+=change;
1272    if (conf.show_dof<0)
1273        conf.show_dof=(sizeof(modes)/sizeof(modes[0]))-1;
1274    else if (conf.show_dof>=(sizeof(modes)/sizeof(modes[0])))
1275        conf.show_dof=0;
1276
1277    return modes[conf.show_dof];
1278}
1279
1280
1281const char* gui_histo_show_enum(int change, int arg) {
1282    static const char* modes[]={ "Don't", "Always", "Shoot" };
1283
1284    conf.show_histo+=change;
1285    if (conf.show_histo<0)
1286        conf.show_histo=(sizeof(modes)/sizeof(modes[0]))-1;
1287    else if (conf.show_histo>=(sizeof(modes)/sizeof(modes[0])))
1288        conf.show_histo=0;
1289
1290    return modes[conf.show_histo];
1291}
1292
1293const char* gui_show_clock_enum(int change, int arg) {
1294    static const char* modes[]={ "Don't", "Normal", "Seconds"};
1295
1296    conf.show_clock+=change;
1297    if (conf.show_clock<0)
1298        conf.show_clock=(sizeof(modes)/sizeof(modes[0]))-1;
1299    else if (conf.show_clock>=(sizeof(modes)/sizeof(modes[0])))
1300        conf.show_clock=0;
1301
1302    return modes[conf.show_clock];
1303}
1304
1305const char* gui_hide_osd_enum(int change, int arg) {
1306    static const char* modes[]={ "Don't", "In Playback", "On Disp Press", "both"};
1307
1308    conf.hide_osd+=change;
1309    if (conf.hide_osd<0)
1310        conf.hide_osd=(sizeof(modes)/sizeof(modes[0]))-1;
1311    else if (conf.hide_osd>=(sizeof(modes)/sizeof(modes[0])))
1312        conf.hide_osd=0;
1313
1314    return modes[conf.hide_osd];
1315}
1316
1317const char* gui_clock_format_enum(int change, int arg) {
1318    static const char* modes[]={ "24h", "12h"};
1319
1320    conf.clock_format+=change;
1321    if (conf.clock_format<0)
1322        conf.clock_format=(sizeof(modes)/sizeof(modes[0]))-1;
1323    else if (conf.clock_format>=(sizeof(modes)/sizeof(modes[0])))
1324        conf.clock_format=0;
1325
1326    return modes[conf.clock_format];
1327}
1328
1329const char* gui_clock_indicator_enum(int change, int arg) {
1330    static const char* modes[]={ "PM", "P","."};
1331
1332    conf.clock_indicator+=change;
1333    if (conf.clock_indicator<0)
1334        conf.clock_indicator=(sizeof(modes)/sizeof(modes[0]))-1;
1335    else if (conf.clock_indicator>=(sizeof(modes)/sizeof(modes[0])))
1336        conf.clock_indicator=0;
1337
1338    return modes[conf.clock_indicator];
1339}
1340
1341const char* gui_clock_halfpress_enum(int change, int arg) {
1342    static const char* modes[]={ "Full", "Seconds","Don't"};
1343
1344    conf.clock_halfpress+=change;
1345    if (conf.clock_halfpress<0)
1346        conf.clock_halfpress=(sizeof(modes)/sizeof(modes[0]))-1;
1347    else if (conf.clock_halfpress>=(sizeof(modes)/sizeof(modes[0])))
1348        conf.clock_halfpress=0;
1349
1350    return modes[conf.clock_halfpress];
1351}
1352
1353const char* gui_space_bar_enum(int change, int arg) {
1354    static const char* modes[]={ "Don't", "Horizontal", "Vertical"};
1355
1356    conf.space_bar_show+=change;
1357    if (conf.space_bar_show<0)
1358        conf.space_bar_show=(sizeof(modes)/sizeof(modes[0]))-1;
1359    else if (conf.space_bar_show>=(sizeof(modes)/sizeof(modes[0])))
1360        conf.space_bar_show=0;
1361
1362    return modes[conf.space_bar_show];
1363}
1364
1365const char* gui_space_bar_size_enum(int change, int arg) {
1366    static const char* modes[]={ "1/4", "1/2", "1"};
1367
1368    conf.space_bar_size+=change;
1369    if (conf.space_bar_size<0)
1370        conf.space_bar_size=(sizeof(modes)/sizeof(modes[0]))-1;
1371    else if (conf.space_bar_size>=(sizeof(modes)/sizeof(modes[0])))
1372        conf.space_bar_size=0;
1373
1374    return modes[conf.space_bar_size];
1375}
1376
1377const char* gui_space_bar_width_enum(int change, int arg) {
1378    static const char* modes[]={ "1", "2", "3","4","5","6","7","8","9","10"};
1379
1380    conf.space_bar_width+=change;
1381    if (conf.space_bar_width<0)
1382        conf.space_bar_width=(sizeof(modes)/sizeof(modes[0]))-1;
1383    else if (conf.space_bar_width>=(sizeof(modes)/sizeof(modes[0])))
1384        conf.space_bar_width=0;
1385
1386    return modes[conf.space_bar_width];
1387}
1388
1389const char* gui_space_warn_type_enum(int change, int arg) {
1390    static const char* modes[]={ "Percent", "MB", "Don't"};
1391
1392    conf.space_warn_type+=change;
1393    if (conf.space_warn_type<0)
1394        conf.space_warn_type=(sizeof(modes)/sizeof(modes[0]))-1;
1395    else if (conf.space_warn_type>=(sizeof(modes)/sizeof(modes[0])))
1396        conf.space_warn_type=0;
1397
1398    return modes[conf.space_warn_type];
1399}
1400
1401 const char* gui_show_movie_time(int change, int arg) {
1402     static const char* modes[]={ "Don't", "hh:mm:ss", "KB/s","both"};
1403 
1404     conf.show_movie_time+=change;
1405     if (conf.show_movie_time<0)
1406         conf.show_movie_time=(sizeof(modes)/sizeof(modes[0]))-1;
1407     else if (conf.show_movie_time>=(sizeof(modes)/sizeof(modes[0])))
1408         conf.show_movie_time=0;
1409 
1410     return modes[conf.show_movie_time];
1411 }
1412
1413//-------------------------------------------------------------------
1414#if CAM_ADJUSTABLE_ALT_BUTTON
1415const char* gui_alt_mode_button_enum(int change, int arg) {
1416#if defined(CAMERA_s2is) || defined(CAMERA_s3is) || defined(CAMERA_s5is)
1417    static const char* names[]={ "Shrtcut", "Flash", "Timer", "ISO", "Video" };
1418    static const int keys[]={ KEY_PRINT, KEY_FLASH, KEY_TIMER, KEY_ISO, KEY_VIDEO };
1419#elif defined(CAMERA_g7)
1420    static const char* names[]={ "Print", "FE"};
1421    static const int keys[]={ KEY_PRINT, KEY_MICROPHONE };
1422#elif defined(CAMERA_g9)
1423    static const char* names[]={ "Print", "FE"};
1424    static const int keys[]={ KEY_PRINT,  KEY_MICROPHONE };
1425#elif defined(CAMERA_a650)
1426    static const char* names[]={ "Print", "ISO"};
1427    static const int keys[]={ KEY_PRINT, KEY_ISO };
1428#elif defined(CAMERA_sx100is)
1429    static const char* names[]={ "Print", "Face"};
1430    static const int keys[]={ KEY_PRINT, KEY_FACE };
1431#else
1432    #error camera alt-buttons not defined
1433#endif
1434    int i;
1435
1436    for (i=0; i<sizeof(names)/sizeof(names[0]); ++i) {
1437        if (conf.alt_mode_button==keys[i]) {
1438            break;
1439        }
1440    }
1441
1442    i+=change;
1443    if (i<0)
1444        i=(sizeof(names)/sizeof(names[0]))-1;
1445    else if (i>=(sizeof(names)/sizeof(names[0])))
1446        i=0;
1447
1448    conf.alt_mode_button = keys[i];
1449    kbd_set_alt_mode_key_mask(conf.alt_mode_button);
1450    return names[i];
1451}
1452#endif
1453
1454//-------------------------------------------------------------------
1455const char* gui_alt_power_enum(int change, int arg) {
1456    static const char* modes[]={ "No", "Alt", "Script" };
1457
1458    conf.alt_prevent_shutdown+=change;
1459    if (conf.alt_prevent_shutdown<0)
1460        conf.alt_prevent_shutdown=(sizeof(modes)/sizeof(modes[0]))-1;
1461    else if (conf.alt_prevent_shutdown>=(sizeof(modes)/sizeof(modes[0])))
1462        conf.alt_prevent_shutdown=0;
1463
1464    return modes[conf.alt_prevent_shutdown];
1465}
1466const char* gui_fast_ev_step(int change, int arg) {
1467    static const char* modes[]={"1/6 Ev","1/3 Ev","1/2 Ev", "2/3 Ev","5/6 Ev","1 Ev","1 1/6 Ev","1 1/3 Ev","1 1/2 Ev", "1 2/3 Ev","1 5/6 Ev","2 Ev","2 1/6 Ev","2 1/3 Ev","2 1/2 Ev", "2 2/3 Ev","2 5/6 Ev","3 Ev","3 1/6 Ev","3 1/3 Ev","3 1/2 Ev", "3 2/3 Ev","3 5/6 Ev","4 Ev"};
1468    conf.fast_ev_step+=change;
1469    if (conf.fast_ev_step<0)
1470        conf.fast_ev_step=(sizeof(modes)/sizeof(modes[0]))-1;
1471    else if (conf.fast_ev_step>=(sizeof(modes)/sizeof(modes[0])))
1472        conf.fast_ev_step=0;
1473    return modes[conf.fast_ev_step];
1474}
1475const char* gui_video_mode_enum(int change, int arg) {
1476    static const char* modes[]={ "Bitrate", "Quality"};
1477
1478    conf.video_mode+=change;
1479    if (conf.video_mode<0)
1480        conf.video_mode=(sizeof(modes)/sizeof(modes[0]))-1;
1481    else if (conf.video_mode>=(sizeof(modes)/sizeof(modes[0])))
1482        conf.video_mode=0;
1483
1484    return modes[conf.video_mode];
1485}
1486
1487//-------------------------------------------------------------------
1488const char* gui_video_bitrate_enum(int change, int arg) {
1489    conf.video_bitrate+=change;
1490    if (conf.video_bitrate<0)
1491        conf.video_bitrate=VIDEO_BITRATE_STEPS-1;
1492    else if (conf.video_bitrate>=VIDEO_BITRATE_STEPS)
1493        conf.video_bitrate=0;
1494
1495    shooting_video_bitrate_change(conf.video_bitrate);
1496
1497    return video_bitrate_strings[conf.video_bitrate];
1498}
1499
1500
1501//-------------------------------------------------------------------
1502const char* gui_tv_bracket_values_enum(int change, int arg) {
1503    static const char* modes[]={ "Off", "1/3 Ev","2/3 Ev", "1 Ev", "1 1/3Ev", "1 2/3Ev", "2 Ev", "2 1/3Ev", "2 2/3Ev", "3 Ev", "3 1/3Ev", "3 2/3Ev", "4 Ev"};
1504
1505    conf.tv_bracket_value+=change;
1506    if (conf.tv_bracket_value<0)
1507        conf.tv_bracket_value=sizeof(modes)/sizeof(modes[0])-1;
1508    else if (conf.tv_bracket_value>=(sizeof(modes)/sizeof(modes[0])))
1509        conf.tv_bracket_value=0;
1510
1511    return modes[conf.tv_bracket_value];
1512}
1513
1514const char* gui_av_bracket_values_enum(int change, int arg) {
1515    static const char* modes[]={ "Off", "1/3 Ev","2/3 Ev", "1 Ev", "1 1/3Ev", "1 2/3Ev", "2 Ev", "2 1/3Ev", "2 2/3Ev", "3 Ev", "3 1/3Ev", "3 2/3Ev", "4 Ev"};
1516
1517    conf.av_bracket_value+=change;
1518    if (conf.av_bracket_value<0)
1519        conf.av_bracket_value=sizeof(modes)/sizeof(modes[0])-1;
1520    else if (conf.av_bracket_value>=(sizeof(modes)/sizeof(modes[0])))
1521        conf.av_bracket_value=0;
1522
1523    return modes[conf.av_bracket_value];
1524}
1525
1526const char* gui_subj_dist_bracket_koef_enum(int change, int arg) {
1527    static const char* modes[]={"Off", "1", "10","100","1000"};
1528
1529    conf.subj_dist_bracket_koef+=change;
1530    if (conf.subj_dist_bracket_koef<0)
1531        conf.subj_dist_bracket_koef=sizeof(modes)/sizeof(modes[0])-1;
1532    else if (conf.subj_dist_bracket_koef>=(sizeof(modes)/sizeof(modes[0])))
1533        conf.subj_dist_bracket_koef=0;
1534   
1535    return modes[conf.subj_dist_bracket_koef];
1536}
1537
1538const char* gui_iso_bracket_koef_enum(int change, int arg) {
1539    static const char* modes[]={ "Off","1", "10","100"};
1540
1541    conf.iso_bracket_koef+=change;
1542    if (conf.iso_bracket_koef<0)
1543        conf.iso_bracket_koef=sizeof(modes)/sizeof(modes[0])-1;
1544    else if (conf.iso_bracket_koef>=(sizeof(modes)/sizeof(modes[0])))
1545        conf.iso_bracket_koef=0;
1546   
1547    return modes[conf.iso_bracket_koef];
1548}
1549
1550const char* gui_bracket_type_enum(int change, int arg) {
1551    static const char* modes[]={ "+/-", "-","+"};
1552
1553    conf.bracket_type+=change;
1554    if (conf.bracket_type<0)
1555        conf.bracket_type=0;
1556    else if (conf.bracket_type>=(sizeof(modes)/sizeof(modes[0])))
1557        conf.bracket_type=sizeof(modes)/sizeof(modes[0])-1;
1558
1559    return modes[conf.bracket_type];
1560}
1561
1562const char* gui_tv_override_koef_enum(int change, int arg) {
1563    static const char* modes[]={"Off", "1/100K", "1/10000", "1/1000","1/100","1/10", "1","10","100"};
1564
1565    conf.tv_override_koef+=change;
1566   if (conf.tv_enum_type) {
1567     if (conf.tv_override_koef<0)  conf.tv_override_koef=6;
1568     else if (conf.tv_override_koef>6) conf.tv_override_koef=0;
1569     else if (conf.tv_override_koef==1)  conf.tv_override_koef=6;
1570     else if (conf.tv_override_koef==5)  conf.tv_override_koef=0;
1571     else if (conf.tv_override_koef!=0 && conf.tv_override_koef!=6) conf.tv_override_koef=6;
1572     }
1573   else {
1574    if (conf.tv_override_koef<0)
1575        conf.tv_override_koef=sizeof(modes)/sizeof(modes[0])-1;
1576    else if (conf.tv_override_koef>=(sizeof(modes)/sizeof(modes[0])))
1577        conf.tv_override_koef=0;
1578    }
1579   
1580    return modes[conf.tv_override_koef];
1581}
1582
1583const char* gui_tv_override_value_enum(int change, int arg) {
1584    static const char* modes[]={"64","50.8", "40.3", "32", "25.4","20","16", "12.7", "10","8", "6.3","5","4","3.2", "2.5","2", "1.6", "1.3", "1", "0.8", "0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13", "1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125", "1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640","1/800", "1/1000", "1/1250", "1/1600","1/2000","1/2500","1/3200","1/4000", "1/5000", "1/6400", "1/8000", "1/10000", "1/12500", "1/16000", "1/20000", "1/25000", "1/32000", "1/40000", "1/50000", "1/64000","1/80000", "1/100k"};
1585    static char *buf;
1586
1587    conf.tv_override_value+=change;
1588    if (conf.tv_enum_type) {
1589       if (conf.tv_override_value<0) {
1590          conf.tv_override_value=sizeof(modes)/sizeof(modes[0])-1;
1591        }
1592       else if (conf.tv_override_value>=(sizeof(modes)/sizeof(modes[0])))
1593         conf.tv_override_value=0;
1594       return modes[conf.tv_override_value];
1595     }
1596     else
1597      {
1598       if (conf.tv_override_value<0) {
1599          conf.tv_override_value=100;
1600        }
1601       else if (conf.tv_override_value>100)  conf.tv_override_value=0;
1602       if(!buf) buf=malloc(4);
1603       if(!buf) return "";
1604       sprintf(buf, "%d",  conf.tv_override_value);
1605       return buf;
1606      }
1607}
1608
1609const char* gui_tv_enum_type_enum(int change, int arg) {
1610    static const char* modes[]={"Factor", "Ev Step"};
1611
1612    conf.tv_enum_type+=change;
1613    if (conf.tv_enum_type<0)
1614        conf.tv_enum_type=sizeof(modes)/sizeof(modes[0])-1;
1615    else if (conf.tv_enum_type>=(sizeof(modes)/sizeof(modes[0])))
1616        conf.tv_enum_type=0;
1617    if (change) {
1618      conf.tv_override_koef=6; 
1619          if (conf.tv_enum_type) 
1620             conf.tv_override_value=18;
1621          else conf.tv_override_value=1;
1622      }
1623    return modes[conf.tv_enum_type];
1624}
1625
1626
1627const char* gui_iso_override_koef_enum(int change, int arg) {
1628    static const char* modes[]={ "Off","1", "10","100"};
1629
1630    conf.iso_override_koef+=change;
1631    if (conf.iso_override_koef<0)
1632        conf.iso_override_koef=0;
1633    else if (conf.iso_override_koef>=(sizeof(modes)/sizeof(modes[0])))
1634        conf.iso_override_koef=sizeof(modes)/sizeof(modes[0])-1;
1635   
1636    return modes[conf.iso_override_koef];
1637}
1638
1639const char* gui_subj_dist_override_value_enum(int change, int arg) {
1640        static const int koef[] = {0, 1,10,100,1000};
1641    static char buf[8];
1642    conf.subj_dist_override_value+=(change*koef[conf.subj_dist_override_koef]);
1643    if (conf.subj_dist_override_value<0)
1644        conf.subj_dist_override_value=MAX_DIST;
1645    else if (conf.subj_dist_override_value>MAX_DIST)
1646        conf.subj_dist_override_value=0;
1647    sprintf(buf, "%d", (int)conf.subj_dist_override_value);
1648    return buf;
1649}
1650
1651
1652const char* gui_subj_dist_override_koef_enum(int change, int arg) {
1653    static const char* modes[]={ "Off","1", "10","100","1000"};
1654
1655    conf.subj_dist_override_koef+=change;
1656    if (conf.subj_dist_override_koef<0) conf.subj_dist_override_koef=0;
1657    else if (conf.subj_dist_override_koef>=(sizeof(modes)/sizeof(modes[0])))
1658        conf.subj_dist_override_koef=sizeof(modes)/sizeof(modes[0])-1;
1659   
1660    return modes[conf.subj_dist_override_koef];
1661}
1662
1663/*
1664const char* gui_tv_exposure_order_enum(int change, int arg) {
1665    static const char* modes[]={ "Off", "1","2", "3"};
1666
1667    conf.tv_exposure_order+=change;
1668    if (conf.tv_exposure_order<0)
1669        conf.tv_exposure_order=0;
1670    else if (conf.tv_exposure_order>=(sizeof(modes)/sizeof(modes[0])))
1671        conf.tv_exposure_order=sizeof(modes)/sizeof(modes[0])-1;
1672    if((conf.tv_exposure_order>0) && (conf.av_exposure_order==conf.tv_exposure_order))
1673     {
1674       conf.av_exposure_order=0;
1675     }
1676    if((conf.tv_exposure_order>0) && (conf.iso_exposure_order==conf.tv_exposure_order))
1677     {
1678       conf.iso_exposure_order=0;
1679     }
1680
1681    return modes[conf.tv_exposure_order];
1682}
1683
1684const char* gui_av_exposure_order_enum(int change, int arg) {
1685    static const char* modes[]={ "Off", "1","2", "3"};
1686
1687    conf.av_exposure_order+=change;
1688    if (conf.av_exposure_order<0)
1689        conf.av_exposure_order=0;
1690    else if (conf.av_exposure_order>=(sizeof(modes)/sizeof(modes[0])))
1691        conf.av_exposure_order=sizeof(modes)/sizeof(modes[0])-1;
1692    if((conf.av_exposure_order>0) && (conf.tv_exposure_order==conf.av_exposure_order))
1693     {
1694       conf.tv_exposure_order=0;
1695     }
1696    if((conf.av_exposure_order>0) && (conf.iso_exposure_order==conf.av_exposure_order))
1697     {
1698       conf.iso_exposure_order=0;
1699     }
1700    return modes[conf.av_exposure_order];
1701}
1702
1703const char* gui_iso_exposure_order_enum(int change, int arg) {
1704    static const char* modes[]={ "Off", "1","2", "3"};
1705
1706    conf.iso_exposure_order+=change;
1707    if (conf.iso_exposure_order<0)
1708        conf.iso_exposure_order=0;
1709    else if (conf.iso_exposure_order>=(sizeof(modes)/sizeof(modes[0])))
1710        conf.iso_exposure_order=sizeof(modes)/sizeof(modes[0])-1;
1711    if((conf.iso_exposure_order>0) && (conf.tv_exposure_order==conf.iso_exposure_order))
1712     {
1713       conf.tv_exposure_order=0;
1714     }
1715    if((conf.iso_exposure_order>0) && (conf.av_exposure_order==conf.iso_exposure_order))
1716     {
1717       conf.av_exposure_order=0;
1718     }
1719
1720    return modes[conf.iso_exposure_order];
1721}
1722*/
1723const char* gui_av_override_enum(int change, int arg) {
1724    static char buf[8];
1725    short prop_id;
1726    conf.av_override_value+=change;
1727    if (conf.av_override_value<0) conf.av_override_value=shooting_get_aperture_sizes_table_size()+6;
1728    else if (conf.av_override_value>shooting_get_aperture_sizes_table_size()+6) conf.av_override_value=0;
1729    if (conf.av_override_value == 0)  return "Off";
1730    else {
1731     short prop_id=shooting_get_aperture_from_av96(shooting_get_av96_override_value());         
1732         sprintf(buf, "%d.%02d", (int)prop_id/100, (int)prop_id%100 );
1733         return buf;
1734        }
1735}
1736
1737#if ZOOM_OVERRIDE
1738const char* gui_zoom_override_enum(int change, int arg) {
1739    static char buf[3];
1740    conf.zoom_override_value+=change;
1741    if (conf.zoom_override_value<0) conf.zoom_override_value=zoom_points-1;
1742    else if (conf.zoom_override_value>zoom_points-1) conf.zoom_override_value=0;
1743                sprintf(buf,"%i",conf.zoom_override_value);
1744                return buf;
1745}
1746#endif
1747
1748const char* gui_user_menu_show_enum(int change, int arg) {
1749    static const char* modes[]={ "Off", "On","On Direct", "Edit" };
1750
1751        if (conf.user_menu_enable == 3) user_menu_save();
1752
1753    conf.user_menu_enable+=change;
1754    if (conf.user_menu_enable<0)
1755        conf.user_menu_enable=(sizeof(modes)/sizeof(modes[0]))-1;
1756    else if (conf.user_menu_enable>=(sizeof(modes)/sizeof(modes[0])))
1757        conf.user_menu_enable=0;
1758
1759    return modes[conf.user_menu_enable];
1760}
1761 
1762const char* gui_video_af_key_enum(int change, int arg){
1763    static const char* names[]={ "", "Shutter", "Set"};
1764    static const int keys[]={0, KEY_SHOOT_HALF, KEY_SET };
1765    int i;
1766 
1767    for (i=0; i<sizeof(names)/sizeof(names[0]); ++i) {
1768        if (conf.video_af_key==keys[i]) {
1769            break;
1770        }
1771    }
1772 
1773    i+=change;
1774    if (i<0)
1775        i=(sizeof(names)/sizeof(names[0]))-1;
1776    else if (i>=(sizeof(names)/sizeof(names[0])))
1777        i=0;
1778 
1779    conf.video_af_key = keys[i];
1780    return names[i];
1781}
1782   
1783const char* gui_bad_pixel_enum(int change, int arg) {
1784    int modes[]={LANG_MENU_BAD_PIXEL_OFF, LANG_MENU_BAD_PIXEL_INTERPOLATION, LANG_MENU_BAD_PIXEL_RAW_CONVERTER};
1785    conf.bad_pixel_removal+=change;
1786    if (conf.bad_pixel_removal<0)
1787        conf.bad_pixel_removal=(sizeof(modes)/sizeof(modes[0]))-1;
1788    else if (conf.bad_pixel_removal>=(sizeof(modes)/sizeof(modes[0])))
1789        conf.bad_pixel_removal=0;
1790 
1791    return lang_str(modes[conf.bad_pixel_removal]);
1792}
1793 
1794//-------------------------------------------------------------------
1795void gui_update_script_submenu() {
1796    register int p=0, i;
1797
1798    for (i=0; i<sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0]); ++p, ++i) {
1799        script_submenu_items[p]=script_submenu_items_top[i];
1800    }
1801    for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
1802        if (script_param_order[i]) {
1803            script_submenu_items[p].symbol=0x0;
1804            script_submenu_items[p].text=(int)script_params[script_param_order[i]-1];
1805            script_submenu_items[p].type=MENUITEM_INT;
1806            script_submenu_items[p].value=&conf.ubasic_vars[script_param_order[i]-1];
1807            ++p;
1808        }
1809    }
1810    for (i=0; i<sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0]); ++p, ++i) {
1811        script_submenu_items[p]=script_submenu_items_bottom[i];
1812    }
1813}
1814
1815//-------------------------------------------------------------------
1816
1817void raw_fselect_cb(const char * filename){
1818 struct stat st;
1819 if (!filename) return;
1820 stat((char*)filename,&st);
1821 if (st.st_size!=hook_raw_size()) return;
1822 gui_mbox_init((int)"", LANG_RAW_DEVELOP_MESSAGE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1823 raw_prepare_develop((char*)filename);
1824}
1825
1826//-------------------------------------------------------------------
1827void gui_raw_develop(int arg){
1828 int m=mode_get();
1829 gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", raw_fselect_cb);
1830}
1831
1832//-------------------------------------------------------------------
1833
1834static void gui_menuproc_reset_files(int arg){
1835conf.lang_file[0] = 0;
1836conf.menu_symbol_rbf_file[0] = 0;
1837conf.menu_rbf_file[0] = 0;
1838conf_save();
1839gui_mbox_init(LANG_INFORMATION, LANG_MENU_RESTART_CAMERA, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1840
1841}
1842
1843//-------------------------------------------------------------------
1844#ifdef OPT_DEBUGGING
1845#define TASKLIST_MAX_LINES 12 // probably as much as will fit on screen
1846#define TASKLIST_NUM_TASKS 64 // should be enough ?
1847static void gui_debug_draw_tasklist(void) {
1848#ifndef CAM_DRYOS
1849    int tasklist[TASKLIST_NUM_TASKS]; // max number of tasks we will look at
1850    char buf[40]; // a single line of the list
1851    int n_tasks,n_show_tasks,show_start;
1852    const char *name;
1853    int i;
1854    n_tasks = task_id_list_get(tasklist,sizeof(tasklist)/sizeof(tasklist[0]));
1855    show_start = debug_tasklist_start;
1856    n_show_tasks = n_tasks - show_start;
1857    // auto adjust to show the last N tasks
1858    if(n_show_tasks < TASKLIST_MAX_LINES) {
1859        show_start = n_tasks - TASKLIST_MAX_LINES;
1860        if(show_start<0)
1861            show_start = 0;
1862         n_show_tasks = n_tasks - show_start;
1863    }
1864    else if( n_show_tasks > TASKLIST_MAX_LINES ) {
1865        n_show_tasks = TASKLIST_MAX_LINES;
1866    }
1867    sprintf(buf,"%d-%d of %d tasks %c",show_start,show_start+n_show_tasks,n_tasks,debug_display_direction > 0?'+':'-');
1868    draw_string(64,0,buf, conf.osd_color);
1869    for( i = 0;  i < n_show_tasks; i++ ) {
1870        // TODO get full task info
1871        name = task_name(tasklist[show_start+i]);
1872        if ( !name || !*name ) {
1873            name = "(unknown)";
1874        }
1875        sprintf(buf,"%10s %8X",name,tasklist[show_start+i]);
1876        draw_string(64,16+16*i,buf, conf.osd_color);
1877    }
1878#endif //CAM_DRYOS
1879}
1880
1881#define DEBUG_DISPLAY_NONE 0
1882#define DEBUG_DISPLAY_PROPS 1
1883#define DEBUG_DISPLAY_PARAMS 2
1884#define DEBUG_DISPLAY_TASKS 3
1885static const char * gui_debug_shortcut_enum(int change, int arg) {
1886    static const char* modes[]={ "None", "DmpRAM", "Page", "CmpProps"};
1887
1888    conf.debug_shortcut_action += change;
1889    if (conf.debug_shortcut_action < 0)
1890        conf.debug_shortcut_action = sizeof(modes)/sizeof(modes[0])-1;
1891    else if (conf.debug_shortcut_action >= (sizeof(modes)/sizeof(modes[0])))
1892        conf.debug_shortcut_action = 0;
1893   
1894    return modes[conf.debug_shortcut_action];
1895}
1896
1897static const char * gui_debug_display_enum(int change, int arg) {
1898    static const char* modes[]={ "None", "Props", "Params", "Tasks"};
1899
1900    conf.debug_display += change;
1901    if (conf.debug_display < 0)
1902        conf.debug_display=sizeof(modes)/sizeof(modes[0])-1;
1903    else if (conf.debug_display >= (sizeof(modes)/sizeof(modes[0])))
1904        conf.debug_display = 0;
1905   
1906    return modes[conf.debug_display];
1907}
1908
1909static void gui_debug_shortcut(void) {
1910    static int lastcall = -1;
1911    int t=get_tick_count();
1912    if ( lastcall != -1) {
1913        if (t-lastcall <= 400)
1914            debug_display_direction = -debug_display_direction;
1915    }
1916    lastcall=t;
1917    switch(conf.debug_shortcut_action) {
1918        case 1:
1919            dump_memory();
1920        break;
1921        case 2:
1922            if(conf.debug_display == DEBUG_DISPLAY_TASKS) {
1923                debug_tasklist_start += debug_display_direction*(TASKLIST_MAX_LINES-2); // a little intentional overlap
1924                if(debug_tasklist_start >= TASKLIST_NUM_TASKS || debug_tasklist_start < 0)
1925                    debug_tasklist_start = 0;
1926            }
1927            else if (conf.debug_display == DEBUG_DISPLAY_PROPS || conf.debug_display == DEBUG_DISPLAY_PARAMS) {
1928                debug_propcase_page += debug_display_direction*1;
1929                if(debug_propcase_page > 128 || debug_propcase_page < 0)
1930                    debug_propcase_page = 0;
1931            }
1932        break;
1933        case 3:
1934            gui_compare_props(1);
1935        break;
1936    }
1937}
1938
1939//-------------------------------------------------------------------
1940#endif
1941
1942#if CAM_MULTIPART
1943void card_break_proc(unsigned int btn){
1944 if (btn==MBOX_BTN_YES) create_partitions();
1945}
1946
1947
1948#ifdef OPT_DEBUGGING
1949static void gui_menuproc_break_card(int arg){
1950 gui_mbox_init(LANG_WARNING, LANG_PARTITIONS_CREATE_WARNING, MBOX_BTN_YES_NO|MBOX_DEF_BTN2|MBOX_TEXT_CENTER, card_break_proc);
1951}
1952#endif
1953
1954static void gui_menuproc_swap_patitons(int arg){
1955 if (get_part_count()<2) gui_mbox_init(LANG_ERROR, LANG_ONLY_ONE_PARTITION, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1956 else
1957        {
1958                swap_partitions();
1959                gui_mbox_init(LANG_INFORMATION, LANG_SOKOBAN_MSG_FINISH_TITLE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1960        }
1961}
1962#endif
1963
1964//-------------------------------------------------------------------
1965static volatile enum Gui_Mode gui_mode;
1966static volatile int gui_restore;
1967static volatile int gui_in_redraw;
1968static int gui_splash, gui_splash_mode;
1969static char osd_buf[32];
1970#ifdef OPTIONS_AUTOSAVE
1971static Conf old_conf;
1972#endif
1973
1974//-------------------------------------------------------------------
1975void gui_init()
1976{
1977
1978    gui_mode = GUI_MODE_NONE;
1979    gui_restore = 0;
1980    gui_in_redraw = 0;
1981    if (conf.start_sound>0)
1982    {
1983        play_sound(4);
1984    }
1985    gui_splash = (conf.splash_show)?SPLASH_TIME:0;
1986    user_menu_restore();
1987    gui_lang_init();
1988    draw_init();
1989
1990    exposition_thresh = screen_size/500;
1991    voltage_step = (conf.batt_step_25)?25:1;
1992    load_bad_pixels_list("A/CHDK/badpixel");
1993    load_bad_pixels_list("A/CHDK/badpixel.txt");
1994#ifdef OPT_CURVES
1995        // initialize curves, loading files if required by current mode
1996        curve_init_mode();
1997#endif         
1998#if ZOOM_OVERRIDE
1999// reyalp - need to do this in capt_seq
2000//              if (conf.zoom_override) shooting_set_zoom(conf.zoom_override_value);
2001#endif
2002}
2003
2004static void gui_load_edge_selected( const char* fn ) {
2005    if( fn )
2006        load_edge_overlay(fn);
2007}
2008
2009//-------------------------------------------------------------------
2010#ifdef OPT_CURVES
2011static void gui_load_curve_selected(const char *fn) {
2012        if (fn) {
2013                // TODO we could sanity check here, but curve_set_type should fail gracefullish
2014                strcpy(conf.curve_file,fn);
2015                if(conf.curve_enable == 1)
2016                        curve_init_mode();
2017        }
2018}
2019
2020//-------------------------------------------------------------------
2021void gui_load_curve(int arg) {
2022    DIR   *d;
2023    char  *path = CURVE_DIR;
2024
2025    // if exists CURVE_DIR go into
2026    d=opendir(path);
2027    if (d) {
2028        closedir(d);
2029    } else {
2030        path="A";
2031    }
2032
2033    gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, path, gui_load_curve_selected);
2034}
2035
2036#endif
2037//-------------------------------------------------------------------
2038enum Gui_Mode gui_get_mode() {
2039    return gui_mode;
2040}
2041
2042//-------------------------------------------------------------------
2043void gui_set_mode(enum Gui_Mode mode) {
2044    gui_mode = mode;
2045}
2046
2047//-------------------------------------------------------------------
2048void gui_force_restore() {
2049    gui_restore = gui_in_redraw;
2050}
2051
2052static void gui_handle_splash(void) {
2053        static char *logo = NULL;
2054    static int logo_size;
2055    if (gui_splash) {
2056                static int need_logo=1; // don't use logo ptr, since we don't want to keep re-trying
2057                if(need_logo) {
2058                const char *logo_name="A/CHDK/DATA/logo.dat";
2059            FILE *fd;
2060            struct stat st;
2061                        need_logo=0;
2062            if (stat(logo_name,&st) == 0) {
2063                                logo_size=st.st_size;
2064                                logo=malloc(logo_size);
2065                                if(logo) {
2066                                        fd = fopen(logo_name, "rb");
2067                                        if(fd){
2068                                                fread(logo,1,logo_size,fd);
2069                                                fclose(fd);
2070                                        }
2071                                        else {
2072                                                free(logo);
2073                                                logo=NULL;
2074                                        }
2075                }
2076                        }
2077                }
2078        if (gui_splash>(SPLASH_TIME-4)) {
2079            gui_draw_splash(logo,logo_size);
2080           //   conf.show_osd = 0;
2081        } else if (gui_splash==1 && (mode_get()&MODE_MASK) == gui_splash_mode && (gui_mode==GUI_MODE_NONE || gui_mode==GUI_MODE_ALT)) {
2082            draw_restore();
2083           // conf.show_osd = 1; //had to uncomment in order to fix a bug with disappearing osd...
2084        }
2085        --gui_splash;
2086                if(!gui_splash) {
2087                        free(logo);
2088                }
2089    }
2090}
2091
2092//-------------------------------------------------------------------
2093void gui_redraw()
2094{
2095    enum Gui_Mode gui_mode_old;
2096    static int show_script_console=0;
2097
2098        gui_handle_splash();
2099
2100    gui_in_redraw = 1;
2101    gui_mode_old = gui_mode;
2102
2103    switch (gui_mode) {
2104        case GUI_MODE_MENU:
2105            gui_menu_draw();
2106//            draw_txt_string(20, 14, "<CNF>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2107            break;
2108        case GUI_MODE_ALT:
2109            gui_draw_osd();
2110            draw_txt_string(20, 14, "<ALT>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2111            if ((mode_get()&MODE_MASK) == MODE_REC) {
2112                draw_txt_string(0, 14, script_title, MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2113                if (state_kbd_script_run) show_script_console=5;
2114                if (show_script_console) {
2115                    --show_script_console;
2116                    md_draw_grid();
2117                    script_console_draw();
2118                }
2119            }
2120            break;
2121        case GUI_MODE_NONE:
2122            gui_draw_osd();
2123            break;
2124        case GUI_MODE_PALETTE:
2125            gui_palette_draw();
2126            break;
2127        case GUI_MODE_MBOX:
2128            gui_mbox_draw();
2129            break;
2130#ifdef OPT_GAME_REVERSI
2131        case GUI_MODE_REVERSI:
2132            gui_reversi_draw();
2133            break;
2134#endif
2135#ifdef OPT_GAME_SOKOBAN
2136        case GUI_MODE_SOKOBAN:
2137            gui_sokoban_draw();
2138            break;
2139#endif
2140#ifdef OPT_GAME_CONNECT4
2141        case GUI_MODE_4WINS:
2142            gui_4wins_draw();
2143            break;
2144#endif
2145#ifdef OPT_GAME_MASTERMIND
2146        case GUI_MODE_MASTERMIND:
2147            gui_mastermind_draw();
2148            break;
2149#endif
2150#ifdef OPT_DEBUGGING
2151        case GUI_MODE_DEBUG:
2152            gui_debug_draw();
2153            break;
2154#endif
2155        case GUI_MODE_FSELECT:
2156            gui_fselect_draw();
2157            break;
2158#ifdef OPT_TEXTREADER
2159        case GUI_MODE_READ:
2160            gui_read_draw();
2161            break;
2162#endif
2163        case GUI_MODE_OSD:
2164            gui_osd_draw();
2165//            draw_txt_string(20, 14, "<OSD>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2166            break;
2167#ifdef OPT_CALENDAR
2168        case GUI_MODE_CALENDAR:
2169            gui_calendar_draw();
2170            break;
2171#endif
2172#ifdef OPT_DEBUGGING
2173        case GUI_MODE_BENCH:
2174            gui_bench_draw();
2175            break;
2176#endif
2177        case GUI_MODE_MPOPUP:
2178            gui_mpopup_draw();
2179            break;
2180        default:
2181            break;
2182    }
2183   
2184    gui_in_redraw = 0;
2185    if ((gui_mode_old != gui_mode && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT) && (gui_mode != GUI_MODE_MBOX && gui_mode != GUI_MODE_MPOPUP)) || gui_restore) {
2186        gui_restore = 0;
2187        if (gui_mode != GUI_MODE_REVERSI && gui_mode != GUI_MODE_SOKOBAN && gui_mode != GUI_MODE_4WINS && gui_mode != GUI_MODE_MASTERMIND)
2188            draw_restore();
2189    }
2190}
2191
2192#ifdef OPTIONS_AUTOSAVE
2193//-------------------------------------------------------------------
2194static inline void conf_store_old_settings() {
2195    old_conf=conf;
2196}
2197
2198//-------------------------------------------------------------------
2199static inline int conf_save_new_settings_if_changed() {
2200    if (memcmp(&old_conf, &conf, sizeof(Conf)) != 0) {
2201                user_menu_save();
2202        conf_save();
2203        conf_store_old_settings();
2204        return 1;
2205    }
2206    return 0;
2207}
2208#endif
2209
2210
2211//-------------------------------------------------------------------
2212void gui_kbd_process()
2213{
2214    int clicked_key;
2215
2216    if (kbd_is_key_clicked(KEY_MENU)){
2217        switch (gui_mode) {
2218            case GUI_MODE_ALT:
2219                                if (conf.user_menu_as_root && (conf.user_menu_enable != 0)) {
2220                                if (kbd_is_key_pressed(KEY_SHOOT_HALF))
2221                                        gui_menu_init(&root_menu);
2222                                else
2223                gui_menu_init(&user_submenu);
2224                                }
2225                                else {
2226                                if ((conf.user_menu_enable != 0) && kbd_is_key_pressed(KEY_SHOOT_HALF))
2227                                        gui_menu_init(&user_submenu);
2228                                else
2229                gui_menu_init(&root_menu);
2230                                }
2231                gui_mode = GUI_MODE_MENU;
2232                draw_restore();
2233                break;
2234            case GUI_MODE_MENU:
2235#ifdef OPTIONS_AUTOSAVE
2236                conf_save_new_settings_if_changed();
2237#endif
2238                                if (gui_user_menu_flag) {
2239                        gui_mode = GUI_MODE_MENU;
2240                                        gui_user_menu_flag = 0;
2241                                        gui_menu_init(&root_menu);
2242                                }
2243                                else
2244                gui_mode = GUI_MODE_ALT;
2245                draw_restore();
2246                break;
2247            case GUI_MODE_PALETTE:
2248            case GUI_MODE_REVERSI:
2249            case GUI_MODE_SOKOBAN:
2250            case GUI_MODE_4WINS:
2251                        case GUI_MODE_MASTERMIND:
2252#ifdef OPT_DEBUGGING
2253            case GUI_MODE_DEBUG:
2254#endif
2255            case GUI_MODE_OSD:
2256#ifdef OPT_CALENDAR
2257            case GUI_MODE_CALENDAR:
2258#endif
2259            case GUI_MODE_BENCH:
2260                draw_restore();
2261                gui_mode = GUI_MODE_MENU;
2262                break;
2263            case GUI_MODE_FSELECT:
2264                gui_fselect_kbd_process();
2265                break;
2266#ifdef OPT_TEXTREADER
2267            case GUI_MODE_READ:
2268                gui_read_kbd_process();
2269                draw_restore();
2270                gui_mode = GUI_MODE_MENU;
2271                break;
2272#endif
2273            default:
2274                break;
2275        }
2276        return;
2277    }
2278   
2279    switch (gui_mode) {
2280        case GUI_MODE_ALT:
2281            if (kbd_is_key_clicked(SHORTCUT_TOGGLE_RAW)) {
2282                if (conf.debug_shortcut_action > 0) {
2283#ifdef OPT_DEBUGGING
2284 gui_debug_shortcut();
2285#endif
2286}
2287#if !CAM_HAS_ERASE_BUTTON && CAM_CAN_SD_OVERRIDE
2288                if (!shooting_get_common_focus_mode())
2289#else               
2290                                else
2291#endif                                                 
2292                                   {conf.save_raw = !conf.save_raw;
2293                    draw_restore();
2294                   }
2295#if !CAM_HAS_ERASE_BUTTON && CAM_CAN_SD_OVERRIDE
2296                                else {
2297   #if CAM_HAS_ZOOM_LEVER
2298               conf.subj_dist_override_value=MAX_DIST;
2299               shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2300   #else
2301               if (conf.subj_dist_override_koef==4)
2302                  gui_subj_dist_override_koef_enum(-3,0);
2303               else
2304                  gui_subj_dist_override_koef_enum(1,0);
2305   #endif
2306                                }
2307#endif
2308            } else if (kbd_is_key_clicked(KEY_SET)) {
2309                gui_menu_init(&script_submenu);
2310                gui_mode = GUI_MODE_MENU;
2311                draw_restore();
2312            } else {
2313#if !CAM_HAS_MANUAL_FOCUS && CAM_CAN_SD_OVERRIDE
2314                        if (kbd_is_key_clicked(SHORTCUT_MF_TOGGLE)) {
2315                              if (conf.subj_dist_override_koef>0)
2316                                     conf.subj_dist_override_koef=0;
2317                              else conf.subj_dist_override_koef=1;
2318                              draw_restore();
2319                             }
2320                else if (shooting_get_common_focus_mode())
2321#elif CAM_CAN_SD_OVERRIDE
2322               if (shooting_get_common_focus_mode())
2323#endif
2324
2325#if CAM_CAN_SD_OVERRIDE           
2326                          {
2327  #if CAM_HAS_ZOOM_LEVER
2328                                if (kbd_is_key_clicked(KEY_RIGHT)) {
2329                                  gui_subj_dist_override_koef_enum(1,0);
2330    #if !CAM_HAS_MANUAL_FOCUS
2331                  if (conf.subj_dist_override_koef==0) conf.subj_dist_override_koef=1;
2332    #endif
2333                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2334                                  }
2335                                else if (kbd_is_key_clicked(KEY_LEFT))
2336                                  {
2337                                  gui_subj_dist_override_koef_enum(-1,0);
2338    #if !CAM_HAS_MANUAL_FOCUS
2339                  if (conf.subj_dist_override_koef==0) conf.subj_dist_override_koef=1;
2340    #endif
2341                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2342                                  }
2343                                else if (kbd_is_key_clicked(SHORTCUT_SET_INFINITY))
2344                                  {
2345                                  conf.subj_dist_override_value=MAX_DIST;       
2346                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2347                                  }
2348                                else
2349  #endif
2350                                if (kbd_is_key_clicked(SHORTCUT_SET_HYPERFOCAL))
2351                                  {     
2352                                  int m=mode_get()&MODE_SHOOTING_MASK;
2353                                  if ((m==MODE_M) || (m==MODE_AV))
2354                                    conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance_f(shooting_get_aperture_from_av96(shooting_get_user_av96()),get_focal_length(lens_get_zoom_point()));
2355                                  else conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance();           
2356                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2357                                  }   
2358                                else 
2359                  switch (kbd_get_autoclicked_key()) {
2360  #if CAM_HAS_ZOOM_LEVER
2361                    case KEY_ZOOM_IN:
2362  #else
2363                    case KEY_RIGHT:
2364  #endif
2365                        gui_subj_dist_override_value_enum(1,0);
2366                        shooting_set_focus(shooting_get_subject_distance_override_value(),SET_NOW);
2367                        break;
2368  #if CAM_HAS_ZOOM_LEVER
2369                    case KEY_ZOOM_OUT:
2370  #else
2371                    case KEY_LEFT:
2372  #endif
2373                        gui_subj_dist_override_value_enum(-1,0);
2374                        shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2375                        break;
2376                  }
2377              }
2378#endif                           
2379            }
2380            break;
2381        case GUI_MODE_MENU:
2382            gui_menu_kbd_process();
2383            break;
2384        case GUI_MODE_PALETTE:
2385            gui_palette_kbd_process();
2386            break;
2387        case GUI_MODE_MBOX:
2388            gui_mbox_kbd_process();
2389            break;
2390#ifdef OPT_GAME_REVERSI
2391        case GUI_MODE_REVERSI:
2392            gui_reversi_kbd_process();
2393            break;
2394#endif
2395#ifdef OPT_GAME_SOKOBAN
2396        case GUI_MODE_SOKOBAN:
2397            gui_sokoban_kbd_process();
2398            break;
2399#endif
2400#ifdef OPT_GAME_CONNECT4
2401        case GUI_MODE_4WINS:
2402            gui_4wins_kbd_process();
2403            break;
2404#endif
2405#ifdef OPT_GAME_MASTERMIND
2406        case GUI_MODE_MASTERMIND:
2407            gui_mastermind_kbd_process();
2408            break;
2409#endif
2410#ifdef OPT_DEBUGGING
2411        case GUI_MODE_DEBUG:
2412            gui_debug_kbd_process();
2413            break;
2414#endif
2415        case GUI_MODE_FSELECT:
2416            gui_fselect_kbd_process();
2417            break;
2418#ifdef OPT_TEXTREADER
2419        case GUI_MODE_READ:
2420            gui_read_kbd_process();
2421            break;
2422#endif
2423        case GUI_MODE_OSD:
2424            gui_osd_kbd_process();
2425            break;
2426#ifdef OPT_CALENDAR
2427        case GUI_MODE_CALENDAR:
2428            gui_calendar_kbd_process();
2429            break;
2430#endif
2431#ifdef OPT_DEBUGGING
2432        case GUI_MODE_BENCH:
2433            gui_bench_kbd_process();
2434            break;
2435#endif
2436        case GUI_MODE_MPOPUP:
2437            gui_mpopup_kbd_process();
2438             break;
2439        default:
2440            break;
2441    }
2442}
2443
2444//-------------------------------------------------------------------
2445void gui_kbd_enter()
2446{
2447    // XXX set custom palette
2448#ifdef OPTIONS_AUTOSAVE
2449    conf_store_old_settings();
2450#endif
2451    if ((conf.alt_prevent_shutdown == ALT_PREVENT_SHUTDOWN_ALT && !state_kbd_script_run)
2452        || conf.alt_prevent_shutdown == ALT_PREVENT_SHUTDOWN_ALT_SCRIPT) {
2453        disable_shutdown();
2454    }
2455    gui_mode = GUI_MODE_ALT;
2456
2457        gui_user_menu_flag = 0;
2458        if (conf.user_menu_enable == 2) {
2459                gui_menu_init(&user_submenu);
2460                gui_mode = GUI_MODE_MENU;
2461                draw_restore();
2462                gui_user_menu_flag = 1;
2463        }
2464
2465}
2466
2467//-------------------------------------------------------------------
2468void gui_kbd_leave()
2469{
2470    // XXX restore palette
2471#ifdef OPTIONS_AUTOSAVE
2472    conf_save_new_settings_if_changed();
2473#endif
2474    ubasic_error = 0;
2475    draw_restore();
2476    if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file))
2477        rbf_load_from_8x16(current_font);
2478    rbf_set_codepage(FONT_CP_WIN);
2479    enable_shutdown();
2480    gui_mode = GUI_MODE_NONE;
2481}
2482//-------------------------------------------------------------------
2483 
2484void other_kbd_process(){
2485 int key;
2486#if CAM_AF_SCAN_DURING_VIDEO_RECORD
2487   
2488 if (movie_status==VIDEO_RECORD_IN_PROGRESS) {
2489  if (kbd_is_key_clicked(conf.video_af_key)) MakeAFScan();
2490 }
2491 
2492#endif
2493
2494#if CAM_CAN_UNLOCK_OPTICAL_ZOOM_IN_VIDEO
2495 // return from digital to optical zoom in video
2496#if CAM_HAS_ZOOM_LEVER
2497   key=KEY_ZOOM_OUT;
2498#else
2499   key=KEY_DOWN;
2500#endif
2501    if (conf.unlock_optical_zoom_for_video && (movie_status==VIDEO_RECORD_IN_PROGRESS) &&  kbd_is_key_clicked(key)){
2502     short x;
2503     get_property_case(PROPCASE_DIGITAL_ZOOM_STATE, &x, sizeof(x));
2504     if (x) {
2505      get_property_case(PROPCASE_DIGITAL_ZOOM_POSITION, &x, sizeof(x));
2506      if (x==0) zoom_status=ZOOM_OPTICAL_MEDIUM;
2507     }
2508    }
2509#endif
2510
2511#if CAM_EV_IN_VIDEO
2512 if ((movie_status==VIDEO_RECORD_IN_PROGRESS) && !kbd_is_key_pressed(KEY_SHOOT_HALF)){
2513  #if CAM_HAS_ERASE_BUTTON
2514  if (kbd_is_key_clicked(KEY_ERASE)){
2515  #else
2516  if (kbd_is_key_clicked(KEY_DISPLAY)){
2517  #endif
2518   set_ev_video_avail(!get_ev_video_avail());
2519  }
2520  if (get_ev_video_avail()) {
2521   if (kbd_is_key_clicked(KEY_LEFT)) {
2522    set_ev_video(get_ev_video()-1);
2523   }
2524   if (kbd_is_key_clicked(KEY_RIGHT)){
2525    set_ev_video(get_ev_video()+1);
2526   }
2527  }
2528 }
2529#endif
2530}
2531
2532//-------------------------------------------------------------------
2533//extern int xxxx, eeee;
2534//-------------------------------------------------------------------
2535void gui_draw_osd() {
2536    unsigned int m, n = 0, mode_photo, mode_video;
2537    coord x;
2538#if CAM_SWIVEL_SCREEN
2539    static int flashlight = 0;
2540#endif
2541    static int pressed = 0;
2542    static int half_disp_press_old=0;
2543    int half_disp_press;
2544    int need_restore = 0;
2545    m = mode_get();
2546
2547#if CAM_SWIVEL_SCREEN
2548    if (conf.flashlight && (m&MODE_SCREEN_OPENED) && (m&MODE_SCREEN_ROTATED) && (gui_mode==GUI_MODE_NONE /* || gui_mode==GUI_MODE_ALT */)) {
2549        draw_filled_rect(0, 0, screen_width-1, screen_height-1, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE));
2550        flashlight = 1;
2551    }
2552    if (flashlight) {
2553        if ((!((m&MODE_SCREEN_OPENED) && (m&MODE_SCREEN_ROTATED))) || (gui_mode!=GUI_MODE_NONE /* && gui_mode!=GUI_MODE_ALT */)) {
2554            flashlight = 0;
2555                        need_restore = 1;
2556        } else {
2557                        return;
2558                }
2559    }
2560#endif
2561   
2562    if (kbd_is_key_pressed(KEY_SHOOT_HALF)) {
2563        if (kbd_is_key_pressed(SHORTCUT_TOGGLE_ZEBRA)) {
2564            if (!pressed) {
2565                conf.zebra_draw = !conf.zebra_draw;
2566                if (!conf.zebra_draw) {
2567                                        need_restore = 1;
2568                }
2569                pressed = 1;
2570            }
2571        } else if (kbd_is_key_pressed(SHORTCUT_TOGGLE_HISTO)) {
2572            if (!pressed) {
2573                if (++conf.show_histo>SHOW_HALF) conf.show_histo=0;
2574                if (!conf.show_histo) {
2575                                        need_restore = 1;
2576                }
2577                pressed = 1;
2578            }
2579        } else if (kbd_is_key_pressed(SHORTCUT_TOGGLE_OSD)) {
2580            if (!pressed) {
2581                conf.show_osd = !conf.show_osd;
2582                if (!conf.show_osd) {
2583                                        need_restore = 1;
2584                }
2585                pressed = 1;
2586            }
2587        } else if (kbd_is_key_pressed(SHORTCUT_DISABLE_OVERRIDES)) {
2588             if (!pressed) {
2589                 if (conf.override_disable < 2) conf.override_disable = !conf.override_disable;
2590                 if (!conf.show_osd) {
2591                                        need_restore = 1;
2592                 }
2593                 pressed = 1;
2594             }
2595        } else {
2596            pressed = 0;
2597        }
2598    } else {
2599        pressed = 0;
2600    }
2601   
2602        // TODO some of the ifs below should probably use this
2603        mode_video = MODE_IS_VIDEO(m);
2604
2605    mode_photo = (m&MODE_MASK) == MODE_PLAY ||
2606                 !( mode_video ||
2607                                 (m&MODE_SHOOTING_MASK)==MODE_STITCH);
2608
2609    half_disp_press=mode_photo && kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(KEY_DISPLAY);
2610    if (half_disp_press && ! half_disp_press_old)
2611                need_restore = 1;
2612    half_disp_press_old=half_disp_press;
2613
2614        if (need_restore)
2615                draw_restore();
2616
2617    if (half_disp_press)
2618                return;
2619
2620        if (gui_osd_draw_zebra(conf.zebra_draw && gui_mode==GUI_MODE_NONE &&
2621                                                        kbd_is_key_pressed(KEY_SHOOT_HALF) && mode_photo &&
2622                                                        !state_kbd_script_run)) {// no zebra when script running, to save mem
2623                return; // if zebra drawn, we're done
2624        }
2625#if !CAM_SHOW_OSD_IN_SHOOT_MENU
2626    if (!(conf.show_osd && (canon_menu_active==(int)&canon_menu_active-4) && (canon_shoot_menu_active==0)))  return;   
2627#else
2628    if (!(conf.show_osd && (canon_menu_active==(int)&canon_menu_active-4) /*&& (canon_shoot_menu_active==0)*/ ))  return;
2629#endif 
2630
2631   
2632    if ((gui_mode==GUI_MODE_NONE || gui_mode==GUI_MODE_ALT) && (
2633     (kbd_is_key_pressed(KEY_SHOOT_HALF) && ((conf.show_histo==SHOW_HALF)/* || (m&MODE_MASK) == MODE_PLAY*/)) ||
2634     ((conf.show_histo==SHOW_ALWAYS)  &&  !((m&MODE_MASK) == MODE_PLAY) && (recreview_hold==0))
2635    ) &&
2636    (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH)) {
2637        gui_osd_draw_histo();
2638    }
2639
2640    if ((m&MODE_MASK) == MODE_REC && (recreview_hold==0 || conf.show_osd_in_review) ) {
2641//        m &= MODE_SHOOTING_MASK;
2642//        if (m==MODE_SCN_WATER || m==MODE_SCN_NIGHT || m==MODE_SCN_CHILD || m==MODE_SCN_PARTY || m==MODE_STITCH ||
2643//            m==MODE_SCN_GRASS || m==MODE_SCN_SNOW  || m==MODE_SCN_BEACH || m==MODE_SCN_FIREWORK || m==MODE_VIDEO)
2644//            ++n;
2645
2646        if (conf.show_grid_lines) {
2647            gui_grid_draw_osd(1);
2648        }
2649        if ((gui_mode==GUI_MODE_NONE || gui_mode==GUI_MODE_ALT) && (((kbd_is_key_pressed(KEY_SHOOT_HALF) || (state_kbd_script_run) || (shooting_get_common_focus_mode())) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH )) || ((mode_video || movie_status > 1) && conf.show_values_in_video) )) {
2650                 
2651           if (conf.show_dof!=DOF_DONT_SHOW) gui_osd_calc_dof();
2652           
2653           if (conf.show_dof==DOF_SHOW_IN_DOF) gui_osd_draw_dof(); 
2654           
2655           if (conf.values_show_real_iso || conf.values_show_market_iso || conf.values_show_ev_seted || conf.values_show_ev_measured || conf.values_show_bv_measured || conf.values_show_bv_seted || conf.values_show_overexposure || conf.values_show_canon_overexposure || conf.values_show_luminance) gui_osd_calc_expo_param();                       
2656        }
2657        if (conf.show_state) gui_osd_draw_state();
2658        if (conf.save_raw && conf.show_raw_state && !mode_video && (!kbd_is_key_pressed(KEY_SHOOT_HALF))) gui_osd_draw_raw_info();
2659       
2660            if ((conf.show_values==SHOW_ALWAYS && mode_photo) || ((mode_video || movie_status > 1)&& conf.show_values_in_video) || ((kbd_is_key_pressed(KEY_SHOOT_HALF) || (recreview_hold==1)) && (conf.show_values==SHOW_HALF)))
2661                   gui_osd_draw_values(1);
2662        else if  (shooting_get_common_focus_mode() && mode_photo && conf.show_values && !(conf.show_dof==DOF_SHOW_IN_DOF) )   
2663           gui_osd_draw_values(2);
2664            else if  (conf.show_values==SHOW_HALF)
2665                   gui_osd_draw_values(0);   
2666    }
2667
2668
2669    if ((recreview_hold==0) &&  (!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1))))   {
2670        gui_batt_draw_osd();
2671        gui_space_draw_osd();
2672    }
2673   
2674    if ((conf.show_clock) && (recreview_hold==0) &&  ((!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1)))|| (conf.clock_halfpress==0) )) {
2675        gui_osd_draw_clock(0,0,0);
2676    }
2677    else if ((conf.show_clock) && (recreview_hold==0) &&  kbd_is_key_pressed(KEY_SHOOT_HALF) && conf.clock_halfpress==1) {
2678        gui_osd_draw_seconds();
2679    }
2680 
2681    if ((conf.show_temp>0) && (recreview_hold==0) &&  ((!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1)) )|| (conf.clock_halfpress==0) )) {
2682        gui_osd_draw_temp();
2683    }
2684    if (conf.show_movie_time > 0 && (mode_video || movie_status > 1)) {
2685        gui_osd_draw_movie_time_left();
2686    }
2687 
2688    if ((conf.fast_ev) && (recreview_hold==0) && ((mode_get()&MODE_SHOOTING_MASK) != MODE_VIDEO_STD) && ((!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1))) )) {
2689        gui_osd_draw_ev();
2690    }
2691#if CAM_DRAW_EXPOSITION
2692    if (gui_mode==GUI_MODE_NONE && kbd_is_key_pressed(KEY_SHOOT_HALF) && ((m&MODE_MASK)==MODE_REC) && ((m&MODE_SHOOTING_MASK))!=MODE_VIDEO_STD && (m&MODE_SHOOTING_MASK)!=MODE_VIDEO_COMPACT) {
2693     strcpy(osd_buf,shooting_get_tv_str());
2694     strcat(osd_buf,"\"  F");
2695     strcat(osd_buf,shooting_get_av_str());
2696     draw_txt_string(22-strlen(osd_buf)/2, 14, osd_buf, conf.osd_color);
2697    }
2698#endif
2699
2700#if CAM_EV_IN_VIDEO
2701    if (movie_status==VIDEO_RECORD_IN_PROGRESS) gui_osd_draw_ev_video(get_ev_video_avail());
2702#endif
2703
2704#ifdef OPT_DEBUGGING
2705    if (debug_vals_show) {
2706//        long v=get_file_counter();
2707//      sprintf(osd_buf, "1:%03d-%04d  ", (v>>18)&0x3FF, (v>>4)&0x3FFF);
2708//      sprintf(osd_buf, "1:%d, %08X  ", xxxx, eeee);
2709/*
2710extern long physw_status[3];
2711        sprintf(osd_buf, "1:%8x  ", physw_status[0]);
2712        draw_txt_string(28, 10, osd_buf, conf.osd_color);
2713
2714        sprintf(osd_buf, "2:%8x  ", physw_status[1]);
2715        draw_txt_string(28, 11, osd_buf, conf.osd_color);
2716
2717        sprintf(osd_buf, "3:%8x  ", physw_status[2]);
2718        draw_txt_string(28, 12, osd_buf, conf.osd_color);
2719
2720        //      sprintf(osd_buf, "4:%8x  ", vid_get_viewport_fb_d());
2721*/
2722        sprintf(osd_buf, "u:%8x  ", get_usb_power(1));
2723        draw_txt_string(28,  9, osd_buf, conf.osd_color);
2724
2725        sprintf(osd_buf, "1:%8x  ", (void*) (*(int*)conf.mem_view_addr_init));
2726        draw_txt_string(28, 10, osd_buf, conf.osd_color);
2727
2728extern volatile long focus_busy;
2729        sprintf(osd_buf, "f:%8x  ", focus_busy);
2730        draw_txt_string(28, 11, osd_buf, conf.osd_color);
2731
2732extern volatile long zoom_busy;
2733        sprintf(osd_buf, "z:%8x  ", zoom_busy);
2734        draw_txt_string(28, 12, osd_buf, conf.osd_color);
2735
2736// some cameras missing zoom_status
2737#if 0
2738        sprintf(osd_buf, "t:%8x  ", zoom_status);
2739        draw_txt_string(28, 13, osd_buf, conf.osd_color);
2740#endif
2741
2742    }
2743
2744
2745   {
2746        static char sbuf[100];
2747    int r,i, p, len;
2748    if (conf.debug_display == DEBUG_DISPLAY_PROPS){
2749
2750        for (i=0;i<10;i++){
2751            r = 0;
2752            p = debug_propcase_page*10+i;
2753            get_property_case(p, &r, 4);
2754            sprintf(sbuf, "%3d: %d              ", p, r);sbuf[20]=0;
2755            draw_string(64,16+16*i,sbuf, conf.osd_color);
2756        }
2757    }
2758
2759    if (conf.debug_display == DEBUG_DISPLAY_PARAMS){
2760        extern long* FlashParamsTable[];
2761        char s[30];
2762        int count;
2763
2764        for (i=0;i<10;i++){
2765            r = 0;
2766            p = debug_propcase_page*10+i;
2767            if (p>=get_flash_params_count())  sprintf(sbuf, "%3d: This parameter does not exists", p);
2768            else   {
2769             len=FlashParamsTable[p][1]>>16;
2770             if ((len==1)||(len==2)||(len==4)){
2771              get_parameter_data(p, &r, len);
2772              sprintf(sbuf, "%3d: %30d :%2d ", p, r,len);
2773              }
2774             else {
2775              if (len>=sizeof(s)) count=sizeof(s)-1; else count=len;
2776              get_parameter_data(p, &s, count);
2777              s[count]=0;
2778              sprintf(sbuf, "%3d: %30s :%2d ", p, s,len);
2779             }
2780            }
2781            draw_string(16,16+16*i,sbuf, conf.osd_color);
2782        }
2783    }
2784   }
2785
2786    if(conf.debug_display == DEBUG_DISPLAY_TASKS) {
2787        gui_debug_draw_tasklist();
2788    }
2789#endif
2790    if (ubasic_error){
2791        const char *msg;
2792        if (ubasic_error >= UBASIC_E_ENDMARK) {
2793            msg = ubasic_errstrings[UBASIC_E_UNKNOWN_ERROR];
2794        } else {
2795            msg = ubasic_errstrings[ubasic_error];
2796        }
2797        sprintf(osd_buf, "uBASIC:%d %s ", ubasic_linenumber(), msg);
2798        draw_txt_string(0, 0, osd_buf, MAKE_COLOR(COLOR_RED, COLOR_YELLOW));
2799    }
2800}
2801
2802#ifndef OPTIONS_AUTOSAVE
2803//-------------------------------------------------------------------
2804void gui_menuproc_save(int arg)
2805{
2806    conf_save();
2807}
2808#endif
2809
2810//-------------------------------------------------------------------
2811static void gui_menuproc_reset_selected(unsigned int btn) {
2812    if (btn==MBOX_BTN_YES)
2813        conf_load_defaults();
2814}
2815
2816void gui_menuproc_reset(int arg)
2817{
2818    gui_mbox_init(LANG_MSG_RESET_OPTIONS_TITLE,
2819                  LANG_MSG_RESET_OPTIONS_TEXT,
2820                  MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER|MBOX_BTN_YES_NO|MBOX_DEF_BTN2, gui_menuproc_reset_selected);
2821}
2822
2823//-------------------------------------------------------------------
2824void gui_draw_palette(int arg) {
2825    draw_restore();
2826    gui_palette_init(PALETTE_MODE_DEFAULT, 0x00, NULL);
2827    gui_mode = GUI_MODE_PALETTE;
2828}
2829
2830//-------------------------------------------------------------------
2831void gui_show_build_info(int arg) {
2832    static char buf[192];
2833    static char comp[64];
2834
2835#ifdef __GNUC__
2836# ifndef __GNUC_PATCHLEVEL__
2837# define __GNUC_PATCHLEVEL 0
2838# endif
2839    sprintf(comp, "GCC %d.%d.%d", __GNUC__ ,__GNUC_MINOR__,__GNUC_PATCHLEVEL__ );
2840#else
2841    sprintf(comp, "UNKNOWN" );
2842#endif
2843    sprintf(buf, lang_str(LANG_MSG_BUILD_INFO_TEXT), HDK_VERSION, BUILD_NUMBER, __DATE__, __TIME__, PLATFORM, PLATFORMSUB, comp);
2844gui_mbox_init(LANG_MSG_BUILD_INFO_TITLE, (int)buf, MBOX_FUNC_RESTORE|MBOX_TEXT_LEFT, NULL);
2845}
2846
2847//-------------------------------------------------------------------
2848void gui_show_memory_info(int arg) {
2849    static char buf[64];
2850    int size, l_size, d;
2851    char* ptr;
2852
2853    size = 16;
2854    while (1) {
2855        ptr= malloc(size);
2856        if (ptr) {
2857            free(ptr);
2858            size <<= 1;
2859        } else
2860            break;
2861    }
2862
2863    l_size = size;
2864    size >>= 1;
2865    d=1024;
2866    while (d) {
2867        ptr = malloc(size);
2868        if (ptr) {
2869            free(ptr);
2870            d = l_size-size;
2871            if (d<0) d=-d;
2872            l_size = size;
2873            size += d>>1;
2874        } else {
2875            d = size-l_size;
2876            if (d<0) d=-d;
2877            l_size = size;
2878            size -= d>>1;
2879        }
2880       
2881    }
2882   
2883    sprintf(buf, lang_str(LANG_MSG_MEMORY_INFO_TEXT), size-1,MEMISOSIZE,&_start,&_end);
2884    gui_mbox_init(LANG_MSG_MEMORY_INFO_TITLE, (int)buf, MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2885}
2886
2887//-------------------------------------------------------------------
2888#ifdef OPT_GAME_REVERSI
2889void gui_draw_reversi(int arg) {
2890    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2891        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2892                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2893        return;
2894    }
2895    gui_mode = GUI_MODE_REVERSI;
2896    gui_reversi_init();
2897}
2898#endif
2899
2900//-------------------------------------------------------------------
2901#ifdef OPT_GAME_SOKOBAN
2902void gui_draw_sokoban(int arg) {
2903    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2904        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2905                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2906        return;
2907    }
2908    if ( gui_sokoban_init() )
2909        gui_mode = GUI_MODE_SOKOBAN;
2910}
2911#endif
2912//-------------------------------------------------------------------
2913#ifdef OPT_GAME_CONNECT4
2914void gui_draw_4wins(int arg) {
2915    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2916        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2917                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2918        return;
2919    }
2920    if ( gui_4wins_init() )
2921        gui_mode = GUI_MODE_4WINS;
2922}
2923#endif
2924//-------------------------------------------------------------------
2925#ifdef OPT_GAME_MASTERMIND
2926void gui_draw_mastermind(int arg) {
2927    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2928        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2929                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2930        return;
2931    }
2932    if ( gui_mastermind_init() )
2933        gui_mode = GUI_MODE_MASTERMIND;
2934}
2935#endif
2936//-------------------------------------------------------------------
2937#ifdef OPT_DEBUGGING
2938void gui_draw_debug(int arg) {
2939//    gui_debug_init(0x2510);
2940//    gui_debug_init(0x127E0);
2941//    gui_debug_init(0x7F5B8);
2942//    gui_debug_init(malloc(16));
2943    gui_debug_init((void*)conf.mem_view_addr_init);
2944}
2945#endif
2946//-------------------------------------------------------------------
2947#ifdef OPT_DEBUGGING
2948void gui_draw_bench(int arg) {
2949    gui_mode = GUI_MODE_BENCH;
2950    gui_bench_init();
2951}
2952#endif
2953//-------------------------------------------------------------------
2954
2955void gui_draw_splash(char* logo, int logo_size) {
2956    coord w, h, x, y;
2957    static const char *text[] = {
2958        "CHDK Firmware '" HDK_VERSION " " BUILD_NUMBER "'" ,
2959        "Build: " __DATE__ " " __TIME__ ,
2960        "Camera: " PLATFORM " - " PLATFORMSUB };
2961    int i, l;
2962    color cl = MAKE_COLOR(COLOR_RED, COLOR_WHITE);
2963
2964    gui_splash_mode = (mode_get()&MODE_MASK);
2965   
2966    h=sizeof(text)/sizeof(text[0])*FONT_HEIGHT+8;
2967    w=0;
2968    for (i=0; i<sizeof(text)/sizeof(text[0]); ++i) {
2969        l=strlen(text[i]);
2970        if (l>w) w=l;
2971    }
2972    w=w*FONT_WIDTH+10;
2973
2974    x = (screen_width-w)>>1; y = ((screen_height-h)>>1) + 20;
2975    draw_filled_round_rect(x, y, x+w, y+h, MAKE_COLOR(COLOR_RED, COLOR_RED));
2976    for (i=0; i<sizeof(text)/sizeof(text[0]); ++i) {
2977        draw_string(x+((w-strlen(text[i])*FONT_WIDTH)>>1), y+i*FONT_HEIGHT+4, text[i], cl);
2978    }
2979    if(logo){
2980      int pos;
2981      int mx=0;
2982      int my=0;
2983      int offset_x = (screen_width-150)>>1;
2984      int offset_y = ((screen_height-84)>>1) - 42;
2985      const color color_lookup[8] = {0xFF, 0x2E, 0x22, 0x3D, 0x1F,  0x21, 0x00, 0x11};
2986   
2987      for(pos=0; pos<logo_size; pos++){
2988          char data = logo[pos];
2989          color c = color_lookup[(data>>5) & 0x07];
2990          for(i=0; i<(data&0x1F)+1; i++){
2991              if (c!=0x00){
2992                  draw_pixel(offset_x+mx,offset_y+my,c);
2993              }
2994              if (mx==149){
2995                  mx=0;
2996                  my++;
2997              }else{
2998                  mx++;
2999              }     
3000          }
3001      }
3002    }
3003}
3004
3005//-------------------------------------------------------------------
3006void gui_draw_fselect(int arg) {
3007    gui_fselect_init(LANG_STR_FILE_BROWSER, "A", NULL);
3008}
3009
3010//-------------------------------------------------------------------
3011static void gui_load_script_selected(const char *fn) {
3012    if (fn)
3013        script_load(fn, 1);
3014}
3015void gui_load_script(int arg) {
3016    DIR   *d;
3017    char  *path="A/CHDK/SCRIPTS";
3018
3019    // if exists "A/CHDK/SCRIPTS" go into
3020    d=opendir(path);
3021    if (d) {
3022        closedir(d);
3023    } else {
3024        path="A";
3025    }
3026
3027    gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected);
3028}
3029
3030void gui_load_script_default(int arg) {
3031    script_load(conf.script_file, 0);
3032    if (conf.script_param_save) {
3033        save_params_values(1);
3034    }
3035}
3036
3037
3038//-------------------------------------------------------------------
3039static void gui_grid_lines_load_selected(const char *fn) {
3040    if (fn)
3041        grid_lines_load(fn);
3042}
3043void gui_grid_lines_load(int arg) {
3044    DIR   *d;
3045    char  *path="A/CHDK/GRIDS";
3046
3047    // if exists "A/CHDK/GRIDS" go into
3048    d=opendir(path);
3049    if (d) {
3050        closedir(d);
3051    } else {
3052        path="A";
3053    }
3054
3055    gui_fselect_init(LANG_STR_SELECT_GRID_FILE, path, gui_grid_lines_load_selected);
3056}
3057
3058//-------------------------------------------------------------------
3059void gui_draw_osd_le(int arg) {
3060    gui_mode = GUI_MODE_OSD;
3061    gui_osd_init();
3062}
3063
3064//-------------------------------------------------------------------
3065#ifdef OPT_TEXTREADER
3066static void gui_draw_read_selected(const char *fn) {
3067    if (fn) {
3068        if (!rbf_load(conf.reader_rbf_file))
3069            rbf_load_from_8x16(current_font);
3070        rbf_set_codepage(conf.reader_codepage);
3071        gui_mode = GUI_MODE_READ;
3072        gui_read_init(fn);
3073    }
3074}
3075void gui_draw_read(int arg) {
3076    DIR   *d;
3077    char  *path="A/CHDK/BOOKS";
3078
3079    // if exists "A/CHDK/BOOKS" go into
3080    d=opendir(path);
3081    if (d) {
3082        closedir(d);
3083    } else {
3084        path="A";
3085    }
3086    gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, path, gui_draw_read_selected);
3087}
3088
3089//-------------------------------------------------------------------
3090void gui_draw_read_last(int arg) {
3091    int fd;
3092   
3093    fd = open(conf.reader_file, O_RDONLY, 0777);
3094    if (fd >= 0) {
3095        close(fd);
3096        gui_draw_read_selected(conf.reader_file);
3097    } else {
3098        gui_draw_read(arg);
3099    }
3100}
3101#endif
3102
3103//-------------------------------------------------------------------
3104void gui_menuproc_mkbootdisk(int arg) {
3105    mark_filesystem_bootable();
3106}
3107
3108void gui_menuproc_edge_free(int arg) {
3109    free_memory_edge_overlay();
3110}
3111
3112void gui_menuproc_edge_save(int arg) {
3113    save_edge_overlay();
3114}
3115
3116void gui_menuproc_edge_load(int arg) {
3117    DIR   *d;
3118    char  *path = EDGE_SAVE_DIR;
3119    const char* fn;
3120
3121    // if exists, go into
3122    d=opendir(path);
3123    if (d) {
3124        closedir(d);
3125    } else {
3126        path="A";
3127    }
3128
3129    gui_fselect_init(LANG_MENU_EDGE_LOAD, path, gui_load_edge_selected);
3130}
3131
3132//-------------------------------------------------------------------
3133#ifdef OPT_CALENDAR
3134void gui_draw_calendar(int arg) {
3135    gui_mode = GUI_MODE_CALENDAR;
3136    gui_calendar_init();
3137}
3138#endif
3139//-------------------------------------------------------------------
3140static void gui_draw_rbf_selected(const char *fn) {
3141    if (fn) {
3142        strcpy(conf.reader_rbf_file, fn);
3143    }
3144}
3145#ifdef OPT_TEXTREADER
3146void gui_draw_load_rbf(int arg) {
3147    DIR   *d;
3148    char  *path="A/CHDK/FONTS";
3149
3150    // if exists "A/CHDK/FONTS" go into
3151    d=opendir(path);
3152    if (d) {
3153        closedir(d);
3154    } else {
3155        path="A";
3156    }
3157
3158    gui_fselect_init(LANG_STR_SELECT_FONT_FILE, path, gui_draw_rbf_selected);
3159}
3160#endif
3161//-------------------------------------------------------------------
3162static void gui_draw_menu_rbf_selected(const char *fn) {
3163    if (fn) {
3164        strcpy(conf.menu_rbf_file, fn);
3165        if (!rbf_load(conf.menu_rbf_file))
3166            rbf_load_from_8x16(current_font);
3167        rbf_set_codepage(FONT_CP_WIN);
3168        gui_menu_init(NULL);
3169    }
3170}
3171void gui_draw_load_menu_rbf(int arg) {
3172    DIR   *d;
3173    char  *path="A/CHDK/FONTS";
3174
3175    // if exists "A/CHDK/FONTS" go into
3176    d=opendir(path);
3177    if (d) {
3178        closedir(d);
3179    } else {
3180        path="A";
3181    }
3182
3183    gui_fselect_init(LANG_STR_SELECT_FONT_FILE, path, gui_draw_menu_rbf_selected);
3184}
3185
3186//-------------------------------------------------------------------
3187static void gui_draw_symbol_rbf_selected(const char *fn) {
3188    if (fn) {
3189        strcpy(conf.menu_symbol_rbf_file, fn);
3190        if(!rbf_load_symbol(conf.menu_symbol_rbf_file)) conf.menu_symbol_enable=0;              //AKA
3191        gui_menu_init(NULL);
3192    }
3193}
3194void gui_draw_load_symbol_rbf(int arg) {
3195    DIR   *d;
3196    char  *path="A/CHDK/SYMBOLS";
3197
3198    // if exists "A/CHDK/FONTS" go into
3199    d=opendir(path);
3200    if (d) {
3201        closedir(d);
3202    } else {
3203        path="A";
3204    }
3205
3206    gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, path, gui_draw_symbol_rbf_selected);
3207}
3208
3209//-------------------------------------------------------------------
3210static void gui_draw_lang_selected(const char *fn) {
3211    if (fn) {
3212        strcpy(conf.lang_file, fn);
3213        lang_load_from_file(conf.lang_file);
3214        gui_menu_init(NULL);
3215    }
3216}
3217void gui_draw_load_lang(int arg) {
3218    DIR   *d;
3219    char  *path="A/CHDK/LANG";
3220
3221    // if exists "A/CHDK/LANG" go into
3222    d=opendir(path);
3223    if (d) {
3224        closedir(d);
3225    } else {
3226        path="A";
3227    }
3228
3229    gui_fselect_init(LANG_STR_SELECT_LANG_FILE, path, gui_draw_lang_selected);
3230}
3231
3232int find_mnu(CMenu *curr_menu, int mnu, int count)
3233{
3234        int gui_menu_curr_item;
3235
3236        gui_menu_curr_item = 0;
3237        while(curr_menu->menu[gui_menu_curr_item].text) {
3238                if (curr_menu->menu[gui_menu_curr_item].text == mnu){
3239                        user_submenu_items[count] = curr_menu->menu[gui_menu_curr_item];
3240                        return 1;
3241                }
3242                if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_SUBMENU)
3243                        if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU)
3244                                if (find_mnu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), mnu, count)) return 1;
3245                gui_menu_curr_item++;
3246        }
3247        return 0;
3248}
3249
3250void user_menu_save() {
3251    int x;
3252        for (x=0; x<USER_MENU_ITEMS; x++) {
3253                /*
3254                 * First entry in user_submenu_items is reserved for the "Main Menu"
3255                 * conf.user_menu_vars only traks/saves the real user entries.
3256                 */
3257                conf.user_menu_vars[x] = user_submenu_items[x+1].text;
3258        }
3259}
3260 
3261void user_menu_restore() {
3262     int x;
3263        for (x=0; x<USER_MENU_ITEMS; x++) {
3264                /*
3265                 * First entry in user_submenu_items is reserved for the "Main Menu"
3266                 * conf.user_menu_vars only traks/saves the real user entries.
3267                 */
3268                find_mnu(&root_menu, conf.user_menu_vars[x], x+1);
3269        }
3270}
3271
3272#ifdef OPT_DEBUGGING
3273
3274void gui_compare_props(int arg)
3275{
3276        #define NUM_PROPS 512
3277        static int initialized = 0;
3278        static int props[NUM_PROPS] = { };
3279        char buf[64];
3280        int i;
3281        int p;
3282        int c;
3283
3284
3285        if( initialized )
3286        { // we have previous data set! do a comparison
3287                c = 0;
3288                for( i = 0; i < NUM_PROPS; ++i )
3289                {
3290                        p = shooting_get_prop(i);
3291                        if( props[i] != p )
3292                        {
3293                                ++c;
3294                                sprintf(buf,"%4d is %8d was %8d",i,p,props[i]);
3295                                draw_string(16,16*c,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));
3296                        }
3297                        props[i] = p;
3298                        if( c == 12 )
3299                        {
3300                                ++c;
3301                                sprintf(buf,"%s","Waiting 15 Seconds");
3302                                draw_string(16,16*c,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));
3303                                msleep(15000);
3304                                c = 0;
3305                        }
3306                }
3307                ++c;
3308                sprintf(buf,"%s","Press <ALT> to leave");
3309                draw_string(16,16*c,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));
3310        }
3311        else
3312        {
3313        // no previous data was set so we save the data initially
3314                for( i = 0; i < NUM_PROPS; ++i )
3315                {
3316                        props[i] = shooting_get_prop(i);
3317                }
3318        }
3319        initialized = 1;
3320}
3321
3322#endif
Note: See TracBrowser for help on using the repository browser.