Previous 15994 Revisions Next

r2890 Wednesday 25th June, 2008 at 09:49:17 UTC by Nathan Woods
New File Manager now supports image creation (should be at feature parity with
the old File Manager)
[src/mess]filemngr.c

src/mess/filemngr.c
r2889r2890
55   MESS's clunky built-in file manager
66
77   TODO
8      - Support image creation; the old file manager did not do this
9        well.
10         - Should only allow image creation if the device allows
11         - Also support creation arguments
8      - Support image creation arguments
129      - Restrict directory listing by file extension
1310      - Support file manager invocation from the main menu for
1411        required images
r2889r2890
2825    CONSTANTS
2926***************************************************************************/
3027
31#define ENABLE_CREATE   0
32
3328#define SLOT_EMPTY      "[empty slot]"
3429#define SLOT_CREATE      "[create]"
3530
r2889r2890
330325{
331326   static char filename_buffer[1024];
332327
328   astring *new_path;
333329   ui_menu_item item_list[200];
334330   int menu_items = 0;
335331   filecreator_state fc_state;
336332   UINT32 selected;
337333   int visible_items;
338   int underscore_pos;
334   int underscore_pos = -1;
339335   menu_extra extra;
340336
341337   /* disassemble state */
r2889r2890
365361   extra.top = ui_get_line_height() + 3.0f * UI_BOX_TB_BORDER;
366362   extra.render = file_creator_render_extra;
367363
368   /* if we're selecting the file name, poll the keyboard */
364   /* features that are only enabled when selecting the file name */
369365   if (selected == 0)
366   {
367      /* poll the keyboard */
370368      poll_keyboard(filename_buffer, ARRAY_LENGTH(filename_buffer), is_valid_filename_char);
371369
372   /* put the underscore in the menu */
373   underscore_pos = strlen(filename_buffer);
374   snprintf(filename_buffer + underscore_pos, ARRAY_LENGTH(filename_buffer) - underscore_pos, "_");
370      /* put the underscore in the menu */
371      underscore_pos = strlen(filename_buffer);
372      snprintf(filename_buffer + underscore_pos, ARRAY_LENGTH(filename_buffer) - underscore_pos, "_");
373   }
375374
376375   /* draw the menu */
377376   visible_items = ui_menu_draw(item_list, menu_items, selected, &extra);
378377
379   /* remove the underscore */
380   filename_buffer[underscore_pos] = '\0';
378   /* remove the underscore, if present */
379   if (underscore_pos >= 0)
380      filename_buffer[underscore_pos] = '\0';
381381
382382   /* handle the keys */
383383   if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items))
384384      goto done;
385385
386386   if (input_ui_pressed(machine, IPT_UI_SELECT))
387      fatalerror("NYI");
387   {
388      switch(selected)
389      {
390         case 0:
391            /* create the image */
392            new_path = zippath_combine(astring_alloc(), astring_c(current_directory), filename_buffer);
393            image_create(selected_device, astring_c(new_path), 0, NULL);
394            astring_free(new_path);
388395
396            /* pop ourselves out */
397            ui_menu_stack_pop();
398            fc_state.i = ui_menu_stack_pop();
399            goto done;
400      }
401   }
402
403   fc_state.s.selected = selected;
404
389405done:
390   fc_state.s.selected = selected;
391406   return fc_state.i;
392407}
393408
r2889r2890
483498   (*menu_items)++;
484499
485500   info = image_device_getinfo(device->machine->config, device);
486   if (ENABLE_CREATE && info.creatable && !zippath_is_zip(directory))
501   if (info.creatable && !zippath_is_zip(directory))
487502   {
488503      /* add the "[create]" entry */
489504      memset(&item_list[*menu_items], 0, sizeof(item_list[*menu_items]));

Previous 15994 Revisions Next


© 1998-2018 The MESS Team