diff options
Diffstat (limited to 'src/frontend')
-rw-r--r-- | src/frontend/mame/clifront.cpp | 10 | ||||
-rw-r--r-- | src/frontend/mame/pluginopts.cpp | 13 | ||||
-rw-r--r-- | src/frontend/mame/ui/custui.cpp | 4 | ||||
-rw-r--r-- | src/frontend/mame/ui/dirmenu.cpp | 4 | ||||
-rw-r--r-- | src/frontend/mame/ui/filesel.cpp | 8 | ||||
-rw-r--r-- | src/frontend/mame/ui/filesel.h | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/imgcntrl.cpp | 16 | ||||
-rw-r--r-- | src/frontend/mame/ui/inifile.cpp | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/miscmenu.cpp | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/selgame.cpp | 4 | ||||
-rw-r--r-- | src/frontend/mame/ui/selsoft.cpp | 6 | ||||
-rw-r--r-- | src/frontend/mame/ui/simpleselgame.cpp | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/ui.cpp | 32 | ||||
-rw-r--r-- | src/frontend/mame/ui/ui.h | 2 |
14 files changed, 61 insertions, 46 deletions
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp index 39033e84d20..3679441957a 100644 --- a/src/frontend/mame/clifront.cpp +++ b/src/frontend/mame/clifront.cpp @@ -1810,19 +1810,19 @@ media_identifier::media_identifier(emu_options &options) void media_identifier::identify(const char *filename) { // first try to open as a directory - osd_directory *directory = osd_opendir(filename); - if (directory != nullptr) + osd::directory::ptr directory = osd::directory::open(filename); + if (directory) { // iterate over all files in the directory - for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory)) - if (entry->type == ENTTYPE_FILE) + for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read()) + if (entry->type == osd::directory::entry::entry_type::FILE) { std::string curfile = std::string(filename).append(PATH_SEPARATOR).append(entry->name); identify(curfile.c_str()); } // close the directory and be done - osd_closedir(directory); + directory.reset(); } // if that failed, and the filename ends with .zip, identify as a ZIP file diff --git a/src/frontend/mame/pluginopts.cpp b/src/frontend/mame/pluginopts.cpp index e56a72dfced..0dd9ca7bcf9 100644 --- a/src/frontend/mame/pluginopts.cpp +++ b/src/frontend/mame/pluginopts.cpp @@ -39,13 +39,13 @@ plugin_options::plugin_options() void plugin_options::parse_json(std::string path) { // first try to open as a directory - osd_directory *directory = osd_opendir(path.c_str()); - if (directory != nullptr) + osd::directory::ptr directory = osd::directory::open(path); + if (directory) { // iterate over all files in the directory - for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory)) + for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read()) { - if (entry->type == ENTTYPE_FILE) + if (entry->type == osd::directory::entry::entry_type::FILE) { std::string name = entry->name; if (name == "plugin.json") @@ -80,7 +80,7 @@ void plugin_options::parse_json(std::string path) } } - else if (entry->type == ENTTYPE_DIR) + else if (entry->type == osd::directory::entry::entry_type::DIR) { std::string name = entry->name; if (!(name == "." || name == "..")) @@ -89,8 +89,5 @@ void plugin_options::parse_json(std::string path) } } } - - // close the directory and be done - osd_closedir(directory); } } diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 95a5ead8a8b..4cb4450b9ce 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -36,10 +36,10 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container // load languages file_enumerator path(mui.machine().options().language_path()); auto lang = mui.machine().options().language(); - const osd_directory_entry *dirent; + const osd::directory::entry *dirent; int cnt = 0; while ((dirent = path.next()) != nullptr) - if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0 && strcmp(dirent->name, "..") != 0) + if (dirent->type == osd::directory::entry::entry_type::DIR && strcmp(dirent->name, ".") != 0 && strcmp(dirent->name, "..") != 0) { auto name = std::string(dirent->name); auto i = strreplace(name, "_", " ("); diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp index 359d6d63420..1a500e14482 100644 --- a/src/frontend/mame/ui/dirmenu.cpp +++ b/src/frontend/mame/ui/dirmenu.cpp @@ -466,7 +466,7 @@ void menu_add_change_folder::populate() // open a path const char *volume_name = nullptr; file_enumerator path(m_current_path.c_str()); - const osd_directory_entry *dirent; + const osd::directory::entry *dirent; int folders_count = 0; // add the drives @@ -476,7 +476,7 @@ void menu_add_change_folder::populate() // add the directories while ((dirent = path.next()) != nullptr) { - if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0) + if (dirent->type == osd::directory::entry::entry_type::DIR && strcmp(dirent->name, ".") != 0) item_append(dirent->name, "[DIR]", 0, (void *)(FPTR)++folders_count); } diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp index 7c1d3ccfed6..1fe8c8e0bf4 100644 --- a/src/frontend/mame/ui/filesel.cpp +++ b/src/frontend/mame/ui/filesel.cpp @@ -451,7 +451,7 @@ menu_file_selector::file_selector_entry *menu_file_selector::append_entry( // a menu item for a file selector entry //------------------------------------------------- -menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent) +menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry(const osd::directory::entry *dirent) { std::string buffer; file_selector_entry_type entry_type; @@ -459,11 +459,11 @@ menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry switch(dirent->type) { - case ENTTYPE_FILE: + case osd::directory::entry::entry_type::FILE: entry_type = SELECTOR_ENTRY_TYPE_FILE; break; - case ENTTYPE_DIR: + case osd::directory::entry::entry_type::DIR: entry_type = SELECTOR_ENTRY_TYPE_DIRECTORY; break; @@ -536,7 +536,7 @@ void menu_file_selector::populate() { util::zippath_directory *directory = nullptr; osd_file::error err; - const osd_directory_entry *dirent; + const osd::directory::entry *dirent; const file_selector_entry *entry; const file_selector_entry *selected_entry = nullptr; int i; diff --git a/src/frontend/mame/ui/filesel.h b/src/frontend/mame/ui/filesel.h index 66be755f699..571c11e4413 100644 --- a/src/frontend/mame/ui/filesel.h +++ b/src/frontend/mame/ui/filesel.h @@ -107,7 +107,7 @@ private: // methods int compare_entries(const file_selector_entry *e1, const file_selector_entry *e2); file_selector_entry *append_entry(file_selector_entry_type entry_type, const char *entry_basename, const char *entry_fullpath); - file_selector_entry *append_dirent_entry(const osd_directory_entry *dirent); + file_selector_entry *append_dirent_entry(const osd::directory::entry *dirent); void append_entry_menu_item(const file_selector_entry *entry); }; diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index bc713bbca53..3468fa04b2d 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -88,31 +88,30 @@ menu_control_device_image::~menu_control_device_image() void menu_control_device_image::test_create(bool &can_create, bool &need_confirm) { std::string path; - osd_directory_entry *entry; - osd_dir_entry_type file_type; + osd::directory::entry::entry_type file_type; /* assemble the full path */ util::zippath_combine(path, current_directory.c_str(), current_file.c_str()); /* does a file or a directory exist at the path */ - entry = osd_stat(path.c_str()); - file_type = (entry != nullptr) ? entry->type : ENTTYPE_NONE; + auto entry = osd_stat(path.c_str()); + file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE; switch(file_type) { - case ENTTYPE_NONE: + case osd::directory::entry::entry_type::NONE: /* no file/dir here - always create */ can_create = true; need_confirm = false; break; - case ENTTYPE_FILE: + case osd::directory::entry::entry_type::FILE: /* a file exists here - ask for permission from the user */ can_create = true; need_confirm = true; break; - case ENTTYPE_DIR: + case osd::directory::entry::entry_type::DIR: /* a directory exists here - we can't save over it */ ui().popup_time(5, "%s", _("Cannot save over directory")); can_create = false; @@ -124,9 +123,6 @@ void menu_control_device_image::test_create(bool &can_create, bool &need_confirm need_confirm = false; fatalerror("Unexpected\n"); } - - if (entry != nullptr) - osd_free(entry); } diff --git a/src/frontend/mame/ui/inifile.cpp b/src/frontend/mame/ui/inifile.cpp index d9f5cbeef8a..d8693356f05 100644 --- a/src/frontend/mame/ui/inifile.cpp +++ b/src/frontend/mame/ui/inifile.cpp @@ -39,7 +39,7 @@ inifile_manager::inifile_manager(running_machine &machine, ui_options &moptions) void inifile_manager::directory_scan() { file_enumerator path(m_options.extraini_path()); - const osd_directory_entry *dir; + const osd::directory::entry *dir; while ((dir = path.next()) != nullptr) if (core_filename_ends_with(dir->name, ".ini") && parseopen(dir->name)) diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index 4e243f8ea8f..f48110dc6da 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -433,7 +433,7 @@ void menu_crosshair::populate() /* open a path to the crosshairs */ file_enumerator path(machine().options().crosshair_path()); - const osd_directory_entry *dir; + const osd::directory::entry *dir; /* reset search flags */ bool using_default = false; bool finished = false; diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 37ec5915885..87a8ebaec79 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -69,7 +69,7 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container *conta // check if there are available icons ui_globals::has_icons = false; file_enumerator path(moptions.icons_directory()); - const osd_directory_entry *dir; + const osd::directory::entry *dir; while ((dir = path.next()) != nullptr) { std::string src(dir->name); @@ -644,7 +644,7 @@ void menu_select_game::build_available_list() // open a path to the ROMs and find them in the array file_enumerator path(machine().options().media_path()); - const osd_directory_entry *dir; + const osd::directory::entry *dir; // iterate while we get new objects while ((dir = path.next()) != nullptr) diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index 95f89bcb8dd..81c0bc97afe 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -608,7 +608,7 @@ void menu_select_software::build_software_list() } std::string searchstr, curpath; - const osd_directory_entry *dir; + const osd::directory::entry *dir; for (auto & elem : m_filter.swlist.name) { path_iterator path(machine().options().media_path()); @@ -621,9 +621,9 @@ void menu_select_software::build_software_list() while ((dir = fpath.next()) != nullptr) { std::string name; - if (dir->type == ENTTYPE_FILE) + if (dir->type == osd::directory::entry::entry_type::FILE) name = core_filename_extract_base(dir->name, true); - else if (dir->type == ENTTYPE_DIR && strcmp(dir->name, ".") != 0) + else if (dir->type == osd::directory::entry::entry_type::DIR && strcmp(dir->name, ".") != 0) name = dir->name; else continue; diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index e2ca4ff6d55..c947279a001 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -63,7 +63,7 @@ void simple_menu_select_game::build_driver_list() // open a path to the ROMs and find them in the array file_enumerator path(machine().options().media_path()); - const osd_directory_entry *dir; + const osd::directory::entry *dir; // iterate while we get new objects while ((dir = path.next()) != nullptr) diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 24d7b61fd2e..df941f3ceb7 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -1210,6 +1210,30 @@ void mame_ui_manager::draw_profiler(render_container *container) //------------------------------------------------- +// start_save_state +//------------------------------------------------- + +void mame_ui_manager::start_save_state() +{ + machine().pause(); + m_load_save_hold = true; + set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_SAVE); +} + + +//------------------------------------------------- +// start_load_state +//------------------------------------------------- + +void mame_ui_manager::start_load_state() +{ + machine().pause(); + m_load_save_hold = true; + set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_LOAD); +} + + +//------------------------------------------------- // image_handler_ingame - execute display // callback function for each image device //------------------------------------------------- @@ -1386,18 +1410,14 @@ UINT32 mame_ui_manager::handler_ingame(render_container *container) // handle a save state request if (machine().ui_input().pressed(IPT_UI_SAVE_STATE)) { - machine().pause(); - m_load_save_hold = true; - set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_SAVE); + start_save_state(); return LOADSAVE_SAVE; } // handle a load state request if (machine().ui_input().pressed(IPT_UI_LOAD_STATE)) { - machine().pause(); - m_load_save_hold = true; - set_handler(UI_CALLBACK_TYPE_GENERAL, &mame_ui_manager::handler_load_save, (UINT32)LOADSAVE_LOAD); + start_load_state(); return LOADSAVE_LOAD; } diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h index 982200d0556..d02e9dd2037 100644 --- a/src/frontend/mame/ui/ui.h +++ b/src/frontend/mame/ui/ui.h @@ -236,6 +236,8 @@ public: void draw_timecode_counter(render_container *container); void draw_timecode_total(render_container *container); void draw_profiler(render_container *container); + void start_save_state(); + void start_load_state(); // print the game info string into a buffer std::string &game_info_astring(std::string &str); |