diff options
Diffstat (limited to 'src/emu/ui/dirmenu.cpp')
-rw-r--r-- | src/emu/ui/dirmenu.cpp | 115 |
1 files changed, 47 insertions, 68 deletions
diff --git a/src/emu/ui/dirmenu.cpp b/src/emu/ui/dirmenu.cpp index 30a992f2363..1e5717fb566 100644 --- a/src/emu/ui/dirmenu.cpp +++ b/src/emu/ui/dirmenu.cpp @@ -28,33 +28,33 @@ struct folders_entry static const folders_entry s_folders[] = { - { __("ROMs"), OPTION_MEDIAPATH, ADDING }, - { __("UI"), OPTION_UI_PATH, CHANGE }, - { __("Language"), OPTION_LANGUAGEPATH, CHANGE }, - { __("Samples"), OPTION_SAMPLEPATH, ADDING }, - { __("DATs"), OPTION_HISTORY_PATH, CHANGE }, - { __("INIs"), OPTION_INIPATH, ADDING }, - { __("Extra INIs"), OPTION_EXTRAINI_PATH, CHANGE }, - { __("Icons"), OPTION_ICONS_PATH, ADDING }, - { __("Cheats"), OPTION_CHEATPATH, ADDING }, - { __("Snapshots"), OPTION_SNAPSHOT_DIRECTORY, ADDING }, - { __("Cabinets"), OPTION_CABINETS_PATH, ADDING }, - { __("Flyers"), OPTION_FLYERS_PATH, ADDING }, - { __("Titles"), OPTION_TITLES_PATH, ADDING }, - { __("Ends"), OPTION_ENDS_PATH, ADDING }, - { __("PCBs"), OPTION_PCBS_PATH, ADDING }, - { __("Marquees"), OPTION_MARQUEES_PATH, ADDING }, - { __("Controls Panels"), OPTION_CPANELS_PATH, ADDING }, - { __("Crosshairs"), OPTION_CROSSHAIRPATH, ADDING }, - { __("Artworks"), OPTION_ARTPATH, ADDING }, - { __("Bosses"), OPTION_BOSSES_PATH, ADDING }, - { __("Artworks Preview"), OPTION_ARTPREV_PATH, ADDING }, - { __("Select"), OPTION_SELECT_PATH, ADDING }, - { __("GameOver"), OPTION_GAMEOVER_PATH, ADDING }, - { __("HowTo"), OPTION_HOWTO_PATH, ADDING }, - { __("Logos"), OPTION_LOGOS_PATH, ADDING }, - { __("Scores"), OPTION_SCORES_PATH, ADDING }, - { __("Versus"), OPTION_VERSUS_PATH, ADDING }, + { __("ROMs"), OPTION_MEDIAPATH, ADDING }, + { __("UI"), OPTION_UI_PATH, CHANGE }, + { __("Language"), OPTION_LANGUAGEPATH, CHANGE }, + { __("Samples"), OPTION_SAMPLEPATH, ADDING }, + { __("DATs"), OPTION_HISTORY_PATH, CHANGE }, + { __("INIs"), OPTION_INIPATH, ADDING }, + { __("Extra INIs"), OPTION_EXTRAINI_PATH, CHANGE }, + { __("Icons"), OPTION_ICONS_PATH, ADDING }, + { __("Cheats"), OPTION_CHEATPATH, ADDING }, + { __("Snapshots"), OPTION_SNAPSHOT_DIRECTORY, ADDING }, + { __("Cabinets"), OPTION_CABINETS_PATH, ADDING }, + { __("Flyers"), OPTION_FLYERS_PATH, ADDING }, + { __("Titles"), OPTION_TITLES_PATH, ADDING }, + { __("Ends"), OPTION_ENDS_PATH, ADDING }, + { __("PCBs"), OPTION_PCBS_PATH, ADDING }, + { __("Marquees"), OPTION_MARQUEES_PATH, ADDING }, + { __("Controls Panels"), OPTION_CPANELS_PATH, ADDING }, + { __("Crosshairs"), OPTION_CROSSHAIRPATH, ADDING }, + { __("Artworks"), OPTION_ARTPATH, ADDING }, + { __("Bosses"), OPTION_BOSSES_PATH, ADDING }, + { __("Artworks Preview"), OPTION_ARTPREV_PATH, ADDING }, + { __("Select"), OPTION_SELECT_PATH, ADDING }, + { __("GameOver"), OPTION_GAMEOVER_PATH, ADDING }, + { __("HowTo"), OPTION_HOWTO_PATH, ADDING }, + { __("Logos"), OPTION_LOGOS_PATH, ADDING }, + { __("Scores"), OPTION_SCORES_PATH, ADDING }, + { __("Versus"), OPTION_VERSUS_PATH, ADDING }, }; @@ -94,6 +94,7 @@ void ui_menu_directory::handle() void ui_menu_directory::populate() { + for (auto & elem : s_folders) item_append(_(elem.name), nullptr, 0, (void *)(FPTR)elem.action); @@ -142,7 +143,7 @@ void ui_menu_directory::custom_render(void *selectedref, float top, float bottom // ctor / dtor //------------------------------------------------- -ui_menu_display_actual::ui_menu_display_actual(running_machine &machine, render_container *container, int ref) +ui_menu_display_actual::ui_menu_display_actual(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container), m_ref(ref) { } @@ -179,12 +180,11 @@ void ui_menu_display_actual::handle() void ui_menu_display_actual::populate() { m_tempbuf.assign(_("Current ")).append(_(s_folders[m_ref].name)).append(_(" Folders")); - if (machine().ui().options().exists(s_folders[m_ref].option)) { + if (machine().ui().options().exists(s_folders[m_ref].option)) m_searchpath.assign(machine().ui().options().value(s_folders[m_ref].option)); - } - else { + else m_searchpath.assign(machine().options().value(s_folders[m_ref].option)); - } + path_iterator path(m_searchpath.c_str()); std::string curpath; m_folders.clear(); @@ -237,7 +237,7 @@ void ui_menu_display_actual::custom_render(void *selectedref, float top, float b y1 += UI_BOX_TB_BORDER; // draw the text within it - mui.draw_text_full(container, m_tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, + mui.draw_text_full(container, m_tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // compute our bounds @@ -285,19 +285,14 @@ ui_menu_add_change_folder::ui_menu_add_change_folder(running_machine &machine, r std::string searchpath; if (machine.ui().options().exists(s_folders[m_ref].option)) - { searchpath = machine.ui().options().value(s_folders[m_ref].option); - } else - { searchpath = machine.options().value(s_folders[m_ref].option); - } path_iterator path(searchpath.c_str()); std::string curpath; while (path.next(curpath, nullptr)) m_folders.push_back(curpath); - } ui_menu_add_change_folder::~ui_menu_add_change_folder() @@ -372,16 +367,11 @@ void ui_menu_add_change_folder::handle() if (m_change) { if (machine().ui().options().exists(s_folders[m_ref].option)) - { machine().ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - } - else + else if (strcmp(machine().options().value(s_folders[m_ref].option), m_current_path.c_str()) != 0) { - if (strcmp(machine().options().value(s_folders[m_ref].option), m_current_path.c_str()) != 0) - { - machine().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - machine().options().mark_changed(s_folders[m_ref].option); - } + machine().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(s_folders[m_ref].option); } machine().datfile().reset_run(); } @@ -397,16 +387,11 @@ void ui_menu_add_change_folder::handle() } if (machine().ui().options().exists(s_folders[m_ref].option)) - { machine().ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - } - else + else if (strcmp(machine().options().value(s_folders[m_ref].option), tmppath.c_str()) != 0) { - if (strcmp(machine().options().value(s_folders[m_ref].option), tmppath.c_str()) != 0) - { - machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - machine().options().mark_changed(s_folders[m_ref].option); - } + machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(s_folders[m_ref].option); } } @@ -476,13 +461,13 @@ void ui_menu_add_change_folder::handle() void ui_menu_add_change_folder::populate() { // open a path - const char *volume_name; + const char *volume_name = nullptr; file_enumerator path(m_current_path.c_str()); const osd_directory_entry *dirent; int folders_count = 0; // add the drives - for (int i = 0; (volume_name = osd_get_volume_name(i)) != nullptr; i++) + for (int i = 0; (volume_name = osd_get_volume_name(i)) != nullptr; ++i) item_append(volume_name, "[DRIVE]", 0, (void *)(FPTR)++folders_count); // add the directories @@ -581,9 +566,9 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa ui_menu_remove_folder::ui_menu_remove_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container) { m_ref = ref; - if (machine.ui().options().exists(s_folders[m_ref].option)) + if (machine.ui().options().exists(s_folders[m_ref].option)) m_searchpath.assign(machine.ui().options().value(s_folders[m_ref].option)); - else + else m_searchpath.assign(machine.options().value(s_folders[m_ref].option)); path_iterator path(m_searchpath.c_str()); @@ -616,16 +601,11 @@ void ui_menu_remove_folder::handle() } if (machine().ui().options().exists(s_folders[m_ref].option)) - { machine().ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - } - else + else if (strcmp(machine().options().value(s_folders[m_ref].option),tmppath.c_str())!=0) { - if (strcmp(machine().options().value(s_folders[m_ref].option),tmppath.c_str())!=0) - { - machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - machine().options().mark_changed(s_folders[m_ref].option); - } + machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(s_folders[m_ref].option); } ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); @@ -644,7 +624,6 @@ void ui_menu_remove_folder::populate() item_append(elem.c_str(), nullptr, 0, (void *)(FPTR)++folders_count); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); - customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -678,6 +657,6 @@ void ui_menu_remove_folder::custom_render(void *selectedref, float top, float bo y1 += UI_BOX_TB_BORDER; // draw the text within it - mui.draw_text_full(container, tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, + mui.draw_text_full(container, tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } |