root/trunk/core/gui.c @ 736

Revision 736, 122.7 KB (checked in by phyrephox, 4 years ago)

+sx1 - port by fboesch, see  http://chdk.setepontos.com/index.php/topic,3410.0.html (beta)
* svn props for sx10

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