- Timestamp:
- 11/23/11 02:27:57 (18 months ago)
- Location:
- trunk/core
- Files:
-
- 5 edited
-
conf.c (modified) (1 diff)
-
gui.c (modified) (14 diffs)
-
gui_fselect.c (modified) (4 diffs)
-
gui_fselect.h (modified) (1 diff)
-
luascript.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/conf.c
r1416 r1423 184 184 CONF_INFO( 36, conf.raw_prefix, CONF_DEF_VALUE, i:RAW_PREFIX_CRW, NULL), 185 185 CONF_INFO( 37, conf.raw_ext, CONF_DEF_VALUE, i:DEFAULT_RAW_EXT, NULL), 186 CONF_INFO( 38, conf.reader_file, CONF_DEF_PTR, ptr:"A/ README.TXT", NULL),186 CONF_INFO( 38, conf.reader_file, CONF_DEF_PTR, ptr:"A/CHDK/BOOKS/README.TXT", NULL), 187 187 CONF_INFO( 39, conf.reader_pos, CONF_DEF_VALUE, i:0, NULL), 188 188 CONF_INFO( 40, conf.sokoban_level, CONF_DEF_VALUE, i:0, NULL), -
trunk/core/gui.c
r1414 r1423 1143 1143 1144 1144 void gui_load_script(int arg) { 1145 DIR *d; 1146 char *path="A/CHDK/SCRIPTS"; 1147 1148 // if exists "A/CHDK/SCRIPTS" go into 1149 d=opendir(path); 1150 if (d) { 1151 closedir(d); 1152 } else { 1153 path="A"; 1154 } 1155 1156 gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected); 1145 gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected); 1157 1146 } 1158 1147 … … 1340 1329 "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"}; 1341 1330 */ 1342 static char *buf;1331 static char buf[4]; 1343 1332 1344 1333 // XXX This array above is redundant with platform/generic/shooting.c, this should be avoided! … … 1358 1347 } 1359 1348 else if (conf.tv_override_value>100) conf.tv_override_value=0; 1360 if(!buf) buf=malloc(4);1361 if(!buf) return "";1362 1349 sprintf(buf, "%d", conf.tv_override_value); 1363 1350 return buf; … … 1532 1519 void gui_raw_develop(int arg){ 1533 1520 int m=mode_get(); 1534 gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", raw_fselect_cb);1521 gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb); 1535 1522 } 1536 1523 … … 1696 1683 //------------------------------------------------------------------- 1697 1684 void gui_load_curve(int arg) { 1698 DIR *d; 1699 char *path = CURVE_DIR; 1700 1701 // if exists CURVE_DIR go into 1702 d=opendir(path); 1703 if (d) { 1704 closedir(d); 1705 } else { 1706 path="A"; 1707 } 1708 1709 gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, path, gui_load_curve_selected); 1685 gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 1710 1686 } 1711 1687 … … 2062 2038 { 0, 0, 0 }, 2063 2039 #endif 2064 /*GUI_MODE_MPOPUP*/ { gui_mpopup_draw, gui_mpopup_kbd_process, 0},2040 /*GUI_MODE_MPOPUP*/ { gui_mpopup_draw, gui_mpopup_kbd_process, gui_mpopup_kbd_process }, 2065 2041 #ifdef OPT_GAME_CONNECT4 2066 2042 /*GUI_MODE_4WINS*/ { gui_4wins_draw, gui_4wins_kbd_process, gui_default_kbd_process_menu_btn }, … … 2742 2718 //------------------------------------------------------------------- 2743 2719 void gui_draw_fselect(int arg) { 2744 gui_fselect_init(LANG_STR_FILE_BROWSER, "A", NULL);2720 gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 2745 2721 } 2746 2722 … … 2751 2727 } 2752 2728 void gui_grid_lines_load(int arg) { 2753 DIR *d; 2754 char *path="A/CHDK/GRIDS"; 2755 2756 // if exists "A/CHDK/GRIDS" go into 2757 d=opendir(path); 2758 if (d) { 2759 closedir(d); 2760 } else { 2761 path="A"; 2762 } 2763 2764 gui_fselect_init(LANG_STR_SELECT_GRID_FILE, path, gui_grid_lines_load_selected); 2729 gui_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 2765 2730 } 2766 2731 … … 2782 2747 } 2783 2748 } 2749 2784 2750 void gui_draw_read(int arg) { 2785 DIR *d; 2786 char *path="A/CHDK/BOOKS"; 2787 2788 // if exists "A/CHDK/BOOKS" go into 2789 d=opendir(path); 2790 if (d) { 2791 closedir(d); 2792 } else { 2793 path="A"; 2794 } 2795 gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, path, gui_draw_read_selected); 2751 gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected); 2796 2752 void gui_fselect_set_key_redraw(int n); 2797 2753 gui_fselect_set_key_redraw(1); 2798 2754 } 2799 2755 2800 //-------------------------------------------------------------------2801 2756 void gui_draw_read_last(int arg) { 2802 int fd; 2803 2804 fd = open(conf.reader_file, O_RDONLY, 0777); 2805 if (fd >= 0) { 2806 close(fd); 2757 struct stat st; 2758 if (stat(conf.reader_file,&st) == 0) { 2807 2759 gui_draw_read_selected(conf.reader_file); 2808 2760 } else { … … 2829 2781 2830 2782 void gui_menuproc_edge_load(int arg) { 2831 DIR *d; 2832 char *path = EDGE_SAVE_DIR; 2833 const char* fn; 2834 2835 // if exists, go into 2836 d=opendir(path); 2837 if (d) { 2838 closedir(d); 2839 } else { 2840 path="A"; 2841 } 2842 2843 gui_fselect_init(LANG_MENU_EDGE_LOAD, path, gui_load_edge_selected); 2783 gui_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 2844 2784 } 2845 2785 #endif … … 2860 2800 } 2861 2801 void gui_draw_load_rbf(int arg) { 2862 DIR *d; 2863 char *path="A/CHDK/FONTS"; 2864 2865 // if exists "A/CHDK/FONTS" go into 2866 d=opendir(path); 2867 if (d) { 2868 closedir(d); 2869 } else { 2870 path="A"; 2871 } 2872 2873 gui_fselect_init(LANG_STR_SELECT_FONT_FILE, path, gui_draw_rbf_selected); 2802 gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 2874 2803 } 2875 2804 #endif … … 2885 2814 } 2886 2815 void gui_draw_load_menu_rbf(int arg) { 2887 DIR *d; 2888 char *path="A/CHDK/FONTS"; 2889 2890 // if exists "A/CHDK/FONTS" go into 2891 d=opendir(path); 2892 if (d) { 2893 closedir(d); 2894 } else { 2895 path="A"; 2896 } 2897 2898 gui_fselect_init(LANG_STR_SELECT_FONT_FILE, path, gui_draw_menu_rbf_selected); 2816 gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected); 2899 2817 } 2900 2818 … … 2908 2826 } 2909 2827 void gui_draw_load_symbol_rbf(int arg) { 2910 DIR *d; 2911 char *path="A/CHDK/SYMBOLS"; 2912 2913 // if exists "A/CHDK/FONTS" go into 2914 d=opendir(path); 2915 if (d) { 2916 closedir(d); 2917 } else { 2918 path="A"; 2919 } 2920 2921 gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, path, gui_draw_symbol_rbf_selected); 2828 gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected); 2922 2829 } 2923 2830 … … 2931 2838 } 2932 2839 void gui_draw_load_lang(int arg) { 2933 DIR *d; 2934 char *path="A/CHDK/LANG"; 2935 2936 // if exists "A/CHDK/LANG" go into 2937 d=opendir(path); 2938 if (d) { 2939 closedir(d); 2940 } else { 2941 path="A"; 2942 } 2943 2944 gui_fselect_init(LANG_STR_SELECT_LANG_FILE, path, gui_draw_lang_selected); 2840 gui_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 2945 2841 } 2946 2842 -
trunk/core/gui_fselect.c
r1407 r1423 81 81 static char raw_operation; // info for process_raw_files() RAW_OPERATION_AVERAGE, RAW_OPERATION_SUM, 82 82 static int set_key_redraw_mode; // dirty hack: screen erase & mode restore done after(0) or before(1) call to fselect_on_select 83 84 //------------------------------------------------------------------- 85 static void fselect_goto_prev(int step) { 86 register int j, i; 87 88 for (j=0; j<step; ++j) { 89 if (selected->prev==top && top->prev) 90 top=top->prev; 91 if (selected->prev) 92 selected=selected->prev; 93 else 94 if (step == 1) 95 { 96 for(; selected->next; selected=selected->next); 97 for (i=0, top=selected; i<BODY_LINES-1 && top->prev; ++i, top=top->prev); 98 } 99 } 100 } 101 102 //------------------------------------------------------------------- 103 static void fselect_goto_next(int step) { 104 register int j, i; 105 struct fitem *ptr; 106 107 for (j=0; j<step; ++j) { 108 for (i=0, ptr=top; i<BODY_LINES-1 && ptr; ++i, ptr=ptr->next); 109 if (i==BODY_LINES-1 && ptr && ptr->prev==selected && ptr->next) 110 top=top->next; 111 if (selected->next) 112 selected=selected->next; 113 else 114 if (step == 1) 115 { 116 for(; top->prev; top = top->prev); 117 selected = top; 118 } 119 } 120 } 83 121 84 122 //------------------------------------------------------------------- … … 223 261 } 224 262 225 void gui_fselect_init(int title, const char* dir, void (*on_select)(const char *fn)) { 263 //------------------------------------------------------------------- 264 // Attempt to set startup directory (and file) based on input 'dir' 265 // Note: 'dir' may be a directory name or a file name (including path) 266 // Returns 1 if valid directory/file found, 0 otherwise 267 int gui_fselect_find_start_dir(const char* dir) 268 { 269 selected_file[0] = 0; 270 strcpy(current_dir, dir); 271 272 // Make sure there is something left to check 273 while (strlen(current_dir) > 0) 274 { 275 struct stat st; 276 // check if input 'dir' exists 277 if (stat(current_dir,&st) == 0) 278 { 279 // exists - check if it is a directory or file 280 if (st.st_attrib & DOS_ATTR_DIRECTORY) 281 { 282 // Directory and exists so all good 283 return 1; 284 } 285 else 286 { 287 // 'dir' is a file, extract filename to 'selected_file' and remove from 'current_dir' 288 char *p = strrchr(current_dir,'/'); 289 strcpy(selected_file, p+1); 290 *p = 0; 291 return 1; 292 } 293 } 294 else 295 { 296 // could not find 'dir' - try one level up 297 char *p = strrchr(current_dir,'/'); 298 if (p) *p = 0; 299 else return 0; 300 } 301 } 302 303 return 0; 304 } 305 306 //------------------------------------------------------------------- 307 void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)) { 226 308 int i; 227 309 … … 242 324 243 325 fselect_title = lang_str(title); 244 strcpy(current_dir, dir); 326 327 // Try and set start directory, and optionally selected file, from inputs 328 if (!gui_fselect_find_start_dir(prev_dir)) 329 if (!gui_fselect_find_start_dir(default_dir)) 330 gui_fselect_find_start_dir("A"); 331 245 332 max_dir_len = NAME_SIZE + SIZE_SIZE + SPACING; 246 333 gui_fselect_read_dir(current_dir); 247 334 top = selected = head; 248 selected_file[0] = 0; 335 336 // Find selected file if it exists in list 337 if (selected_file[0]) 338 { 339 struct fitem *p = head; 340 while (p) 341 { 342 if (strcmp(p->name,selected_file) == 0) 343 { 344 break; 345 } 346 p = p->next; 347 fselect_goto_next(1); 348 } 349 if (!p) selected_file[0] = 0; 350 } 351 249 352 fselect_on_select = on_select; 250 353 marked_operation = MARKED_OP_NONE; … … 582 685 583 686 //------------------------------------------------------------------- 584 static void fselect_goto_prev(int step) {585 register int j, i;586 587 for (j=0; j<step; ++j) {588 if (selected->prev==top && top->prev)589 top=top->prev;590 if (selected->prev)591 selected=selected->prev;592 else593 if (step == 1)594 {595 for(; selected->next; selected=selected->next);596 for (i=0, top=selected; i<BODY_LINES-1 && top->prev; ++i, top=top->prev);597 }598 }599 }600 601 //-------------------------------------------------------------------602 static void fselect_goto_next(int step) {603 register int j, i;604 struct fitem *ptr;605 606 for (j=0; j<step; ++j) {607 for (i=0, ptr=top; i<BODY_LINES-1 && ptr; ++i, ptr=ptr->next);608 if (i==BODY_LINES-1 && ptr && ptr->prev==selected && ptr->next)609 top=top->next;610 if (selected->next)611 selected=selected->next;612 else613 if (step == 1)614 {615 for(; top->prev; top = top->prev);616 selected = top;617 }618 }619 }620 621 //-------------------------------------------------------------------622 687 static void fselect_marked_toggle() { 623 688 if (selected && selected->attr != 0xFF && !(selected->attr & DOS_ATTR_DIRECTORY)) { -
trunk/core/gui_fselect.h
r1302 r1423 3 3 4 4 //------------------------------------------------------------------- 5 extern void gui_fselect_init(int title, const char* dir, void (*on_select)(const char *fn));5 extern void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 6 6 extern char* gui_fselect_result(); 7 7 extern void gui_fselect_kbd_process(); -
trunk/core/luascript.c
r1360 r1423 778 778 action_push(AS_FILE_BROWSER); 779 779 // Switch to file browser gui mode. Path can be supplied in call or defaults to "A" (root directory). 780 gui_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), file_browser_selected);780 gui_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 781 781 // Yield the script so that the action stack will process the AS_FILE_BROWSER action 782 782 return lua_yield(L, 0);
Note: See TracChangeset
for help on using the changeset viewer.