diff options
Diffstat (limited to 'src/frontend/mame/ui/inifile.cpp')
-rw-r--r-- | src/frontend/mame/ui/inifile.cpp | 75 |
1 files changed, 49 insertions, 26 deletions
diff --git a/src/frontend/mame/ui/inifile.cpp b/src/frontend/mame/ui/inifile.cpp index 87cdd9329b1..5e4be6502ef 100644 --- a/src/frontend/mame/ui/inifile.cpp +++ b/src/frontend/mame/ui/inifile.cpp @@ -16,13 +16,16 @@ #include "language.h" #include "drivenum.h" +#include "fileio.h" #include "softlist_dev.h" #include "corestr.h" +#include "path.h" #include <algorithm> #include <cstring> #include <iterator> +#include <locale> namespace { @@ -55,7 +58,18 @@ inifile_manager::inifile_manager(ui_options &options) } } } - std::stable_sort(m_ini_index.begin(), m_ini_index.end(), [] (auto const &x, auto const &y) { return 0 > core_stricmp(x.first.c_str(), y.first.c_str()); }); + std::locale const lcl; + std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl); + std::stable_sort( + m_ini_index.begin(), + m_ini_index.end(), + [&coll] (auto const &x, auto const &y) + { + std::wstring const wx = wstring_from_utf8(x.first); + std::wstring const wy = wstring_from_utf8(y.first); + return 0 > coll.compare(wx.data(), wx.data() + wx.size(), wy.data(), wy.data() + wy.size()); + } + ); } //------------------------------------------------- @@ -97,7 +111,7 @@ void inifile_manager::load_ini_category(size_t file, size_t category, std::unord // initialize category //------------------------------------------------- -void inifile_manager::init_category(std::string &&filename, emu_file &file) +void inifile_manager::init_category(std::string &&filename, util::core_file &file) { categoryindex index; char rbuf[MAX_CHAR_INFO]; @@ -110,12 +124,29 @@ void inifile_manager::init_category(std::string &&filename, emu_file &file) auto const tail(std::find_if(head, std::end(rbuf), [] (char ch) { return !ch || (']' == ch); })); name.assign(head, tail); if ("FOLDER_SETTINGS" != name) - index.emplace_back(std::move(name), file.tell()); + { + u64 result; + if (!file.tell(result)) + index.emplace_back(std::move(name), result); + } } } - std::stable_sort(index.begin(), index.end(), [] (auto const &x, auto const &y) { return 0 > core_stricmp(x.first.c_str(), y.first.c_str()); }); if (!index.empty()) + { + std::locale const lcl; + std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl); + std::stable_sort( + index.begin(), + index.end(), + [&coll] (auto const &x, auto const &y) + { + std::wstring const wx = wstring_from_utf8(x.first); + std::wstring const wy = wstring_from_utf8(y.first); + return 0 > coll.compare(wx.data(), wx.data() + wx.size(), wy.data(), wy.data() + wy.size()); + } + ); m_ini_index.emplace_back(std::move(filename), std::move(index)); + } } @@ -314,7 +345,7 @@ void favorite_manager::add_favorite(running_machine &machine) driver, imagedev->software_list_name(), imagedev->instance_name(), - strensure(imagedev->image_type_name())); + imagedev->image_type_name() ? imagedev->image_type_name() : ""); // assume it's available if it's mounted info.available = true; @@ -459,31 +490,23 @@ void favorite_manager::apply_running_machine(running_machine &machine, T &&actio { bool done(false); - // TODO: this should be changed - it interacts poorly with cartslots on arcade systems - if ((machine.system().flags & machine_flags::MASK_TYPE) == machine_flags::TYPE_ARCADE) + bool have_software(false); + for (device_image_interface &image_dev : image_interface_enumerator(machine.root_device())) { - action(machine.system(), nullptr, nullptr, done); - } - else - { - bool have_software(false); - for (device_image_interface &image_dev : image_interface_enumerator(machine.root_device())) + software_info const *const sw(image_dev.software_entry()); + if (image_dev.exists() && image_dev.loaded_through_softlist() && sw) { - software_info const *const sw(image_dev.software_entry()); - if (image_dev.exists() && image_dev.loaded_through_softlist() && sw) - { - assert(image_dev.software_list_name()); + assert(image_dev.software_list_name()); - have_software = true; - action(machine.system(), &image_dev, sw, done); - if (done) - return; - } + have_software = true; + action(machine.system(), &image_dev, sw, done); + if (done) + return; } - - if (!have_software) - action(machine.system(), nullptr, nullptr, done); } + + if (!have_software) + action(machine.system(), nullptr, nullptr, done); } void favorite_manager::update_sorted() @@ -504,7 +527,7 @@ void favorite_manager::update_sorted() int cmp; - cmp = core_stricmp(lhs.longname.c_str(), rhs.longname.c_str()); + cmp = core_stricmp(lhs.longname, rhs.longname); if (0 > cmp) return true; else if (0 < cmp) |