trunk/src/emu/ui/imgcntrl.c
| r0 | r29316 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | ui/imgcntrl.c |
| 4 | |
| 5 | MESS's clunky built-in file manager |
| 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | |
| 10 | ***************************************************************************/ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | #include "ui/ui.h" |
| 14 | #include "ui/menu.h" |
| 15 | #include "ui/imgcntrl.h" |
| 16 | #include "ui/filesel.h" |
| 17 | #include "ui/swlist.h" |
| 18 | #include "zippath.h" |
| 19 | |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | IMPLEMENTATION |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | //------------------------------------------------- |
| 26 | // ctor |
| 27 | //------------------------------------------------- |
| 28 | |
| 29 | ui_menu_control_device_image::ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *_image) |
| 30 | : ui_menu(machine, container) |
| 31 | { |
| 32 | image = _image; |
| 33 | |
| 34 | sld = 0; |
| 35 | if (image->software_list_name()) { |
| 36 | software_list_device_iterator iter(machine.config().root_device()); |
| 37 | for (software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next()) |
| 38 | { |
| 39 | if (strcmp(swlist->list_name(),image->software_list_name())==0) sld = swlist; |
| 40 | } |
| 41 | } |
| 42 | swi = image->software_entry(); |
| 43 | swp = image->part_entry(); |
| 44 | |
| 45 | if(swi) |
| 46 | { |
| 47 | state = START_OTHER_PART; |
| 48 | current_directory.cpy(image->working_directory()); |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | state = START_FILE; |
| 53 | |
| 54 | /* if the image exists, set the working directory to the parent directory */ |
| 55 | if (image->exists()) |
| 56 | { |
| 57 | current_file.cpy(image->filename()); |
| 58 | zippath_parent(current_directory, current_file); |
| 59 | } else |
| 60 | current_directory.cpy(image->working_directory()); |
| 61 | |
| 62 | /* check to see if the path exists; if not clear it */ |
| 63 | if (zippath_opendir(current_directory, NULL) != FILERR_NONE) |
| 64 | current_directory.reset(); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | |
| 69 | //------------------------------------------------- |
| 70 | // dtor |
| 71 | //------------------------------------------------- |
| 72 | |
| 73 | ui_menu_control_device_image::~ui_menu_control_device_image() |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | |
| 78 | //------------------------------------------------- |
| 79 | // test_create - creates a new disk image |
| 80 | //------------------------------------------------- |
| 81 | |
| 82 | void ui_menu_control_device_image::test_create(bool &can_create, bool &need_confirm) |
| 83 | { |
| 84 | astring path; |
| 85 | osd_directory_entry *entry; |
| 86 | osd_dir_entry_type file_type; |
| 87 | |
| 88 | /* assemble the full path */ |
| 89 | zippath_combine(path, current_directory, current_file); |
| 90 | |
| 91 | /* does a file or a directory exist at the path */ |
| 92 | entry = osd_stat(path); |
| 93 | file_type = (entry != NULL) ? entry->type : ENTTYPE_NONE; |
| 94 | |
| 95 | switch(file_type) |
| 96 | { |
| 97 | case ENTTYPE_NONE: |
| 98 | /* no file/dir here - always create */ |
| 99 | can_create = true; |
| 100 | need_confirm = false; |
| 101 | break; |
| 102 | |
| 103 | case ENTTYPE_FILE: |
| 104 | /* a file exists here - ask for permission from the user */ |
| 105 | can_create = true; |
| 106 | need_confirm = true; |
| 107 | break; |
| 108 | |
| 109 | case ENTTYPE_DIR: |
| 110 | /* a directory exists here - we can't save over it */ |
| 111 | machine().ui().popup_time(5, "Cannot save over directory"); |
| 112 | can_create = false; |
| 113 | need_confirm = false; |
| 114 | break; |
| 115 | |
| 116 | default: |
| 117 | fatalerror("Unexpected\n"); |
| 118 | can_create = false; |
| 119 | need_confirm = false; |
| 120 | break; |
| 121 | } |
| 122 | |
| 123 | if (entry != NULL) |
| 124 | osd_free(entry); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | //------------------------------------------------- |
| 129 | // load_software_part |
| 130 | //------------------------------------------------- |
| 131 | |
| 132 | void ui_menu_control_device_image::load_software_part() |
| 133 | { |
| 134 | astring temp_name(sld->list_name(), ":", swi->shortname(), ":", swp->name()); |
| 135 | hook_load(temp_name, true); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | //------------------------------------------------- |
| 140 | // hook_load |
| 141 | //------------------------------------------------- |
| 142 | |
| 143 | void ui_menu_control_device_image::hook_load(astring name, bool softlist) |
| 144 | { |
| 145 | image->load(name); |
| 146 | ui_menu::stack_pop(machine()); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | //------------------------------------------------- |
| 151 | // populate |
| 152 | //------------------------------------------------- |
| 153 | |
| 154 | void ui_menu_control_device_image::populate() |
| 155 | { |
| 156 | } |
| 157 | |
| 158 | |
| 159 | //------------------------------------------------- |
| 160 | // handle |
| 161 | //------------------------------------------------- |
| 162 | |
| 163 | void ui_menu_control_device_image::handle() |
| 164 | { |
| 165 | switch(state) { |
| 166 | case START_FILE: { |
| 167 | bool can_create = false; |
| 168 | if(image->is_creatable()) { |
| 169 | zippath_directory *directory = NULL; |
| 170 | file_error err = zippath_opendir(current_directory, &directory); |
| 171 | can_create = err == FILERR_NONE && !zippath_is_zip(directory); |
| 172 | if(directory) |
| 173 | zippath_closedir(directory); |
| 174 | } |
| 175 | submenu_result = -1; |
| 176 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result))); |
| 177 | state = SELECT_FILE; |
| 178 | break; |
| 179 | } |
| 180 | |
| 181 | case START_SOFTLIST: |
| 182 | sld = 0; |
| 183 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &sld))); |
| 184 | state = SELECT_SOFTLIST; |
| 185 | break; |
| 186 | |
| 187 | case START_OTHER_PART: { |
| 188 | submenu_result = -1; |
| 189 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, swp->interface(), &swp, true, &submenu_result))); |
| 190 | state = SELECT_OTHER_PART; |
| 191 | break; |
| 192 | } |
| 193 | |
| 194 | case SELECT_SOFTLIST: |
| 195 | if(!sld) { |
| 196 | ui_menu::stack_pop(machine()); |
| 197 | break; |
| 198 | } |
| 199 | software_info_name = ""; |
| 200 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, sld, image->image_interface(), software_info_name))); |
| 201 | state = SELECT_PARTLIST; |
| 202 | break; |
| 203 | |
| 204 | case SELECT_PARTLIST: |
| 205 | swi = sld->find(software_info_name); |
| 206 | if(swi->has_multiple_parts(image->image_interface())) { |
| 207 | submenu_result = -1; |
| 208 | swp = 0; |
| 209 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result))); |
| 210 | state = SELECT_ONE_PART; |
| 211 | } else { |
| 212 | swp = swi->first_part(); |
| 213 | load_software_part(); |
| 214 | ui_menu::stack_pop(machine()); |
| 215 | } |
| 216 | break; |
| 217 | |
| 218 | case SELECT_ONE_PART: |
| 219 | switch(submenu_result) { |
| 220 | case ui_menu_software_parts::T_ENTRY: { |
| 221 | load_software_part(); |
| 222 | ui_menu::stack_pop(machine()); |
| 223 | break; |
| 224 | } |
| 225 | |
| 226 | case -1: // return to list |
| 227 | state = SELECT_SOFTLIST; |
| 228 | break; |
| 229 | |
| 230 | } |
| 231 | break; |
| 232 | |
| 233 | case SELECT_OTHER_PART: |
| 234 | switch(submenu_result) { |
| 235 | case ui_menu_software_parts::T_ENTRY: { |
| 236 | load_software_part(); |
| 237 | break; |
| 238 | } |
| 239 | |
| 240 | case ui_menu_software_parts::T_FMGR: |
| 241 | state = START_FILE; |
| 242 | handle(); |
| 243 | break; |
| 244 | |
| 245 | case -1: // return to system |
| 246 | ui_menu::stack_pop(machine()); |
| 247 | break; |
| 248 | |
| 249 | } |
| 250 | break; |
| 251 | |
| 252 | case SELECT_FILE: |
| 253 | switch(submenu_result) { |
| 254 | case ui_menu_file_selector::R_EMPTY: |
| 255 | image->unload(); |
| 256 | ui_menu::stack_pop(machine()); |
| 257 | break; |
| 258 | |
| 259 | case ui_menu_file_selector::R_FILE: |
| 260 | hook_load(current_file, false); |
| 261 | break; |
| 262 | |
| 263 | case ui_menu_file_selector::R_CREATE: |
| 264 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, image, current_directory, current_file))); |
| 265 | state = CREATE_FILE; |
| 266 | break; |
| 267 | |
| 268 | case ui_menu_file_selector::R_SOFTLIST: |
| 269 | state = START_SOFTLIST; |
| 270 | handle(); |
| 271 | break; |
| 272 | |
| 273 | case -1: // return to system |
| 274 | ui_menu::stack_pop(machine()); |
| 275 | break; |
| 276 | } |
| 277 | break; |
| 278 | |
| 279 | case CREATE_FILE: { |
| 280 | bool can_create, need_confirm; |
| 281 | test_create(can_create, need_confirm); |
| 282 | if(can_create) { |
| 283 | if(need_confirm) { |
| 284 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, &create_confirmed))); |
| 285 | state = CREATE_CONFIRM; |
| 286 | } else { |
| 287 | state = DO_CREATE; |
| 288 | handle(); |
| 289 | } |
| 290 | } else { |
| 291 | state = START_FILE; |
| 292 | handle(); |
| 293 | } |
| 294 | break; |
| 295 | } |
| 296 | |
| 297 | case CREATE_CONFIRM: { |
| 298 | state = create_confirmed ? DO_CREATE : START_FILE; |
| 299 | handle(); |
| 300 | break; |
| 301 | } |
| 302 | |
| 303 | case DO_CREATE: { |
| 304 | astring path; |
| 305 | zippath_combine(path, current_directory, current_file); |
| 306 | int err = image->create(path, 0, NULL); |
| 307 | if (err != 0) |
| 308 | popmessage("Error: %s", image->error()); |
| 309 | ui_menu::stack_pop(machine()); |
| 310 | break; |
| 311 | } |
| 312 | } |
| 313 | } |
trunk/src/emu/ui/imgcntrl.h
| r0 | r29316 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | ui/imgcntrl.h |
| 4 | |
| 5 | MESS's clunky built-in file manager |
| 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | |
| 10 | ***************************************************************************/ |
| 11 | |
| 12 | #pragma once |
| 13 | |
| 14 | #ifndef __UI_IMGCNTRL_H__ |
| 15 | #define __UI_IMGCNTRL_H__ |
| 16 | |
| 17 | // ======================> ui_menu_control_device_image |
| 18 | |
| 19 | class ui_menu_control_device_image : public ui_menu { |
| 20 | public: |
| 21 | ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *image); |
| 22 | virtual ~ui_menu_control_device_image(); |
| 23 | virtual void populate(); |
| 24 | virtual void handle(); |
| 25 | |
| 26 | protected: |
| 27 | enum { |
| 28 | START_FILE, START_OTHER_PART, START_SOFTLIST, SELECT_PARTLIST, SELECT_ONE_PART, SELECT_OTHER_PART, SELECT_FILE, CREATE_FILE, CREATE_CONFIRM, DO_CREATE, SELECT_SOFTLIST, |
| 29 | LAST_ID |
| 30 | }; |
| 31 | |
| 32 | // protected instance variables |
| 33 | int state; |
| 34 | device_image_interface *image; |
| 35 | int submenu_result; |
| 36 | astring current_directory; |
| 37 | astring current_file; |
| 38 | |
| 39 | // methods |
| 40 | virtual void hook_load(astring filename, bool softlist); |
| 41 | |
| 42 | private: |
| 43 | // instance variables |
| 44 | bool create_confirmed; |
| 45 | bool softlist_done; |
| 46 | const software_info *swi; |
| 47 | const software_part *swp; |
| 48 | class software_list_device *sld; |
| 49 | astring software_info_name; |
| 50 | |
| 51 | // methods |
| 52 | void test_create(bool &can_create, bool &need_confirm); |
| 53 | void load_software_part(); |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | #endif /* __UI_IMGCNTRL_H__ */ |
trunk/src/emu/diimage.c
| r29315 | r29316 | |
| 15 | 15 | #include "zippath.h" |
| 16 | 16 | #include "ui/filesel.h" |
| 17 | 17 | #include "ui/swlist.h" |
| 18 | #include "ui/imgcntrl.h" |
| 18 | 19 | |
| 19 | 20 | //************************************************************************** |
| 20 | 21 | // DEVICE CONFIG IMAGE INTERFACE |
| r29315 | r29316 | |
| 1327 | 1328 | { |
| 1328 | 1329 | return auto_alloc_clear(machine, ui_menu_control_device_image(machine, container, this)); |
| 1329 | 1330 | } |
| 1330 | | |
| 1331 | | ui_menu_control_device_image::ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *_image) : ui_menu(machine, container) |
| 1332 | | { |
| 1333 | | image = _image; |
| 1334 | | |
| 1335 | | sld = 0; |
| 1336 | | if (image->software_list_name()) { |
| 1337 | | software_list_device_iterator iter(machine.config().root_device()); |
| 1338 | | for (software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next()) |
| 1339 | | { |
| 1340 | | if (strcmp(swlist->list_name(),image->software_list_name())==0) sld = swlist; |
| 1341 | | } |
| 1342 | | } |
| 1343 | | swi = image->software_entry(); |
| 1344 | | swp = image->part_entry(); |
| 1345 | | |
| 1346 | | if(swi) |
| 1347 | | { |
| 1348 | | state = START_OTHER_PART; |
| 1349 | | current_directory.cpy(image->working_directory()); |
| 1350 | | } |
| 1351 | | else |
| 1352 | | { |
| 1353 | | state = START_FILE; |
| 1354 | | |
| 1355 | | /* if the image exists, set the working directory to the parent directory */ |
| 1356 | | if (image->exists()) |
| 1357 | | { |
| 1358 | | current_file.cpy(image->filename()); |
| 1359 | | zippath_parent(current_directory, current_file); |
| 1360 | | } else |
| 1361 | | current_directory.cpy(image->working_directory()); |
| 1362 | | |
| 1363 | | /* check to see if the path exists; if not clear it */ |
| 1364 | | if (zippath_opendir(current_directory, NULL) != FILERR_NONE) |
| 1365 | | current_directory.reset(); |
| 1366 | | } |
| 1367 | | } |
| 1368 | | |
| 1369 | | ui_menu_control_device_image::~ui_menu_control_device_image() |
| 1370 | | { |
| 1371 | | } |
| 1372 | | |
| 1373 | | |
| 1374 | | |
| 1375 | | |
| 1376 | | /*------------------------------------------------- |
| 1377 | | create_new_image - creates a new disk image |
| 1378 | | -------------------------------------------------*/ |
| 1379 | | |
| 1380 | | void ui_menu_control_device_image::test_create(bool &can_create, bool &need_confirm) |
| 1381 | | { |
| 1382 | | astring path; |
| 1383 | | osd_directory_entry *entry; |
| 1384 | | osd_dir_entry_type file_type; |
| 1385 | | |
| 1386 | | /* assemble the full path */ |
| 1387 | | zippath_combine(path, current_directory, current_file); |
| 1388 | | |
| 1389 | | /* does a file or a directory exist at the path */ |
| 1390 | | entry = osd_stat(path); |
| 1391 | | file_type = (entry != NULL) ? entry->type : ENTTYPE_NONE; |
| 1392 | | |
| 1393 | | switch(file_type) |
| 1394 | | { |
| 1395 | | case ENTTYPE_NONE: |
| 1396 | | /* no file/dir here - always create */ |
| 1397 | | can_create = true; |
| 1398 | | need_confirm = false; |
| 1399 | | break; |
| 1400 | | |
| 1401 | | case ENTTYPE_FILE: |
| 1402 | | /* a file exists here - ask for permission from the user */ |
| 1403 | | can_create = true; |
| 1404 | | need_confirm = true; |
| 1405 | | break; |
| 1406 | | |
| 1407 | | case ENTTYPE_DIR: |
| 1408 | | /* a directory exists here - we can't save over it */ |
| 1409 | | machine().ui().popup_time(5, "Cannot save over directory"); |
| 1410 | | can_create = false; |
| 1411 | | need_confirm = false; |
| 1412 | | break; |
| 1413 | | |
| 1414 | | default: |
| 1415 | | fatalerror("Unexpected\n"); |
| 1416 | | can_create = false; |
| 1417 | | need_confirm = false; |
| 1418 | | break; |
| 1419 | | } |
| 1420 | | |
| 1421 | | if (entry != NULL) |
| 1422 | | osd_free(entry); |
| 1423 | | } |
| 1424 | | |
| 1425 | | void ui_menu_control_device_image::load_software_part() |
| 1426 | | { |
| 1427 | | astring temp_name(sld->list_name(), ":", swi->shortname(), ":", swp->name()); |
| 1428 | | hook_load(temp_name, true); |
| 1429 | | } |
| 1430 | | |
| 1431 | | void ui_menu_control_device_image::hook_load(astring name, bool softlist) |
| 1432 | | { |
| 1433 | | image->load(name); |
| 1434 | | ui_menu::stack_pop(machine()); |
| 1435 | | } |
| 1436 | | |
| 1437 | | void ui_menu_control_device_image::populate() |
| 1438 | | { |
| 1439 | | } |
| 1440 | | |
| 1441 | | void ui_menu_control_device_image::handle() |
| 1442 | | { |
| 1443 | | switch(state) { |
| 1444 | | case START_FILE: { |
| 1445 | | bool can_create = false; |
| 1446 | | if(image->is_creatable()) { |
| 1447 | | zippath_directory *directory = NULL; |
| 1448 | | file_error err = zippath_opendir(current_directory, &directory); |
| 1449 | | can_create = err == FILERR_NONE && !zippath_is_zip(directory); |
| 1450 | | if(directory) |
| 1451 | | zippath_closedir(directory); |
| 1452 | | } |
| 1453 | | submenu_result = -1; |
| 1454 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result))); |
| 1455 | | state = SELECT_FILE; |
| 1456 | | break; |
| 1457 | | } |
| 1458 | | |
| 1459 | | case START_SOFTLIST: |
| 1460 | | sld = 0; |
| 1461 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &sld))); |
| 1462 | | state = SELECT_SOFTLIST; |
| 1463 | | break; |
| 1464 | | |
| 1465 | | case START_OTHER_PART: { |
| 1466 | | submenu_result = -1; |
| 1467 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, swp->interface(), &swp, true, &submenu_result))); |
| 1468 | | state = SELECT_OTHER_PART; |
| 1469 | | break; |
| 1470 | | } |
| 1471 | | |
| 1472 | | case SELECT_SOFTLIST: |
| 1473 | | if(!sld) { |
| 1474 | | ui_menu::stack_pop(machine()); |
| 1475 | | break; |
| 1476 | | } |
| 1477 | | software_info_name = ""; |
| 1478 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, sld, image->image_interface(), software_info_name))); |
| 1479 | | state = SELECT_PARTLIST; |
| 1480 | | break; |
| 1481 | | |
| 1482 | | case SELECT_PARTLIST: |
| 1483 | | swi = sld->find(software_info_name); |
| 1484 | | if(swi->has_multiple_parts(image->image_interface())) { |
| 1485 | | submenu_result = -1; |
| 1486 | | swp = 0; |
| 1487 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result))); |
| 1488 | | state = SELECT_ONE_PART; |
| 1489 | | } else { |
| 1490 | | swp = swi->first_part(); |
| 1491 | | load_software_part(); |
| 1492 | | ui_menu::stack_pop(machine()); |
| 1493 | | } |
| 1494 | | break; |
| 1495 | | |
| 1496 | | case SELECT_ONE_PART: |
| 1497 | | switch(submenu_result) { |
| 1498 | | case ui_menu_software_parts::T_ENTRY: { |
| 1499 | | load_software_part(); |
| 1500 | | ui_menu::stack_pop(machine()); |
| 1501 | | break; |
| 1502 | | } |
| 1503 | | |
| 1504 | | case -1: // return to list |
| 1505 | | state = SELECT_SOFTLIST; |
| 1506 | | break; |
| 1507 | | |
| 1508 | | } |
| 1509 | | break; |
| 1510 | | |
| 1511 | | case SELECT_OTHER_PART: |
| 1512 | | switch(submenu_result) { |
| 1513 | | case ui_menu_software_parts::T_ENTRY: { |
| 1514 | | load_software_part(); |
| 1515 | | break; |
| 1516 | | } |
| 1517 | | |
| 1518 | | case ui_menu_software_parts::T_FMGR: |
| 1519 | | state = START_FILE; |
| 1520 | | handle(); |
| 1521 | | break; |
| 1522 | | |
| 1523 | | case -1: // return to system |
| 1524 | | ui_menu::stack_pop(machine()); |
| 1525 | | break; |
| 1526 | | |
| 1527 | | } |
| 1528 | | break; |
| 1529 | | |
| 1530 | | case SELECT_FILE: |
| 1531 | | switch(submenu_result) { |
| 1532 | | case ui_menu_file_selector::R_EMPTY: |
| 1533 | | image->unload(); |
| 1534 | | ui_menu::stack_pop(machine()); |
| 1535 | | break; |
| 1536 | | |
| 1537 | | case ui_menu_file_selector::R_FILE: |
| 1538 | | hook_load(current_file, false); |
| 1539 | | break; |
| 1540 | | |
| 1541 | | case ui_menu_file_selector::R_CREATE: |
| 1542 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, image, current_directory, current_file))); |
| 1543 | | state = CREATE_FILE; |
| 1544 | | break; |
| 1545 | | |
| 1546 | | case ui_menu_file_selector::R_SOFTLIST: |
| 1547 | | state = START_SOFTLIST; |
| 1548 | | handle(); |
| 1549 | | break; |
| 1550 | | |
| 1551 | | case -1: // return to system |
| 1552 | | ui_menu::stack_pop(machine()); |
| 1553 | | break; |
| 1554 | | } |
| 1555 | | break; |
| 1556 | | |
| 1557 | | case CREATE_FILE: { |
| 1558 | | bool can_create, need_confirm; |
| 1559 | | test_create(can_create, need_confirm); |
| 1560 | | if(can_create) { |
| 1561 | | if(need_confirm) { |
| 1562 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, &create_confirmed))); |
| 1563 | | state = CREATE_CONFIRM; |
| 1564 | | } else { |
| 1565 | | state = DO_CREATE; |
| 1566 | | handle(); |
| 1567 | | } |
| 1568 | | } else { |
| 1569 | | state = START_FILE; |
| 1570 | | handle(); |
| 1571 | | } |
| 1572 | | break; |
| 1573 | | } |
| 1574 | | |
| 1575 | | case CREATE_CONFIRM: { |
| 1576 | | state = create_confirmed ? DO_CREATE : START_FILE; |
| 1577 | | handle(); |
| 1578 | | break; |
| 1579 | | } |
| 1580 | | |
| 1581 | | case DO_CREATE: { |
| 1582 | | astring path; |
| 1583 | | zippath_combine(path, current_directory, current_file); |
| 1584 | | int err = image->create(path, 0, NULL); |
| 1585 | | if (err != 0) |
| 1586 | | popmessage("Error: %s", image->error()); |
| 1587 | | ui_menu::stack_pop(machine()); |
| 1588 | | break; |
| 1589 | | } |
| 1590 | | } |
| 1591 | | } |