mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
Save mame.ini options only if they are updated in UI (nw)
Not all are covered, will need to check rest of files, but not tonight
This commit is contained in:
parent
bd3b47671d
commit
6f3e86613d
@ -44,8 +44,14 @@ ui_menu_controller_mapping::ui_menu_controller_mapping(running_machine &machine,
|
||||
ui_menu_controller_mapping::~ui_menu_controller_mapping()
|
||||
{
|
||||
std::string error_string;
|
||||
for (int d = 1; d < ARRAY_LENGTH(m_options); ++d)
|
||||
machine().options().set_value(m_options[d].option, m_device_status[m_options[d].status], OPTION_PRIORITY_CMDLINE, error_string);
|
||||
for (int d = 1; d < ARRAY_LENGTH(m_options); ++d)
|
||||
{
|
||||
if (strcmp(machine().options().value(m_options[d].option),m_device_status[m_options[d].status])!=0)
|
||||
{
|
||||
machine().options().set_value(m_options[d].option, m_device_status[m_options[d].status], OPTION_PRIORITY_CMDLINE, error_string);
|
||||
save_main_option(machine(),m_options[d].option, m_device_status[m_options[d].status]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -60,11 +60,7 @@ ui_menu_display_options::dspl_option ui_menu_display_options::m_options[] = {
|
||||
|
||||
ui_menu_display_options::ui_menu_display_options(running_machine &machine, render_container *container) : ui_menu(machine, container)
|
||||
{
|
||||
#if defined(UI_WINDOWS) && !defined(UI_SDL)
|
||||
windows_options &options = downcast<windows_options &>(machine.options());
|
||||
#else
|
||||
osd_options &options = downcast<osd_options &>(machine.options());
|
||||
#endif
|
||||
|
||||
for (int d = 2; d < ARRAY_LENGTH(m_options); ++d)
|
||||
m_options[d].status = options.int_value(m_options[d].option);
|
||||
@ -85,13 +81,23 @@ ui_menu_display_options::ui_menu_display_options(running_machine &machine, rende
|
||||
ui_menu_display_options::~ui_menu_display_options()
|
||||
{
|
||||
std::string error_string;
|
||||
for (int d = 2; d < ARRAY_LENGTH(m_options); ++d)
|
||||
machine().options().set_value(m_options[d].option, m_options[d].status, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
|
||||
machine().options().set_value(m_options[1].option, m_video[m_options[1].status].option, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
for (int d = 2; d < ARRAY_LENGTH(m_options); ++d)
|
||||
{
|
||||
if (machine().options().int_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);
|
||||
}
|
||||
}
|
||||
if (strcmp(machine().options().value(m_options[1].option), m_video[m_options[1].status].option)!=0)
|
||||
{
|
||||
machine().options().set_value(m_options[1].option, m_video[m_options[1].status].option, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
save_main_option(machine(),m_options[1].option, m_video[m_options[1].status].option);
|
||||
}
|
||||
ui_globals::reset = true;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// handle
|
||||
//-------------------------------------------------
|
||||
|
@ -278,4 +278,8 @@ private:
|
||||
void draw_icon(int linenum, void *selectedref, float x1, float y1);
|
||||
};
|
||||
|
||||
void save_main_option(running_machine &machine,const char *name, const char *value);
|
||||
void save_main_option(running_machine &machine,const char *name, int value);
|
||||
void save_main_option(running_machine &machine,const char *name, float value);
|
||||
|
||||
#endif // __UI_MENU_H__
|
||||
|
@ -340,3 +340,57 @@ void save_ui_options(running_machine &machine)
|
||||
else
|
||||
machine.popmessage("**Error to save ui.ini**", emulator_info::get_configname());
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// save main option
|
||||
//-------------------------------------------------
|
||||
|
||||
void save_main_option(running_machine &machine,const char *name, const char *value)
|
||||
{
|
||||
// parse the file
|
||||
std::string error;
|
||||
emu_options options(machine.options()); // This way we make sure that all OSD parts are in
|
||||
std::string error_string;
|
||||
|
||||
// attempt to open the main ini file
|
||||
{
|
||||
emu_file file(machine.options().ini_path(), OPEN_FLAG_READ);
|
||||
if (file.open(emulator_info::get_configname(), ".ini") == FILERR_NONE)
|
||||
{
|
||||
bool result = options.parse_ini_file((core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
|
||||
if (!result)
|
||||
{
|
||||
osd_printf_error("**Error to load %s.ini**", emulator_info::get_configname());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
options.set_value(name, value, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
|
||||
// attempt to open the output file
|
||||
{
|
||||
emu_file file(machine.options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
if (file.open(emulator_info::get_configname(), ".ini") == FILERR_NONE)
|
||||
{
|
||||
// generate the updated INI
|
||||
std::string initext = options.output_ini();
|
||||
file.puts(initext.c_str());
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
machine.popmessage("**Error to save %s.ini**", emulator_info::get_configname());
|
||||
}
|
||||
}
|
||||
|
||||
void save_main_option(running_machine &machine,const char *name, int value)
|
||||
{
|
||||
std::string tempstr = strformat("%d", value);
|
||||
save_main_option(machine,name,tempstr.c_str());
|
||||
}
|
||||
|
||||
void save_main_option(running_machine &machine,const char *name, float value)
|
||||
{
|
||||
std::string tempstr = strformat("%f", (double)value);
|
||||
save_main_option(machine,name,tempstr.c_str());
|
||||
}
|
||||
|
@ -49,13 +49,21 @@ ui_menu_sound_options::~ui_menu_sound_options()
|
||||
std::string error_string;
|
||||
emu_options &moptions = machine().options();
|
||||
|
||||
if (m_sound)
|
||||
moptions.set_value(OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
else
|
||||
moptions.set_value(OSDOPTION_SOUND, OSDOPTVAL_NONE, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
|
||||
moptions.set_value(OPTION_SAMPLERATE, m_sound_rate[m_cur_rates], OPTION_PRIORITY_CMDLINE, error_string);
|
||||
moptions.set_value(OPTION_SAMPLES, m_samples, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
if (strcmp(moptions.value(OSDOPTION_SOUND),m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE)!=0)
|
||||
{
|
||||
moptions.set_value(OSDOPTION_SOUND, m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
save_main_option(machine(),OSDOPTION_SOUND, m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE);
|
||||
}
|
||||
if (moptions.int_value(OPTION_SAMPLERATE)!=m_sound_rate[m_cur_rates])
|
||||
{
|
||||
moptions.set_value(OPTION_SAMPLERATE, m_sound_rate[m_cur_rates], OPTION_PRIORITY_CMDLINE, error_string);
|
||||
save_main_option(machine(),OPTION_SAMPLERATE, m_sound_rate[m_cur_rates]);
|
||||
}
|
||||
if (moptions.bool_value(OPTION_SAMPLES)!=m_samples)
|
||||
{
|
||||
moptions.set_value(OPTION_SAMPLES, m_samples, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
save_main_option(machine(),OPTION_SAMPLES, m_samples);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user