src/mess/filemngr.c
| r3055 | r3056 | |
| 26 | 26 | CONSTANTS |
| 27 | 27 | ***************************************************************************/ |
| 28 | 28 | |
| 29 | | #define ITEMREF_CREATE ((void *) 0x0001) |
| 29 | #define ENABLE_FORMATS 0 |
| 30 | 30 | |
| 31 | #define ITEMREF_NEW_IMAGE_NAME ((void *) 0x0001) |
| 32 | #define ITEMREF_CREATE ((void *) 0x0002) |
| 33 | #define ITEMREF_FORMAT ((void *) 0x0003) |
| 31 | 34 | |
| 32 | 35 | |
| 36 | |
| 33 | 37 | /*************************************************************************** |
| 34 | 38 | TYPE DEFINITIONS |
| 35 | 39 | ***************************************************************************/ |
| r3055 | r3056 | |
| 86 | 90 | struct _file_create_menu_state |
| 87 | 91 | { |
| 88 | 92 | file_manager_menu_state *manager_menustate; |
| 93 | const image_device_format *current_format; |
| 89 | 94 | char filename_buffer[1024]; |
| 90 | 95 | }; |
| 91 | 96 | |
| r3055 | r3056 | |
| 218 | 223 | |
| 219 | 224 | static void file_create_render_extra(running_machine *machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 220 | 225 | { |
| 221 | | astring *buffer; |
| 222 | 226 | file_create_menu_state *menustate = (file_create_menu_state *) state; |
| 223 | 227 | |
| 224 | | buffer = astring_assemble_4(astring_alloc(), |
| 228 | extra_text_render(machine, menu, state, selectedref, top, bottom, origx1, origy1, origx2, origy2, |
| 225 | 229 | astring_c(menustate->manager_menustate->current_directory), |
| 226 | | "\nNew Image Name: ", |
| 227 | | menustate->filename_buffer, |
| 228 | | "_"); |
| 229 | | |
| 230 | | extra_text_render(machine, menu, state, selectedref, top, bottom, origx1, origy1, origx2, origy2, |
| 231 | | astring_c(buffer), |
| 232 | 230 | NULL); |
| 233 | | |
| 234 | | astring_free(buffer); |
| 235 | 231 | } |
| 236 | 232 | |
| 237 | 233 | |
| r3055 | r3056 | |
| 241 | 237 | creator menu |
| 242 | 238 | -------------------------------------------------*/ |
| 243 | 239 | |
| 244 | | static void menu_file_create_populate(running_machine *machine, ui_menu *menu) |
| 240 | static void menu_file_create_populate(running_machine *machine, ui_menu *menu, void *state) |
| 245 | 241 | { |
| 246 | | /* append menu items */ |
| 242 | astring *buffer = astring_alloc(); |
| 243 | file_create_menu_state *menustate = (file_create_menu_state *) state; |
| 244 | const device_config *device = menustate->manager_menustate->selected_device; |
| 245 | const image_device_format *format; |
| 246 | const char *new_image_name; |
| 247 | void *selection; |
| 248 | |
| 249 | /* identify the selection */ |
| 250 | selection = ui_menu_get_selection(menu); |
| 251 | |
| 252 | /* append the "New Image Name" item */ |
| 253 | if (selection == ITEMREF_NEW_IMAGE_NAME) |
| 254 | { |
| 255 | astring_assemble_2(buffer, menustate->filename_buffer, "_"); |
| 256 | new_image_name = astring_c(buffer); |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | new_image_name = menustate->filename_buffer; |
| 261 | } |
| 262 | ui_menu_item_append(menu, "New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME); |
| 263 | |
| 264 | /* do we support multiple formats? */ |
| 265 | format = image_device_get_creatable_formats(device); |
| 266 | if (ENABLE_FORMATS && (format != NULL)) |
| 267 | { |
| 268 | ui_menu_item_append(menu, "Image Format:", menustate->current_format->description, 0, ITEMREF_FORMAT); |
| 269 | menustate->current_format = format; |
| 270 | } |
| 271 | |
| 272 | /* finish up the menu */ |
| 273 | ui_menu_item_append(menu, MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 247 | 274 | ui_menu_item_append(menu, "Create", NULL, 0, ITEMREF_CREATE); |
| 248 | 275 | |
| 249 | 276 | /* set up custom render proc */ |
| 250 | | ui_menu_set_custom_render(menu, file_create_render_extra, (ui_get_line_height() * 2) + 3.0f * UI_BOX_TB_BORDER, 0); |
| 277 | ui_menu_set_custom_render(menu, file_create_render_extra, ui_get_line_height() + 3.0f * UI_BOX_TB_BORDER, 0); |
| 278 | |
| 279 | /* cleanup */ |
| 280 | astring_free(buffer); |
| 251 | 281 | } |
| 252 | 282 | |
| 253 | 283 | |
| r3055 | r3056 | |
| 262 | 292 | const ui_menu_event *event; |
| 263 | 293 | file_create_menu_state *menustate = (file_create_menu_state *) state; |
| 264 | 294 | |
| 265 | | /* if the menu isn't built, populate now */ |
| 266 | | if (!ui_menu_populated(menu)) |
| 267 | | menu_file_create_populate(machine, menu); |
| 295 | /* rebuild the menu */ |
| 296 | ui_menu_reset(menu, UI_MENU_RESET_REMEMBER_POSITION); |
| 297 | menu_file_create_populate(machine, menu, state); |
| 268 | 298 | |
| 269 | 299 | /* process the menu */ |
| 270 | 300 | event = ui_menu_process(menu, 0); |
| r3055 | r3056 | |
| 293 | 323 | break; |
| 294 | 324 | |
| 295 | 325 | case IPT_SPECIAL: |
| 296 | | input_character( |
| 297 | | menustate->filename_buffer, |
| 298 | | ARRAY_LENGTH(menustate->filename_buffer), |
| 299 | | event->unichar, |
| 300 | | is_valid_filename_char); |
| 326 | if (ui_menu_get_selection(menu) == ITEMREF_NEW_IMAGE_NAME) |
| 327 | { |
| 328 | input_character( |
| 329 | menustate->filename_buffer, |
| 330 | ARRAY_LENGTH(menustate->filename_buffer), |
| 331 | event->unichar, |
| 332 | is_valid_filename_char); |
| 333 | } |
| 301 | 334 | break; |
| 302 | 335 | } |
| 303 | 336 | } |