fixed rest of ui.ini mame.ini read/write settings (nw)

This commit is contained in:
Miodrag Milanovic 2016-02-06 10:39:49 +01:00
parent 4404f3dab3
commit 65d9003144
3 changed files with 70 additions and 10 deletions

View File

@ -144,13 +144,40 @@ void ui_menu_add_change_folder::handle()
std::string error_string;
if (m_change)
{
machine().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
if (machine().ui().options().exists(s_folders_entry[m_ref].option))
{
machine().ui().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
else {
if (strcmp(machine().options().value(s_folders_entry[m_ref].option), m_current_path.c_str()) != 0)
{
machine().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
save_main_option(machine(), s_folders_entry[m_ref].option, m_current_path.c_str());
}
}
machine().datfile().reset_run();
}
else
{
std::string tmppath = std::string(machine().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str());
machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
std::string tmppath;
if (machine().ui().options().exists(s_folders_entry[m_ref].option)) {
tmppath.assign(machine().ui().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str());
}
else {
tmppath.assign(machine().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str());
}
if (machine().ui().options().exists(s_folders_entry[m_ref].option))
{
machine().ui().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
else {
if (strcmp(machine().options().value(s_folders_entry[m_ref].option), tmppath.c_str()) != 0)
{
machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
save_main_option(machine(), s_folders_entry[m_ref].option, tmppath.c_str());
}
}
}
ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST);
@ -464,7 +491,12 @@ void ui_menu_display_actual::handle()
void ui_menu_display_actual::populate()
{
m_tempbuf.assign("Current ").append(s_folders_entry[m_ref - 1].name).append(" Folders");
m_searchpath.assign(machine().options().value(s_folders_entry[m_ref - 1].option));
if (machine().ui().options().exists(s_folders_entry[m_ref - 1].option)) {
m_searchpath.assign(machine().ui().options().value(s_folders_entry[m_ref - 1].option));
}
else {
m_searchpath.assign(machine().options().value(s_folders_entry[m_ref - 1].option));
}
path_iterator path(m_searchpath.c_str());
std::string curpath;
m_folders.clear();
@ -557,7 +589,13 @@ void ui_menu_display_actual::custom_render(void *selectedref, float top, float b
ui_menu_remove_folder::ui_menu_remove_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container)
{
m_ref = ref - 1;
m_searchpath.assign(machine.options().value(s_folders_entry[m_ref].option));
if (machine.ui().options().exists(s_folders_entry[m_ref].option)) {
m_searchpath.assign(machine.ui().options().value(s_folders_entry[m_ref].option));
}
else {
m_searchpath.assign(machine.options().value(s_folders_entry[m_ref].option));
}
}
ui_menu_remove_folder::~ui_menu_remove_folder()
@ -582,7 +620,18 @@ void ui_menu_remove_folder::handle()
tmppath.substr(0, tmppath.size() - 1);
std::string error_string;
machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
if (machine().ui().options().exists(s_folders_entry[m_ref].option))
{
machine().ui().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
else {
if (strcmp(machine().options().value(s_folders_entry[m_ref].option),tmppath.c_str())!=0)
{
machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
save_main_option(machine(), s_folders_entry[m_ref].option, tmppath.c_str());
}
}
ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF);
ui_menu::stack_pop(machine());
}

View File

@ -585,8 +585,19 @@ ui_menu_misc_options::ui_menu_misc_options(running_machine &machine, render_cont
ui_menu_misc_options::~ui_menu_misc_options()
{
std::string error_string;
for (int d = 1; d < ARRAY_LENGTH(m_options); ++d)
machine().ui().options().set_value(m_options[d].option, m_options[d].status, OPTION_PRIORITY_CMDLINE, error_string);
for (int d = 1; d < ARRAY_LENGTH(m_options); ++d) {
if (machine().ui().options().exists(m_options[d].option))
{
machine().ui().options().set_value(m_options[d].option, m_options[d].status, OPTION_PRIORITY_CMDLINE, error_string);
}
else {
if (machine().options().bool_value(m_options[d].option) != m_options[d].status)
{
machine().options().set_value(m_options[d].option, m_options[d].status, OPTION_PRIORITY_CMDLINE, error_string);
save_main_option(machine(), m_options[d].option, m_options[d].status);
}
}
}
ui_globals::reset = true;
}

View File

@ -166,8 +166,8 @@ ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_contai
if (!moptions.remember_last())
reselect_last::reset();
moptions.set_value(OPTION_SNAPNAME, "%g/%i", OPTION_PRIORITY_CMDLINE, error_string);
moptions.set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string);
machine.options().set_value(OPTION_SNAPNAME, "%g/%i", OPTION_PRIORITY_CMDLINE, error_string);
machine.options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string);
ui_globals::curimage_view = FIRST_VIEW;
ui_globals::curdats_view = UI_FIRST_LOAD;