source: trunk/core/gui.c @ 769

Revision 769, 123.8 KB checked in by reyalp, 4 years ago (diff)

mantis 260: screen update fixes from mweerden. currently ixus870 only, can be ported to other cams.

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