Skip to content

Commit

Permalink
Thanks to ultimaA, Lua and ubasic optional at compile time, from http…
Browse files Browse the repository at this point in the history
  • Loading branch information
reyalP authored and reyalP committed Jan 9, 2011
1 parent bb0913e commit bd66c51
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 84 deletions.
2 changes: 2 additions & 0 deletions core/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ static void conf_change_font_cp() {
}

static void conf_change_script_file() {
#ifdef OPT_SCRIPTING
script_load(conf.script_file, 2);
#endif
}

static void conf_change_menu_rbf_file() {
Expand Down
139 changes: 81 additions & 58 deletions core/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#endif
#include "gui_grid.h"
#include "histogram.h"
#include "script.h"
#include "motion_detector.h"
#include "raw.h"
#ifdef OPT_CURVES
Expand All @@ -45,12 +44,15 @@
#ifdef OPT_EDGEOVERLAY
#include "edgeoverlay.h"
#endif
#ifdef OPT_SCRIPTING
#include "script.h"
int script_params_has_changed=0;
#endif
//-------------------------------------------------------------------

#define OPTIONS_AUTOSAVE
#define SPLASH_TIME 20

int script_params_has_changed=0;
//shortcuts
//------------------------------------------------------------------
// #define KEY_NONE (KEY_DUMMY+1)
Expand Down Expand Up @@ -144,8 +146,6 @@ static void gui_draw_mastermind(int arg);
#endif
static void gui_draw_fselect(int arg);
static void gui_draw_osd_le(int arg);
static void gui_load_script(int arg);
static void gui_load_script_default(int arg);
#ifdef OPT_TEXTREADER
static void gui_draw_read(int arg);
static void gui_draw_read_last(int arg);
Expand Down Expand Up @@ -243,8 +243,6 @@ static const char* gui_space_warn_type_enum(int change, int arg);
static const char* gui_bad_pixel_enum(int change, int arg);
static const char* gui_video_af_key_enum(int change, int arg);
static const char* gui_show_movie_time(int change, int arg);
static const char* gui_script_autostart_enum(int change, int arg);
static const char* gui_script_param_set_enum(int change, int arg);
static const char* gui_override_disable_enum(int change, int arg);
#ifdef OPT_CURVES
static const char* gui_conf_curve_enum(int change, int arg);
Expand All @@ -261,6 +259,13 @@ static void gui_menuproc_edge_load(int arg);
static const char* gui_edge_pano_enum(int change, int arg);
#endif

#ifdef OPT_SCRIPTING
static void gui_load_script(int arg);
static void gui_load_script_default(int arg);
static const char* gui_script_autostart_enum(int change, int arg);
static const char* gui_script_param_set_enum(int change, int arg);
#endif

void rinit();


Expand Down Expand Up @@ -305,6 +310,8 @@ static CMenuItem remote_submenu_items[] = {
};
static CMenu remote_submenu = {0x86,LANG_MENU_REMOTE_PARAM_TITLE, NULL, remote_submenu_items };


#ifdef OPT_SCRIPTING
static CMenuItem script_submenu_items_top[] = {
{0x35,LANG_MENU_SCRIPT_LOAD, MENUITEM_PROC, (int*)gui_load_script },
{0x5f,LANG_MENU_SCRIPT_DELAY, MENUITEM_INT|MENUITEM_F_UNSIGNED, &conf.script_shoot_delay },
Expand Down Expand Up @@ -332,7 +339,7 @@ static CMenuItem script_submenu_items_bottom[] = {
static CMenuItem script_submenu_items[sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0])+SCRIPT_NUM_PARAMS+
sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0])];
static CMenu script_submenu = {0x27,LANG_MENU_SCRIPT_TITLE, NULL, script_submenu_items };

#endif

