static const char* gui_script_param_set_enum(int change, int arg) { static const char* modes[]={ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Default" }; if (change != 0) { save_params_values(0); gui_enum_value_change(&conf.script_param_set,change,sizeof(modes)/sizeof(modes[0])); if ( !load_params_values(conf.script_file, conf.script_param_set) ) script_reset_to_default_params_values(); gui_update_script_submenu(); } return modes[conf.script_param_set]; }
//------------------------------------------------------------------- // PURPOSE: Load script to memory ( and free malloc previous if exists) // PARAMETERS: fn - full path of script // // RESULTS: conf.script_file // // NOTES: 1. Try to load fn, if fn or file is empty - SCRIPT_DEFAULT_FILENAME, // if default not exists - display 'NO SCRIPT' // 2. Update conf.script_file, title, submenu //------------------------------------------------------------------- void script_load(const char *fn) { char* buf; // if filename is empty, try to load default named script. // if no such one, no script will be used if ((fn == 0) || (fn[0] == 0)) fn = SCRIPT_DEFAULT_FILENAME; strcpy(conf.script_file, fn); get_last_paramset_num(); // update data paths script_scan(); // re-fill @title/@names/@range/@value + reset values to @default load_params_values(); gui_update_script_submenu(); }
//------------------------------------------------------------------- // PURPOSE: Load script to memory ( and free malloc previous if exists) // PARAMETERS: fn - full path of script // // RESULTS: conf.script_file // script_source_str - loaded script file content // // NOTES: 1. Try to load fn, if fn or file is empty - SCRIPT_DEFAULT_FILENAME, // if default not exists - use builtin // 2. Update conf.script_file, title, submenu //------------------------------------------------------------------- void script_load(const char *fn) { int size; char* buf; if(script_source_str && script_source_str != lua_script_default) free((void *)script_source_str); // if filename is empty, try to load default named script. // if no such one, lua_script_default will be used if ( !fn[0] ) { buf = load_file_to_cached( SCRIPT_DEFAULT_FILENAME, &size ); if ( buf ) fn = SCRIPT_DEFAULT_FILENAME; } else { buf = load_file_to_cached( fn, &size ); } if ( !buf ) { // if failed to load - say "internal" and raise flag need update script_source_str = lua_script_default; conf.script_file[0] = 0; } else { // if ok - set pointers to script script_source_str = buf; strcpy(conf.script_file, fn); } get_last_paramset_num( conf.script_file ); // update data paths script_scan( conf.script_file ); // re-fill @title/@names/@order/@range/@value + reset values to @default load_params_values( conf.script_file, conf.script_param_set ); gui_update_script_submenu(); }