mirror of
https://github.com/holub/mame
synced 2025-04-22 00:11:58 +03:00
Keep ui options separate from emulator ini file. (nw)
TODO: Need fixing saving of some core settings that could be changed by UI
This commit is contained in:
parent
9a28da4f73
commit
d0162765cd
@ -202,7 +202,7 @@ const options_entry emu_options::s_option_entries[] =
|
||||
//-------------------------------------------------
|
||||
|
||||
emu_options::emu_options()
|
||||
: ui_options()
|
||||
: core_options()
|
||||
, m_coin_impulse(0)
|
||||
, m_joystick_contradictory(false)
|
||||
, m_sleep(true)
|
||||
|
@ -13,8 +13,7 @@
|
||||
#ifndef __EMUOPTS_H__
|
||||
#define __EMUOPTS_H__
|
||||
|
||||
#include "ui/moptions.h"
|
||||
|
||||
#include "options.h"
|
||||
|
||||
//**************************************************************************
|
||||
// CONSTANTS
|
||||
@ -27,7 +26,8 @@ enum
|
||||
OPTION_PRIORITY_CMDLINE = OPTION_PRIORITY_HIGH,
|
||||
|
||||
// INI-based options are NORMAL priority, in increasing order:
|
||||
OPTION_PRIORITY_MAME_INI = OPTION_PRIORITY_NORMAL,
|
||||
OPTION_PRIORITY_INI = OPTION_PRIORITY_NORMAL,
|
||||
OPTION_PRIORITY_MAME_INI,
|
||||
OPTION_PRIORITY_DEBUG_INI,
|
||||
OPTION_PRIORITY_ORIENTATION_INI,
|
||||
OPTION_PRIORITY_SYSTYPE_INI,
|
||||
@ -35,8 +35,7 @@ enum
|
||||
OPTION_PRIORITY_SOURCE_INI,
|
||||
OPTION_PRIORITY_GPARENT_INI,
|
||||
OPTION_PRIORITY_PARENT_INI,
|
||||
OPTION_PRIORITY_DRIVER_INI,
|
||||
OPTION_PRIORITY_INI
|
||||
OPTION_PRIORITY_DRIVER_INI
|
||||
};
|
||||
|
||||
// core options
|
||||
@ -202,7 +201,7 @@ struct game_driver;
|
||||
class software_part;
|
||||
|
||||
|
||||
class emu_options : public ui_options
|
||||
class emu_options : public core_options
|
||||
{
|
||||
static const UINT32 OPTION_FLAG_DEVICE = 0x80000000;
|
||||
|
||||
|
@ -231,12 +231,13 @@ void running_machine::start()
|
||||
// init the osd layer
|
||||
m_manager.osd().init(*this);
|
||||
|
||||
// start the inifile manager
|
||||
m_inifile = std::make_unique<inifile_manager>(*this);
|
||||
|
||||
// create the video manager
|
||||
m_video = std::make_unique<video_manager>(*this);
|
||||
m_ui = std::make_unique<ui_manager>(*this);
|
||||
m_ui->init();
|
||||
|
||||
// start the inifile manager
|
||||
m_inifile = std::make_unique<inifile_manager>(*this);
|
||||
|
||||
// initialize the base time (needed for doing record/playback)
|
||||
::time(&m_base_time);
|
||||
|
@ -173,7 +173,7 @@ void ui_menu_audit::populate()
|
||||
void ui_menu_audit::save_available_machines()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
if (file.open(emulator_info::get_configname(), "_avail.ini") == FILERR_NONE)
|
||||
{
|
||||
// generate header
|
||||
|
@ -272,7 +272,7 @@ void ui_menu_custom_filter::custom_render(void *selectedref, float top, float bo
|
||||
void ui_menu_custom_filter::save_custom_filters()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == FILERR_NONE)
|
||||
{
|
||||
// generate custom filters info
|
||||
@ -587,7 +587,7 @@ void ui_menu_swcustom_filter::custom_render(void *selectedref, float top, float
|
||||
void ui_menu_swcustom_filter::save_sw_custom_filters()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
if (file.open("custom_", m_driver->name, "_filter.ini") == FILERR_NONE)
|
||||
{
|
||||
// generate custom filters info
|
||||
|
@ -140,10 +140,10 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom
|
||||
|
||||
ui_menu_font_ui::ui_menu_font_ui(running_machine &machine, render_container *container) : ui_menu(machine, container)
|
||||
{
|
||||
emu_options &moptions = machine.options();
|
||||
ui_options &moptions = machine.ui().options();
|
||||
#ifdef UI_WINDOWS
|
||||
|
||||
std::string name(moptions.ui_font());
|
||||
std::string name(machine.options().ui_font());
|
||||
list();
|
||||
|
||||
m_bold = (strreplace(name, "[B]", "") + strreplace(name, "[b]", "") > 0);
|
||||
@ -163,7 +163,7 @@ ui_menu_font_ui::ui_menu_font_ui(running_machine &machine, render_container *con
|
||||
m_info_size = moptions.infos_size();
|
||||
m_font_size = moptions.font_rows();
|
||||
|
||||
for (emu_options::entry *f_entry = moptions.first(); f_entry != nullptr; f_entry = f_entry->next())
|
||||
for (ui_options::entry *f_entry = moptions.first(); f_entry != nullptr; f_entry = f_entry->next())
|
||||
{
|
||||
const char *name = f_entry->name();
|
||||
if (name && strlen(name) && !strcmp(OPTION_INFOS_SIZE, f_entry->name()))
|
||||
@ -225,7 +225,7 @@ void ui_menu_font_ui::list()
|
||||
ui_menu_font_ui::~ui_menu_font_ui()
|
||||
{
|
||||
std::string error_string;
|
||||
emu_options &moptions = machine().options();
|
||||
ui_options &moptions = machine().ui().options();
|
||||
|
||||
#ifdef UI_WINDOWS
|
||||
std::string name(m_fonts[m_actual]);
|
||||
@ -655,7 +655,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
|
||||
|
||||
void ui_menu_colors_ui::restore_colors()
|
||||
{
|
||||
emu_options options;
|
||||
ui_options options;
|
||||
for (int index = 1; index < MUI_RESTORE; index++)
|
||||
m_color_table[index].color = rgb_t((UINT32)strtoul(options.value(m_color_table[index].option), nullptr, 16));
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "emu.h"
|
||||
#include "drivenum.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/datfile.h"
|
||||
#include "ui/utils.h"
|
||||
|
||||
@ -56,7 +57,7 @@ bool datfile_manager::first_run = true;
|
||||
//-------------------------------------------------
|
||||
datfile_manager::datfile_manager(running_machine &machine) : m_machine(machine)
|
||||
{
|
||||
if (machine.options().enabled_dats() && first_run)
|
||||
if (machine.ui().options().enabled_dats() && first_run)
|
||||
{
|
||||
first_run = false;
|
||||
if (parseopen("mameinfo.dat"))
|
||||
@ -539,7 +540,7 @@ bool datfile_manager::parseopen(const char *filename)
|
||||
// MAME core file parsing functions fail in recognizing UNICODE chars in UTF-8 without BOM,
|
||||
// so it's better and faster use standard C fileio functions.
|
||||
|
||||
emu_file file(machine().options().history_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().history_path(), OPEN_FLAG_READ);
|
||||
if (file.open(filename) != FILERR_NONE)
|
||||
return false;
|
||||
|
||||
|
@ -326,7 +326,7 @@ ui_menu_directory::ui_menu_directory(running_machine &machine, render_container
|
||||
|
||||
ui_menu_directory::~ui_menu_directory()
|
||||
{
|
||||
save_game_options(machine());
|
||||
save_ui_options(machine());
|
||||
ui_globals::reset = true;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/inifile.h"
|
||||
#include "softlist.h"
|
||||
#include "drivenum.h"
|
||||
@ -38,7 +39,7 @@ inifile_manager::inifile_manager(running_machine &machine)
|
||||
void inifile_manager::directory_scan()
|
||||
{
|
||||
// open extra INIs folder
|
||||
file_enumerator path(machine().options().extraini_path());
|
||||
file_enumerator path(machine().ui().options().extraini_path());
|
||||
const osd_directory_entry *dir;
|
||||
|
||||
// loop into folder's file
|
||||
@ -149,7 +150,7 @@ bool inifile_manager::parseopen(const char *filename)
|
||||
// MAME core file parsing functions fail in recognizing UNICODE chars in UTF-8 without BOM,
|
||||
// so it's better and faster use standard C fileio functions.
|
||||
|
||||
emu_file file(machine().options().extraini_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().extraini_path(), OPEN_FLAG_READ);
|
||||
if (file.open(filename) != FILERR_NONE)
|
||||
return false;
|
||||
|
||||
@ -357,7 +358,7 @@ bool favorite_manager::isgame_favorite(ui_software_info &swinfo)
|
||||
|
||||
void favorite_manager::parse_favorite()
|
||||
{
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
|
||||
if (file.open(favorite_filename) == FILERR_NONE)
|
||||
{
|
||||
char readbuf[1024];
|
||||
@ -416,7 +417,7 @@ void favorite_manager::parse_favorite()
|
||||
void favorite_manager::save_favorite_games()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
if (file.open(favorite_filename) == FILERR_NONE)
|
||||
{
|
||||
if (m_list.empty())
|
||||
|
@ -137,11 +137,11 @@ void ui_menu_main::populate()
|
||||
item_append("Cheat", nullptr, 0, (void *)CHEAT);
|
||||
|
||||
/* add history menu */
|
||||
if (machine().options().enabled_dats())
|
||||
if (machine().ui().options().enabled_dats())
|
||||
item_append("History Info", nullptr, 0, (void *)HISTORY);
|
||||
|
||||
// add software history menu
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().options().enabled_dats())
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().ui().options().enabled_dats())
|
||||
{
|
||||
image_interface_iterator iter(machine().root_device());
|
||||
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
|
||||
@ -156,7 +156,7 @@ void ui_menu_main::populate()
|
||||
}
|
||||
|
||||
/* add mameinfo / messinfo menu */
|
||||
if (machine().options().enabled_dats())
|
||||
if (machine().ui().options().enabled_dats())
|
||||
{
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0)
|
||||
item_append("MameInfo", nullptr, 0, (void *)MAMEINFO);
|
||||
@ -165,15 +165,15 @@ void ui_menu_main::populate()
|
||||
}
|
||||
|
||||
/* add sysinfo menu */
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().options().enabled_dats())
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().ui().options().enabled_dats())
|
||||
item_append("SysInfo", nullptr, 0, (void *)SYSINFO);
|
||||
|
||||
/* add command list menu */
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().options().enabled_dats())
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().ui().options().enabled_dats())
|
||||
item_append("Commands Info", nullptr, 0, (void *)COMMAND);
|
||||
|
||||
/* add story menu */
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().options().enabled_dats())
|
||||
if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().ui().options().enabled_dats())
|
||||
item_append("Mamescores", nullptr, 0, (void *)STORYINFO);
|
||||
|
||||
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
|
||||
|
@ -465,7 +465,7 @@ void ui_menu::draw(bool customonly, bool noimage, bool noinput)
|
||||
float mouse_x = -1, mouse_y = -1;
|
||||
bool history_flag = ((item[0].flags & MENU_FLAG_UI_HISTORY) != 0);
|
||||
|
||||
if (machine().options().use_background_image() && &machine().system() == &GAME_NAME(___empty) && bgrnd_bitmap->valid() && !noimage)
|
||||
if (machine().ui().options().use_background_image() && &machine().system() == &GAME_NAME(___empty) && bgrnd_bitmap->valid() && !noimage)
|
||||
container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
// compute the width and height of the full menu
|
||||
@ -1305,7 +1305,7 @@ void ui_menu::init_ui(running_machine &machine)
|
||||
bgrnd_bitmap = std::make_unique<bitmap_argb32>(0, 0);
|
||||
bgrnd_texture = mrender.texture_alloc(render_texture::hq_scale);
|
||||
|
||||
emu_options &mopt = machine.options();
|
||||
ui_options &mopt = machine.ui().options();
|
||||
if (mopt.use_background_image() && &machine.system() == &GAME_NAME(___empty))
|
||||
{
|
||||
emu_file backgroundfile(".", OPEN_FLAG_READ);
|
||||
@ -1372,7 +1372,7 @@ void ui_menu::draw_select_game(bool noinput)
|
||||
ui_manager &mui = machine().ui();
|
||||
|
||||
// draw background image if available
|
||||
if (machine().options().use_background_image() && bgrnd_bitmap->valid())
|
||||
if (machine().ui().options().use_background_image() && bgrnd_bitmap->valid())
|
||||
container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
hover = item.size() + 1;
|
||||
@ -2207,7 +2207,7 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float
|
||||
int dest_yPixel = tmp_bitmap->height();
|
||||
|
||||
// force 4:3 ratio min
|
||||
if (machine().options().forced_4x3_snapshot() && ratioI < 0.75f && ui_globals::curimage_view == SNAPSHOT_VIEW)
|
||||
if (machine().ui().options().forced_4x3_snapshot() && ratioI < 0.75f && ui_globals::curimage_view == SNAPSHOT_VIEW)
|
||||
{
|
||||
// smaller ratio will ensure that the image fits in the view
|
||||
dest_yPixel = tmp_bitmap->width() * 0.75f;
|
||||
@ -2217,7 +2217,7 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float
|
||||
dest_yPixel *= ratio;
|
||||
}
|
||||
// resize the bitmap if necessary
|
||||
else if (ratioW < 1 || ratioH < 1 || (machine().options().enlarge_snaps() && !no_available))
|
||||
else if (ratioW < 1 || ratioH < 1 || (machine().ui().options().enlarge_snaps() && !no_available))
|
||||
{
|
||||
// smaller ratio will ensure that the image fits in the view
|
||||
ratio = MIN(ratioW, ratioH);
|
||||
@ -2336,9 +2336,9 @@ void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0)
|
||||
}
|
||||
|
||||
// get search path
|
||||
path_iterator path(machine().options().icons_directory());
|
||||
path_iterator path(machine().ui().options().icons_directory());
|
||||
std::string curpath;
|
||||
std::string searchstr(machine().options().icons_directory());
|
||||
std::string searchstr(machine().ui().options().icons_directory());
|
||||
|
||||
// iterate over path and add path for zipped formats
|
||||
while (path.next(curpath))
|
||||
@ -2446,7 +2446,7 @@ void ui_menu::draw_palette_menu()
|
||||
float gutter_width = lr_arrow_width * 1.3f;
|
||||
int itemnum, linenum;
|
||||
|
||||
if (machine().options().use_background_image() && machine().options().system() == nullptr && bgrnd_bitmap->valid())
|
||||
if (machine().ui().options().use_background_image() && machine().options().system() == nullptr && bgrnd_bitmap->valid())
|
||||
container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
// compute the width and height of the full menu
|
||||
|
@ -39,7 +39,7 @@ ui_menu_game_options::ui_menu_game_options(running_machine &machine, render_cont
|
||||
ui_menu_game_options::~ui_menu_game_options()
|
||||
{
|
||||
ui_menu::menu_stack->reset(UI_MENU_RESET_SELECT_FIRST);
|
||||
save_game_options(machine());
|
||||
save_ui_options(machine());
|
||||
ui_globals::switch_image = true;
|
||||
}
|
||||
|
||||
@ -323,20 +323,20 @@ void ui_menu_game_options::custom_render(void *selectedref, float top, float bot
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// save game options
|
||||
// save ui options
|
||||
//-------------------------------------------------
|
||||
|
||||
void save_game_options(running_machine &machine)
|
||||
void save_ui_options(running_machine &machine)
|
||||
{
|
||||
// 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)
|
||||
if (file.open("ui.ini") == FILERR_NONE)
|
||||
{
|
||||
// generate the updated INI
|
||||
std::string initext = machine.options().output_ini();
|
||||
std::string initext = machine.ui().options().output_ini();
|
||||
file.puts(initext.c_str());
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
machine.popmessage("**Error to save %s.ini**", emulator_info::get_configname());
|
||||
machine.popmessage("**Error to save ui.ini**", emulator_info::get_configname());
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ private:
|
||||
};
|
||||
|
||||
// save options to file
|
||||
void save_game_options(running_machine &machine);
|
||||
void save_ui_options(running_machine &machine);
|
||||
|
||||
#endif /* __UI_OPTSMENU_H__ */
|
||||
|
@ -108,7 +108,7 @@ bool sort_game_list(const game_driver *x, const game_driver *y)
|
||||
ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container)
|
||||
{
|
||||
std::string error_string, last_filter, sub_filter;
|
||||
emu_options &moptions = machine.options();
|
||||
ui_options &moptions = machine.ui().options();
|
||||
|
||||
// load drivers cache
|
||||
load_cache_info();
|
||||
@ -185,7 +185,7 @@ ui_menu_select_game::~ui_menu_select_game()
|
||||
std::string error_string, last_driver;
|
||||
const game_driver *driver = nullptr;
|
||||
ui_software_info *swinfo = nullptr;
|
||||
emu_options &mopt = machine().options();
|
||||
ui_options &mopt = machine().ui().options();
|
||||
if (main_filters::actual == FILTER_FAVORITE_GAME)
|
||||
swinfo = (selected >= 0 && selected < item.size()) ? (ui_software_info *)item[selected].ref : nullptr;
|
||||
else
|
||||
@ -208,7 +208,7 @@ ui_menu_select_game::~ui_menu_select_game()
|
||||
mopt.set_value(OPTION_LAST_USED_FILTER, filter.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
|
||||
mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
|
||||
mopt.set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string);
|
||||
save_game_options(machine());
|
||||
save_ui_options(machine());
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -218,7 +218,7 @@ ui_menu_select_game::~ui_menu_select_game()
|
||||
void ui_menu_select_game::handle()
|
||||
{
|
||||
bool check_filter = false;
|
||||
bool enabled_dats = machine().options().enabled_dats();
|
||||
bool enabled_dats = machine().ui().options().enabled_dats();
|
||||
|
||||
// if i have to load datfile, performe an hard reset
|
||||
if (ui_globals::reset)
|
||||
@ -1023,7 +1023,7 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
|
||||
}
|
||||
|
||||
std::vector<s_bios> biosname;
|
||||
if (!machine().options().skip_bios_menu() && has_multiple_bios(driver, biosname))
|
||||
if (!machine().ui().options().skip_bios_menu() && has_multiple_bios(driver, biosname))
|
||||
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)driver, false, false));
|
||||
else
|
||||
{
|
||||
@ -1051,7 +1051,7 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
|
||||
void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
|
||||
{
|
||||
ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
|
||||
emu_options &mopt = machine().options();
|
||||
ui_options &mopt = machine().ui().options();
|
||||
|
||||
// special case for configure options
|
||||
if ((FPTR)ui_swinfo == 1)
|
||||
@ -1064,7 +1064,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
|
||||
else if (ui_swinfo->startempty == 1)
|
||||
{
|
||||
// audit the game first to see if we're going to work
|
||||
driver_enumerator enumerator(mopt, *ui_swinfo->driver);
|
||||
driver_enumerator enumerator(machine().options(), *ui_swinfo->driver);
|
||||
enumerator.next();
|
||||
media_auditor auditor(enumerator);
|
||||
media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST);
|
||||
@ -1097,7 +1097,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
|
||||
else
|
||||
{
|
||||
// first validate
|
||||
driver_enumerator drv(mopt, *ui_swinfo->driver);
|
||||
driver_enumerator drv(machine().options(), *ui_swinfo->driver);
|
||||
media_auditor auditor(drv);
|
||||
drv.next();
|
||||
software_list_device *swlist = software_list_device::find_by_name(drv.config(), ui_swinfo->listname.c_str());
|
||||
@ -1541,7 +1541,7 @@ void ui_menu_select_game::general_info(const game_driver *driver, std::string &b
|
||||
strcatprintf(buffer, "Requires CHD: %s\n", (driver_cache[idx].b_chd ? "Yes" : "No"));
|
||||
|
||||
// audit the game first to see if we're going to work
|
||||
if (machine().options().info_audit())
|
||||
if (machine().ui().options().info_audit())
|
||||
{
|
||||
driver_enumerator enumerator(machine().options(), *driver);
|
||||
enumerator.next();
|
||||
@ -1569,7 +1569,7 @@ void ui_menu_select_game::general_info(const game_driver *driver, std::string &b
|
||||
void ui_menu_select_game::inkey_export()
|
||||
{
|
||||
std::string filename("exported");
|
||||
emu_file infile(machine().options().ui_path(), OPEN_FLAG_READ);
|
||||
emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ);
|
||||
if (infile.open(filename.c_str(), ".xml") == FILERR_NONE)
|
||||
for (int seq = 0; ; ++seq)
|
||||
{
|
||||
@ -1583,7 +1583,7 @@ void ui_menu_select_game::inkey_export()
|
||||
}
|
||||
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
if (file.open(filename.c_str(), ".xml") == FILERR_NONE)
|
||||
{
|
||||
FILE *pfile;
|
||||
@ -1625,7 +1625,7 @@ void ui_menu_select_game::inkey_export()
|
||||
void ui_menu_select_game::save_cache_info()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
|
||||
if (file.open("info_", emulator_info::get_configname(), ".ini") == FILERR_NONE)
|
||||
{
|
||||
@ -1716,7 +1716,7 @@ void ui_menu_select_game::load_cache_info()
|
||||
driver_cache.resize(driver_list::total() + 1);
|
||||
|
||||
// try to load driver cache
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
|
||||
if (file.open("info_", emulator_info::get_configname(), ".ini") != FILERR_NONE)
|
||||
{
|
||||
save_cache_info();
|
||||
@ -1788,7 +1788,7 @@ void ui_menu_select_game::load_cache_info()
|
||||
bool ui_menu_select_game::load_available_machines()
|
||||
{
|
||||
// try to load available drivers from file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
|
||||
if (file.open(emulator_info::get_configname(), "_avail.ini") != FILERR_NONE)
|
||||
return false;
|
||||
|
||||
@ -1840,7 +1840,7 @@ bool ui_menu_select_game::load_available_machines()
|
||||
void ui_menu_select_game::load_custom_filters()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
|
||||
if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == FILERR_NONE)
|
||||
{
|
||||
char buffer[MAX_CHAR_INFO];
|
||||
@ -2066,7 +2066,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
|
||||
static std::string buffer;
|
||||
std::vector<int> xstart;
|
||||
std::vector<int> xend;
|
||||
float text_size = machine().options().infos_size();
|
||||
float text_size = machine().ui().options().infos_size();
|
||||
const game_driver *driver = nullptr;
|
||||
ui_software_info *soft = nullptr;
|
||||
bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0);
|
||||
|
@ -213,7 +213,7 @@ void ui_menu_select_software::handle()
|
||||
}
|
||||
|
||||
// handle UI_HISTORY
|
||||
else if (m_event->iptkey == IPT_UI_HISTORY && machine().options().enabled_dats())
|
||||
else if (m_event->iptkey == IPT_UI_HISTORY && machine().ui().options().enabled_dats())
|
||||
{
|
||||
ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
|
||||
|
||||
@ -817,7 +817,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
|
||||
void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
|
||||
{
|
||||
ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
|
||||
emu_options &mopt = machine().options();
|
||||
ui_options &mopt = machine().ui().options();
|
||||
|
||||
if (ui_swinfo->startempty == 1)
|
||||
{
|
||||
@ -925,7 +925,7 @@ void ui_menu_select_software::inkey_special(const ui_menu_event *m_event)
|
||||
void ui_menu_select_software::load_sw_custom_filters()
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
|
||||
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
|
||||
if (file.open("custom_", m_driver->name, "_filter.ini") == FILERR_NONE)
|
||||
{
|
||||
char buffer[MAX_CHAR_INFO];
|
||||
@ -1417,7 +1417,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
|
||||
static std::string buffer;
|
||||
std::vector<int> xstart;
|
||||
std::vector<int> xend;
|
||||
float text_size = machine().options().infos_size();
|
||||
float text_size = machine().ui().options().infos_size();
|
||||
ui_software_info *soft = ((FPTR)selectedref > 2) ? (ui_software_info *)selectedref : nullptr;
|
||||
static ui_software_info *oldsoft = nullptr;
|
||||
static int old_sw_view = -1;
|
||||
@ -1876,7 +1876,7 @@ void ui_bios_selection::handle()
|
||||
{
|
||||
// process the menu
|
||||
const ui_menu_event *event = process(0);
|
||||
emu_options &moptions = machine().options();
|
||||
ui_options &moptions = machine().ui().options();
|
||||
if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr)
|
||||
for (auto & elem : m_bios)
|
||||
if ((void*)&elem.name == event->itemref)
|
||||
@ -1905,7 +1905,7 @@ void ui_bios_selection::handle()
|
||||
ui_software_info *ui_swinfo = (ui_software_info *)m_driver;
|
||||
std::string error;
|
||||
machine().options().set_value("bios", elem.id, OPTION_PRIORITY_CMDLINE, error);
|
||||
driver_enumerator drivlist(moptions, *ui_swinfo->driver);
|
||||
driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
|
||||
drivlist.next();
|
||||
software_list_device *swlist = software_list_device::find_by_name(drivlist.config(), ui_swinfo->listname.c_str());
|
||||
software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
|
||||
|
@ -159,6 +159,24 @@ static INT32 slider_crossoffset(running_machine &machine, void *arg, std::string
|
||||
INLINE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
//-------------------------------------------------
|
||||
// load ui options
|
||||
//-------------------------------------------------
|
||||
|
||||
static void load_ui_options(running_machine &machine)
|
||||
{
|
||||
// parse the file
|
||||
std::string error;
|
||||
// attempt to open the output file
|
||||
emu_file file(machine.options().ini_path(), OPEN_FLAG_READ);
|
||||
if (file.open("ui.ini") == FILERR_NONE)
|
||||
{
|
||||
bool result = machine.ui().options().parse_ini_file((core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
|
||||
if (!result)
|
||||
osd_printf_error("**Error to load ui.ini**");
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// is_breakable_char - is a given unicode
|
||||
// character a possible line break?
|
||||
@ -248,9 +266,14 @@ static const UINT32 mouse_bitmap[32*32] =
|
||||
ui_manager::ui_manager(running_machine &machine)
|
||||
: m_machine(machine)
|
||||
{
|
||||
}
|
||||
|
||||
void ui_manager::init()
|
||||
{
|
||||
load_ui_options(machine());
|
||||
// initialize the other UI bits
|
||||
ui_menu::init(machine);
|
||||
ui_gfx_init(machine);
|
||||
ui_menu::init(machine());
|
||||
ui_gfx_init(machine());
|
||||
|
||||
// reset instance variables
|
||||
m_font = nullptr;
|
||||
@ -265,23 +288,23 @@ ui_manager::ui_manager(running_machine &machine)
|
||||
m_mouse_arrow_texture = nullptr;
|
||||
m_load_save_hold = false;
|
||||
|
||||
get_font_rows(&machine);
|
||||
decode_ui_color(0, &machine);
|
||||
get_font_rows(&machine());
|
||||
decode_ui_color(0, &machine());
|
||||
|
||||
// more initialization
|
||||
set_handler(handler_messagebox, 0);
|
||||
m_non_char_keys_down = std::make_unique<UINT8[]>((ARRAY_LENGTH(non_char_keys) + 7) / 8);
|
||||
m_mouse_show = machine.system().flags & MACHINE_CLICKABLE_ARTWORK ? true : false;
|
||||
m_mouse_show = machine().system().flags & MACHINE_CLICKABLE_ARTWORK ? true : false;
|
||||
|
||||
// request a callback upon exiting
|
||||
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_manager::exit), this));
|
||||
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_manager::exit), this));
|
||||
|
||||
// retrieve options
|
||||
m_use_natural_keyboard = machine.options().natural_keyboard();
|
||||
bitmap_argb32 *ui_mouse_bitmap = auto_alloc(machine, bitmap_argb32(32, 32));
|
||||
m_use_natural_keyboard = machine().options().natural_keyboard();
|
||||
bitmap_argb32 *ui_mouse_bitmap = auto_alloc(machine(), bitmap_argb32(32, 32));
|
||||
UINT32 *dst = &ui_mouse_bitmap->pix32(0);
|
||||
memcpy(dst,mouse_bitmap,32*32*sizeof(UINT32));
|
||||
m_mouse_arrow_texture = machine.render().texture_alloc();
|
||||
m_mouse_arrow_texture = machine().render().texture_alloc();
|
||||
m_mouse_arrow_texture->set_bitmap(*ui_mouse_bitmap, ui_mouse_bitmap->cliprect(), TEXFORMAT_ARGB32);
|
||||
}
|
||||
|
||||
@ -2729,10 +2752,10 @@ rgb_t decode_ui_color(int id, running_machine *machine)
|
||||
static rgb_t color[ARRAY_LENGTH(s_color_list)];
|
||||
|
||||
if (machine != nullptr) {
|
||||
emu_options option;
|
||||
ui_options option;
|
||||
for (int x = 0; x < ARRAY_LENGTH(s_color_list); x++) {
|
||||
const char *o_default = option.value(s_color_list[x]);
|
||||
const char *s_option = machine->options().value(s_color_list[x]);
|
||||
const char *s_option = machine->ui().options().value(s_color_list[x]);
|
||||
int len = strlen(s_option);
|
||||
if (len != 8)
|
||||
color[x] = rgb_t((UINT32)strtoul(o_default, nullptr, 16));
|
||||
@ -2751,5 +2774,5 @@ int get_font_rows(running_machine *machine)
|
||||
{
|
||||
static int value;
|
||||
|
||||
return ((machine != nullptr) ? value = machine->options().font_rows() : value);
|
||||
return ((machine != nullptr) ? value = machine->ui().options().font_rows() : value);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define __USRINTRF_H__
|
||||
|
||||
#include "render.h"
|
||||
|
||||
#include "moptions.h"
|
||||
|
||||
/***************************************************************************
|
||||
CONSTANTS
|
||||
@ -116,10 +116,13 @@ public:
|
||||
// construction/destruction
|
||||
ui_manager(running_machine &machine);
|
||||
|
||||
void init();
|
||||
|
||||
// getters
|
||||
running_machine &machine() const { return m_machine; }
|
||||
bool single_step() const { return m_single_step; }
|
||||
|
||||
ui_options &options() { return m_ui_options; }
|
||||
|
||||
// setters
|
||||
void set_single_step(bool single_step) { m_single_step = single_step; }
|
||||
|
||||
@ -193,6 +196,7 @@ private:
|
||||
render_texture * m_mouse_arrow_texture;
|
||||
bool m_mouse_show;
|
||||
bool m_load_save_hold;
|
||||
ui_options m_ui_options;
|
||||
|
||||
// text generators
|
||||
std::string &disclaimer_string(std::string &buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user