static CMenuItem games_submenu_items[] = {
#ifdef OPT_GAME_REVERSI
Expand Down Expand Up @@ -393,7 +400,9 @@ static CMenuItem debug_submenu_items[] = {
{0x2a,LANG_MENU_DEBUG_BENCHMARK, MENUITEM_PROC, (int*)gui_draw_bench },
{0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION, MENUITEM_ENUM, (int*)gui_debug_shortcut_enum },
{0x5c,LANG_MENU_RAW_TIMER, MENUITEM_BOOL, &conf.raw_timer },
#ifdef OPT_LUA
{0x5c,LANG_MENU_LUA_RESTART, MENUITEM_BOOL, &conf.debug_lua_restart_on_error },
#endif
#if CAM_MULTIPART
{0x33,LANG_MENU_DEBUG_CREATE_MULTIPART , MENUITEM_PROC, (int*)gui_menuproc_break_card },
#endif
Expand Down Expand Up @@ -858,7 +867,9 @@ static CMenuItem root_menu_items[] = {
{0x26,LANG_MENU_MAIN_ZEBRA_PARAM, MENUITEM_SUBMENU, (int*)&zebra_submenu },
{0x22,LANG_MENU_MAIN_OSD_PARAM, MENUITEM_SUBMENU, (int*)&osd_submenu },
{0x28,LANG_MENU_MAIN_VISUAL_PARAM, MENUITEM_SUBMENU, (int*)&visual_submenu },
#ifdef OPT_SCRIPTING
{0x27,LANG_MENU_MAIN_SCRIPT_PARAM, MENUITEM_SUBMENU, (int*)&script_submenu },
#endif
{0x29,LANG_MENU_MAIN_MISC, MENUITEM_SUBMENU, (int*)&misc_submenu },
#ifndef OPTIONS_AUTOSAVE
{0x33,LANG_MENU_MAIN_SAVE_OPTIONS, MENUITEM_PROC, (int*)gui_menuproc_save },
Expand Down Expand Up @@ -1034,6 +1045,8 @@ const char* gui_conf_curve_enum(int change, int arg) {
return modes[conf.curve_enable];
}
#endif

#ifdef OPT_SCRIPTING
//-------------------------------------------------------------------
const char* gui_script_autostart_enum(int change, int arg) {
static const char* modes[]={ "Off", "On", "Once"};
Expand All @@ -1058,6 +1071,55 @@ const char* gui_script_param_set_enum(int change, int arg) {
return modes[conf.script_param_set];
}

//-------------------------------------------------------------------
void gui_update_script_submenu() {
register int p=0, i;

for (i=0; i<sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0]); ++p, ++i) {
script_submenu_items[p]=script_submenu_items_top[i];
}
for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
if (script_param_order[i]) {
script_submenu_items[p].symbol=0x0;
script_submenu_items[p].text=(int)script_params[script_param_order[i]-1];
script_submenu_items[p].type=MENUITEM_INT;
script_submenu_items[p].value=&conf.ubasic_vars[script_param_order[i]-1];
++p;
}
}
for (i=0; i<sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0]); ++p, ++i) {
script_submenu_items[p]=script_submenu_items_bottom[i];
}
}

//-------------------------------------------------------------------
static void gui_load_script_selected(const char *fn) {
if (fn)
script_load(fn, 1);
}

void gui_load_script(int arg) {
DIR *d;
char *path="A/CHDK/SCRIPTS";

// if exists "A/CHDK/SCRIPTS" go into
d=opendir(path);
if (d) {
closedir(d);
} else {
path="A";
}

gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected);
}

void gui_load_script_default(int arg) {
script_load(conf.script_file, 0);
if (conf.script_param_save) {
save_params_values(1);
}
}
#endif

//-------------------------------------------------------------------
const char* gui_override_disable_enum(int change, int arg) {
Expand Down Expand Up @@ -1290,7 +1352,9 @@ const char* gui_alt_mode_button_enum(int change, int arg) {

//-------------------------------------------------------------------
const char* gui_alt_power_enum(int change, int arg) {
static const char* modes[]={ "Never", "Alt", "Script","Always" };
// Script option is retained even if scripting is disabled, otherwise conf values will change
// Equivalent to ALT
static const char* modes[]={ "Never", "Alt", "Script", "Always" };
gui_enum_value_change(&conf.alt_prevent_shutdown,change,sizeof(modes)/sizeof(modes[0]));

conf_update_prevent_shutdown();
Expand Down Expand Up @@ -1565,27 +1629,6 @@ const char* gui_bad_pixel_enum(int change, int arg) {
int modes[]={LANG_MENU_BAD_PIXEL_OFF, LANG_MENU_BAD_PIXEL_INTERPOLATION, LANG_MENU_BAD_PIXEL_RAW_CONVERTER};
return lang_str((int)gui_change_simple_enum(&conf.bad_pixel_removal,change,(const char **)modes,sizeof(modes)/sizeof(modes[0])));
}

//-------------------------------------------------------------------
void gui_update_script_submenu() {
register int p=0, i;

for (i=0; i<sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0]); ++p, ++i) {
script_submenu_items[p]=script_submenu_items_top[i];
}
for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
if (script_param_order[i]) {
script_submenu_items[p].symbol=0x0;
script_submenu_items[p].text=(int)script_params[script_param_order[i]-1];
script_submenu_items[p].type=MENUITEM_INT;
script_submenu_items[p].value=&conf.ubasic_vars[script_param_order[i]-1];
++p;
}
}
for (i=0; i<sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0]); ++p, ++i) {
script_submenu_items[p]=script_submenu_items_bottom[i];
}
}

//-------------------------------------------------------------------

Expand Down Expand Up @@ -1873,6 +1916,7 @@ void gui_redraw()
case GUI_MODE_ALT:
gui_draw_osd();
draw_txt_string(20, 14, "<ALT>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
#ifdef OPT_SCRIPTING
if ((mode_get()&MODE_MASK) == MODE_REC) {
draw_txt_string(0, 14, script_title, MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
if (state_kbd_script_run) show_md_grid=5;
Expand All @@ -1881,6 +1925,7 @@ void gui_redraw()
md_draw_grid();
}
}
#endif
console_draw();
break;
case GUI_MODE_NONE:
Expand Down Expand Up @@ -2070,10 +2115,12 @@ void gui_kbd_process()
#endif
}
#endif
#ifdef OPT_SCRIPTING
} else if (kbd_is_key_clicked(KEY_SET)) {
gui_menu_init(&script_submenu);
gui_mode = GUI_MODE_MENU;
draw_restore();
#endif
} else {
#if !CAM_HAS_MANUAL_FOCUS && CAM_CAN_SD_OVERRIDE
if (kbd_is_key_clicked(SHORTCUT_MF_TOGGLE)) {
Expand Down Expand Up @@ -2236,7 +2283,9 @@ void gui_kbd_leave()
#ifdef OPTIONS_AUTOSAVE
conf_save_new_settings_if_changed();
#endif
ubasic_error = 0;
#ifdef OPT_UBASIC
ubasic_error = UBASIC_E_NONE;
#endif
draw_restore();
if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file))
rbf_load_from_8x16(current_font);
Expand Down Expand Up @@ -2564,6 +2613,7 @@ void gui_draw_osd() {

gui_draw_debug_vals_osd();

#ifdef OPT_UBASIC
if (ubasic_error){
const char *msg;
if (ubasic_error >= UBASIC_E_ENDMARK) {
Expand All @@ -2574,6 +2624,7 @@ void gui_draw_osd() {
sprintf(osd_buf, "uBASIC:%d %s ", ubasic_linenumber(), msg);
draw_txt_string(0, 0, osd_buf, MAKE_COLOR(COLOR_RED, COLOR_YELLOW));
}
#endif
}

#ifndef OPTIONS_AUTOSAVE
Expand Down Expand Up @@ -2771,34 +2822,6 @@ void gui_draw_fselect(int arg) {
gui_fselect_init(LANG_STR_FILE_BROWSER, "A", NULL);
}

//-------------------------------------------------------------------
static void gui_load_script_selected(const char *fn) {
if (fn)
script_load(fn, 1);
}
void gui_load_script(int arg) {
DIR *d;
char *path="A/CHDK/SCRIPTS";

// if exists "A/CHDK/SCRIPTS" go into
d=opendir(path);
if (d) {
closedir(d);
} else {
path="A";
}

gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected);
}

void gui_load_script_default(int arg) {
script_load(conf.script_file, 0);
if (conf.script_param_save) {
save_params_values(1);
}
}


//-------------------------------------------------------------------
static void gui_grid_lines_load_selected(const char *fn) {
if (fn)
Expand Down
1 change: 0 additions & 1 deletion core/gui_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "keyboard.h"
#include "conf.h"
#include "font.h"
#include "ubasic.h"
#include "gui_draw.h"

//-------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion core/gui_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "core.h"
#include "keyboard.h"
#include "conf.h"
#include "ubasic.h"
#include "font.h"
#include "lang.h"
#include "gui.h"
Expand Down
15 changes: 13 additions & 2 deletions core/kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static int nTxtbl[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13};
static int nTxtbl[]={0,1,2,3,4,5,6,7,8,9};
#endif

#ifdef OPT_SCRIPTING
// remote autostart
void script_autostart()
{
Expand All @@ -115,6 +116,8 @@ void script_autostart()
script_console_add_line("***Autostart***"); //lang_str(LANG_CONSOLE_TEXT_STARTED));
script_start_gui( 1 );
}
#endif

void exit_alt()
{
kbd_blocked = 0;
Expand Down Expand Up @@ -233,26 +236,34 @@ long kbd_process()
}
}
/*-------------------- Alex scriptless remote additions end ---------------------*/
#ifdef OPT_SCRIPTING
if (kbd_is_key_pressed(KEY_SHOOT_FULL)) {
key_pressed = 100;
if (!state_kbd_script_run) {
script_start_gui(0);
} else if (state_kbd_script_run == 2 || state_kbd_script_run == 3) {
script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
script_end();
} else if (L) {
}
#ifdef OPT_LUA
else if (L) {
state_kbd_script_run = 2;
lua_run_restore();
script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
script_end();
} else {
}
#endif
#ifdef OPT_UBASIC
else {
state_kbd_script_run = 2;
if (jump_label("restore") == 0) {
script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
script_end();
}
}
#endif
}
#endif

action_stack_process_all();
if (!state_kbd_script_run)
Expand Down
2 changes: 0 additions & 2 deletions core/luascript.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "lauxlib.h"
#include "conf.h"
#include "shot_histogram.h"
#include "ubasic.h"
#include "stdlib.h"
#include "raw.h"
#include "raw_merge.h"
Expand Down Expand Up @@ -565,7 +564,6 @@ static int luaCB_md_detect_motion( lua_State* L )
int parameters = (luaL_optnumber(L,14,1));
int pixels_step = (luaL_optnumber(L,15,6));
int msecs_before_trigger = (luaL_optnumber(L,16,0));
ubasic_set_variable(0, 0);
if(md_init_motion_detector(
columns, rows, pixel_measure_mode, detection_timeout,
measure_interval, threshold, draw_grid, 0,
Expand Down
Loading

0 comments on commit bd66c51

Please sign in to comment.