Relieve UI menus and such from having to constantly fetch UI object from global state (nw)

This commit is contained in:
AJR 2016-04-26 16:37:43 -04:00
parent 0b1ca9b15d
commit e06384aaba
79 changed files with 1193 additions and 1205 deletions

View File

@ -75,6 +75,7 @@
#include "emu.h"
#include "emuopts.h"
#include "xmlfile.h"
#include "mame.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "cheat.h"
@ -1221,17 +1222,17 @@ bool cheat_manager::save_all(const char *filename)
// render text
//-------------------------------------------------
void cheat_manager::render_text(render_container &container)
void cheat_manager::render_text(mame_ui_manager &mui, render_container &container)
{
// render any text and free it along the way
for (int linenum = 0; linenum < m_output.size(); linenum++)
if (!m_output[linenum].empty())
{
// output the text
mame_machine_manager::instance()->ui().draw_text_full(&container, m_output[linenum].c_str(),
0.0f, (float)linenum * mame_machine_manager::instance()->ui().get_line_height(), 1.0f,
mui.draw_text_full(&container, m_output[linenum].c_str(),
0.0f, (float)linenum * mui.get_line_height(), 1.0f,
m_justify[linenum], WRAP_NEVER, DRAW_OPAQUE,
ARGB_WHITE, ARGB_BLACK, nullptr, nullptr);
rgb_t::white, rgb_t::black, nullptr, nullptr);
}
}

View File

@ -14,7 +14,6 @@
#define __CHEAT_H__
#include "debug/express.h"
#include "ui/ui.h"
//**************************************************************************
@ -38,6 +37,7 @@ DECLARE_ENUM_OPERATORS(script_state)
//**************************************************************************
class cheat_manager;
class mame_ui_manager;
// ======================> number_and_format
@ -303,7 +303,7 @@ public:
// actions
void reload();
bool save_all(const char *filename);
void render_text(render_container &container);
void render_text(mame_ui_manager &mui, render_container &container);
// output helpers
std::string &get_output_astring(int row, int justify);

View File

@ -28,6 +28,8 @@
#include "softlist.h"
#include "ui/moptions.h"
#include "language.h"
#include "pluginopts.h"
#include <new>
#include <ctype.h>

View File

@ -9,7 +9,6 @@
***************************************************************************/
#include "emu.h"
#include "mame.h"
#include "mameopts.h"
#include "machine/ram.h"
#include "sound/samples.h"
@ -216,7 +215,7 @@ void info_xml_creator::output(FILE *out, bool nodevices)
#endif
"\" mameconfig=\"%d\">\n",
XML_ROOT,
xml_normalize_string(build_version),
xml_normalize_string(emulator_info::get_build_version()),
CONFIG_VERSION
);

View File

@ -1507,6 +1507,7 @@ int lua_engine::lua_screen::l_draw_text(lua_State *L)
}
const char *msg = luaL_checkstring(L,4);
rgb_t textcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (!lua_isnone(L, 5)) {
textcolor = rgb_t(lua_tounsigned(L, 5));
}
@ -1515,7 +1516,7 @@ int lua_engine::lua_screen::l_draw_text(lua_State *L)
render_container &rc = sc->container();
mame_machine_manager::instance()->ui().draw_text_full(&rc, msg, x, y, (1.0f - x),
justify, WRAP_WORD, DRAW_NORMAL, textcolor,
UI_TEXT_BG_COLOR, nullptr, nullptr);
bgcolor, nullptr, nullptr);
return 0;
}

View File

@ -12,12 +12,14 @@
#include "mame.h"
#include "emuopts.h"
#include "mameopts.h"
#include "pluginopts.h"
#include "osdepend.h"
#include "validity.h"
#include "clifront.h"
#include "drivenum.h"
#include "luaengine.h"
#include <time.h>
#include "ui/ui.h"
#include "ui/selgame.h"
#include "ui/simpleselgame.h"
#include "cheat.h"
@ -272,7 +274,7 @@ ui_manager* mame_machine_manager::create_ui(running_machine& machine)
machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(mame_machine_manager::reset), this));
// start the inifile manager
m_inifile = std::make_unique<inifile_manager>(machine);
m_inifile = std::make_unique<inifile_manager>(machine, m_ui->options());
m_ui->set_startup_text("Initializing...", true);
@ -280,10 +282,10 @@ ui_manager* mame_machine_manager::create_ui(running_machine& machine)
m_autoboot_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(mame_machine_manager::autoboot_callback), this));
// start datfile manager
m_datfile = std::make_unique<datfile_manager>(machine);
m_datfile = std::make_unique<datfile_manager>(machine, m_ui->options());
// start favorite manager
m_favorite = std::make_unique<favorite_manager>(machine);
m_favorite = std::make_unique<favorite_manager>(machine, m_ui->options());
return m_ui.get();
}
@ -308,12 +310,12 @@ const char * emulator_info::get_build_version() { return build_version; }
void emulator_info::display_ui_chooser(running_machine& machine)
{
// force the UI to show the game select screen
if (strcmp(machine.options().ui(), "simple") == 0) {
ui_simple_menu_select_game::force_game_select(machine, &machine.render().ui_container());
}
else {
ui_menu_select_game::force_game_select(machine, &machine.render().ui_container());
}
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
render_container *container = &machine.render().ui_container();
if (strcmp(machine.options().ui(), "simple") == 0)
ui_simple_menu_select_game::force_game_select(mui, container);
else
ui_menu_select_game::force_game_select(mui, container);
}
int emulator_info::start_frontend(emu_options &options, osd_interface &osd, int argc, char *argv[])

View File

@ -12,11 +12,7 @@
#ifndef __MAME_H__
#define __MAME_H__
#include "emu.h"
#include <time.h>
#include "pluginopts.h"
#include "ui/ui.h"
class plugin_options;
class osd_interface;
//**************************************************************************

View File

@ -84,8 +84,8 @@ bool sorted_game_list(const game_driver *x, const game_driver *y)
// ctor / dtor
//-------------------------------------------------
ui_menu_audit::ui_menu_audit(running_machine &machine, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int _audit_mode)
: ui_menu(machine, container)
ui_menu_audit::ui_menu_audit(mame_ui_manager &mui, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int _audit_mode)
: ui_menu(mui, container)
, m_availablesorted(availablesorted)
, m_unavailablesorted(unavailablesorted)
, m_audit_mode(_audit_mode)
@ -112,7 +112,7 @@ void ui_menu_audit::handle()
if (m_first)
{
mame_machine_manager::instance()->ui().draw_text_box(container, _("Audit in progress..."), JUSTIFY_CENTER, 0.5f, 0.5f, UI_GREEN_COLOR);
ui().draw_text_box(container, _("Audit in progress..."), JUSTIFY_CENTER, 0.5f, 0.5f, UI_GREEN_COLOR);
m_first = false;
return;
}
@ -177,7 +177,7 @@ void ui_menu_audit::populate()
void ui_menu_audit::save_available_machines()
{
// attempt to open the output file
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(emulator_info::get_configname(), "_avail.ini") == osd_file::error::NONE)
{
// generate header

View File

@ -21,7 +21,7 @@ using vptr_game = std::vector<const game_driver *>;
class ui_menu_audit : public ui_menu
{
public:
ui_menu_audit(running_machine &machine, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int audit_mode);
ui_menu_audit(mame_ui_manager &mui, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int audit_mode);
virtual ~ui_menu_audit();
virtual void populate() override;
virtual void handle() override;

View File

@ -30,8 +30,8 @@
// ctor
//-------------------------------------------------
ui_menu_barcode_reader::ui_menu_barcode_reader(running_machine &machine, render_container *container, barcode_reader_device *device)
: ui_menu_device_control<barcode_reader_device>(machine, container, device)
ui_menu_barcode_reader::ui_menu_barcode_reader(mame_ui_manager &mui, render_container *container, barcode_reader_device *device)
: ui_menu_device_control<barcode_reader_device>(mui, container, device)
{
}
@ -75,7 +75,7 @@ void ui_menu_barcode_reader::populate()
item_append(ui_menu_item_type::SEPARATOR);
item_append(_("Enter Code"), nullptr, 0, ITEMREF_ENTER_BARCODE);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
}
@ -115,7 +115,7 @@ void ui_menu_barcode_reader::handle()
std::string tmp_file(m_barcode_buffer);
//printf("code %s\n", m_barcode_buffer);
if (!current_device()->is_valid(tmp_file.length()))
mame_machine_manager::instance()->ui().popup_time(5, "%s", _("Barcode length invalid!"));
ui().popup_time(5, "%s", _("Barcode length invalid!"));
else
{
current_device()->write_code(tmp_file.c_str(), tmp_file.length());

View File

@ -18,7 +18,7 @@
class ui_menu_barcode_reader : public ui_menu_device_control<barcode_reader_device> {
public:
ui_menu_barcode_reader(running_machine &machine, render_container *container, barcode_reader_device *device);
ui_menu_barcode_reader(mame_ui_manager &mui, render_container *container, barcode_reader_device *device);
virtual ~ui_menu_barcode_reader();
virtual void populate() override;
virtual void handle() override;

View File

@ -10,6 +10,7 @@
#include "emu.h"
#include "cheat.h"
#include "mame.h"
#include "ui/ui.h"
#include "ui/menu.h"
@ -93,7 +94,7 @@ void ui_menu_cheat::handle()
/* handle autofire menu */
if (menu_event->itemref == ITEMREF_CHEATS_AUTOFIRE_SETTINGS && menu_event->iptkey == IPT_UI_SELECT)
{
ui_menu::stack_push(global_alloc_clear<ui_menu_autofire>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_autofire>(ui(), container));
}
/* if things changed, update */
@ -107,7 +108,7 @@ void ui_menu_cheat::handle()
menu_cheat_populate - populate the cheat menu
-------------------------------------------------*/
ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_cheat::ui_menu_cheat(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -156,9 +157,9 @@ ui_menu_cheat::~ui_menu_cheat()
menu
-------------------------------------------------*/
ui_menu_autofire::ui_menu_autofire(running_machine &machine, render_container *container) : ui_menu(machine, container), last_toggle(false)
ui_menu_autofire::ui_menu_autofire(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container), last_toggle(false)
{
const screen_device *screen = machine.first_screen();
const screen_device *screen = mui.machine().first_screen();
if (screen == nullptr)
{

View File

@ -21,7 +21,7 @@
class ui_menu_cheat : public ui_menu {
public:
ui_menu_cheat(running_machine &machine, render_container *container);
ui_menu_cheat(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_cheat();
virtual void populate() override;
virtual void handle() override;
@ -35,7 +35,7 @@ public:
class ui_menu_autofire : public ui_menu {
public:
ui_menu_autofire(running_machine &machine, render_container *container);
ui_menu_autofire(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_autofire();
virtual void populate() override;
virtual void handle() override;

View File

@ -22,8 +22,8 @@
//-------------------------------------------------
// ctor / dtor
//-------------------------------------------------
ui_menu_custom_filter::ui_menu_custom_filter(running_machine &machine, render_container *container, bool _single_menu)
: ui_menu(machine, container)
ui_menu_custom_filter::ui_menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu)
: ui_menu(mui, container)
, m_single_menu(_single_menu)
, m_added(false)
{
@ -104,7 +104,7 @@ void ui_menu_custom_filter::handle()
else
s_sel[index] = main_filters::text[index];
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, custfltr::other[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, custfltr::other[pos]));
}
}
else if ((FPTR)m_event->itemref >= YEAR_FILTER && (FPTR)m_event->itemref < YEAR_FILTER + MAX_CUST_FILTER)
@ -121,7 +121,7 @@ void ui_menu_custom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, c_year::ui, custfltr::year[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, c_year::ui, custfltr::year[pos]));
}
else if ((FPTR)m_event->itemref >= MNFCT_FILTER && (FPTR)m_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER)
{
@ -137,7 +137,7 @@ void ui_menu_custom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, c_mnfct::ui, custfltr::mnfct[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, c_mnfct::ui, custfltr::mnfct[pos]));
}
}
@ -196,7 +196,7 @@ void ui_menu_custom_filter::populate()
item_append(_("Add filter"), nullptr, 0, (void *)(FPTR)ADD_FILTER);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -205,11 +205,10 @@ void ui_menu_custom_filter::populate()
void ui_menu_custom_filter::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// get the size of the text
mui.draw_text_full(container, _("Select custom filters:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Select custom filters:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
float maxwidth = MAX(width, origx2 - origx1);
@ -220,7 +219,7 @@ void ui_menu_custom_filter::custom_render(void *selectedref, float top, float bo
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -228,7 +227,7 @@ void ui_menu_custom_filter::custom_render(void *selectedref, float top, float bo
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Select custom filters:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, _("Select custom filters:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -239,7 +238,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(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == osd_file::error::NONE)
{
// generate custom filters info
@ -266,8 +265,8 @@ void ui_menu_custom_filter::save_custom_filters()
//-------------------------------------------------
// ctor / dtor
//-------------------------------------------------
ui_menu_swcustom_filter::ui_menu_swcustom_filter(running_machine &machine, render_container *container, const game_driver *_driver, s_filter &_filter) :
ui_menu(machine, container)
ui_menu_swcustom_filter::ui_menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter) :
ui_menu(mui, container)
, m_added(false)
, m_filter(_filter)
, m_driver(_driver)
@ -344,7 +343,7 @@ void ui_menu_swcustom_filter::handle()
else
s_sel[index] = sw_filters::text[index];
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, sw_custfltr::other[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, sw_custfltr::other[pos]));
}
}
else if ((FPTR)m_event->itemref >= YEAR_FILTER && (FPTR)m_event->itemref < YEAR_FILTER + MAX_CUST_FILTER)
@ -361,7 +360,7 @@ void ui_menu_swcustom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.year.ui, sw_custfltr::year[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.year.ui, sw_custfltr::year[pos]));
}
else if ((FPTR)m_event->itemref >= TYPE_FILTER && (FPTR)m_event->itemref < TYPE_FILTER + MAX_CUST_FILTER)
{
@ -377,7 +376,7 @@ void ui_menu_swcustom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.type.ui, sw_custfltr::type[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.type.ui, sw_custfltr::type[pos]));
}
else if ((FPTR)m_event->itemref >= MNFCT_FILTER && (FPTR)m_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER)
{
@ -393,7 +392,7 @@ void ui_menu_swcustom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.publisher.ui, sw_custfltr::mnfct[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.publisher.ui, sw_custfltr::mnfct[pos]));
}
else if ((FPTR)m_event->itemref >= REGION_FILTER && (FPTR)m_event->itemref < REGION_FILTER + MAX_CUST_FILTER)
{
@ -409,7 +408,7 @@ void ui_menu_swcustom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.region.ui, sw_custfltr::region[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.region.ui, sw_custfltr::region[pos]));
}
else if ((FPTR)m_event->itemref >= LIST_FILTER && (FPTR)m_event->itemref < LIST_FILTER + MAX_CUST_FILTER)
{
@ -425,7 +424,7 @@ void ui_menu_swcustom_filter::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.swlist.description, sw_custfltr::list[pos]));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.swlist.description, sw_custfltr::list[pos]));
}
}
@ -512,7 +511,7 @@ void ui_menu_swcustom_filter::populate()
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -521,11 +520,10 @@ void ui_menu_swcustom_filter::populate()
void ui_menu_swcustom_filter::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// get the size of the text
mui.draw_text_full(container, _("Select custom filters:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Select custom filters:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
float maxwidth = MAX(width, origx2 - origx1);
@ -536,7 +534,7 @@ void ui_menu_swcustom_filter::custom_render(void *selectedref, float top, float
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -544,7 +542,7 @@ void ui_menu_swcustom_filter::custom_render(void *selectedref, float top, float
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Select custom filters:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, _("Select custom filters:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -555,7 +553,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(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open("custom_", m_driver->name, "_filter.ini") == osd_file::error::NONE)
{
// generate custom filters info

View File

@ -73,7 +73,7 @@ struct s_filter
class ui_menu_swcustom_filter : public ui_menu
{
public:
ui_menu_swcustom_filter(running_machine &machine, render_container *container, const game_driver *_driver, s_filter &_filter);
ui_menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter);
virtual ~ui_menu_swcustom_filter();
virtual void populate() override;
virtual void handle() override;
@ -106,7 +106,7 @@ private:
class ui_menu_custom_filter : public ui_menu
{
public:
ui_menu_custom_filter(running_machine &machine, render_container *container, bool _single_menu = false);
ui_menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu = false);
virtual ~ui_menu_custom_filter();
virtual void populate() override;
virtual void handle() override;

View File

@ -27,11 +27,11 @@ const char *const ui_menu_custom_ui::hide_status[] = {
// ctor
//-------------------------------------------------
ui_menu_custom_ui::ui_menu_custom_ui(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_custom_ui::ui_menu_custom_ui(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
// load languages
file_enumerator path(machine.options().language_path());
const char *lang = machine.options().language();
file_enumerator path(mui.machine().options().language_path());
const char *lang = mui.machine().options().language();
const osd_directory_entry *dirent;
int cnt = 0;
while ((dirent = path.next()) != nullptr)
@ -54,7 +54,7 @@ ui_menu_custom_ui::ui_menu_custom_ui(running_machine &machine, render_container
ui_menu_custom_ui::~ui_menu_custom_ui()
{
std::string error_string;
mame_machine_manager::instance()->ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string);
ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string);
if (!m_lang.empty())
{
machine().options().set_value(OPTION_LANGUAGE, m_lang[m_currlang].c_str(), OPTION_PRIORITY_CMDLINE, error_string);
@ -81,11 +81,11 @@ void ui_menu_custom_ui::handle()
{
case FONT_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_font_ui>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_font_ui>(ui(), container));
break;
case COLORS_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_colors_ui>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_colors_ui>(ui(), container));
break;
case HIDE_MENU:
{
@ -101,7 +101,7 @@ void ui_menu_custom_ui::handle()
for (int index = 0; index < total; ++index)
s_sel[index] = _(hide_status[index]);
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ui_globals::panels_status));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, ui_globals::panels_status));
}
break;
}
@ -119,7 +119,7 @@ void ui_menu_custom_ui::handle()
for (int index = 0; index < total; ++index)
s_sel[index] = m_lang[index];
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, m_currlang));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, m_currlang));
}
break;
}
@ -150,7 +150,7 @@ void ui_menu_custom_ui::populate()
item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status]), arrow_flags, (void *)(FPTR)HIDE_MENU);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -160,10 +160,9 @@ void ui_menu_custom_ui::populate()
void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _("Custom UI Settings"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Custom UI Settings"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -174,7 +173,7 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -182,7 +181,7 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Custom UI Settings"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Custom UI Settings"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -190,10 +189,10 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom
// ctor
//-------------------------------------------------
ui_menu_font_ui::ui_menu_font_ui(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_font_ui::ui_menu_font_ui(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
ui_options &moptions = mame_machine_manager::instance()->ui().options();
std::string name(machine.options().ui_font());
ui_options &moptions = mui.options();
std::string name(mui.machine().options().ui_font());
list();
#ifdef UI_WINDOWS
@ -250,7 +249,7 @@ void ui_menu_font_ui::list()
ui_menu_font_ui::~ui_menu_font_ui()
{
std::string error_string;
ui_options &moptions = mame_machine_manager::instance()->ui().options();
ui_options &moptions = ui().options();
std::string name(m_fonts[m_actual].first);
#ifdef UI_WINDOWS
@ -311,7 +310,7 @@ void ui_menu_font_ui::handle()
std::vector<std::string> display_names;
display_names.reserve(m_fonts.size());
for (auto const &font : m_fonts) display_names.emplace_back(font.second);
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, std::move(display_names), m_actual));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, std::move(display_names), m_actual));
changed = true;
}
break;
@ -364,7 +363,7 @@ void ui_menu_font_ui::populate()
item_append(ui_menu_item_type::SEPARATOR);
custombottom = customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -374,13 +373,12 @@ void ui_menu_font_ui::populate()
void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// top text
std::string topbuf(_("UI Fonts Settings"));
mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -391,7 +389,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom,
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -399,15 +397,15 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom,
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
if ((FPTR)selectedref == INFOS_SIZE)
{
topbuf = _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr, m_info_size);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr, m_info_size);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(origx2 - origx1, width);
@ -418,7 +416,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom,
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -426,7 +424,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom,
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_LEFT, WRAP_NEVER,
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_LEFT, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, m_info_size);
}
}
@ -436,7 +434,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom,
//-------------------------------------------------
#define SET_COLOR_UI(var, opt) var[M##opt].color = opt; var[M##opt].option = OPTION_##opt
ui_menu_colors_ui::ui_menu_colors_ui(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_colors_ui::ui_menu_colors_ui(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
SET_COLOR_UI(m_color_table, UI_BACKGROUND_COLOR);
SET_COLOR_UI(m_color_table, UI_BORDER_COLOR);
@ -466,7 +464,7 @@ ui_menu_colors_ui::~ui_menu_colors_ui()
for (int index = 1; index < MUI_RESTORE; index++)
{
dec_color = string_format("%x", (UINT32)m_color_table[index].color);
mame_machine_manager::instance()->ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
}
@ -484,7 +482,7 @@ void ui_menu_colors_ui::handle()
if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
{
if ((FPTR)m_event->itemref != MUI_RESTORE)
ui_menu::stack_push(global_alloc_clear<ui_menu_rgb_ui>(machine(), container, &m_color_table[(FPTR)m_event->itemref].color, item[selected].text));
ui_menu::stack_push(global_alloc_clear<ui_menu_rgb_ui>(ui(), container, &m_color_table[(FPTR)m_event->itemref].color, item[selected].text));
else
{
changed = true;
@ -522,7 +520,7 @@ void ui_menu_colors_ui::populate()
item_append(ui_menu_item_type::SEPARATOR);
item_append(_("Restore originals colors"), nullptr, 0, (void *)(FPTR)MUI_RESTORE);
custombottom = customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -532,14 +530,13 @@ void ui_menu_colors_ui::populate()
void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width, maxwidth = origx2 - origx1;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
// top text
std::string topbuf(_("UI Colors Settings"));
mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -550,7 +547,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -558,7 +555,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// bottom text
@ -566,8 +563,8 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
std::string ui_select_text = machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD));
topbuf = string_format(_("Double click or press %1$s to change the color value"), ui_select_text);
mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -578,7 +575,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -586,14 +583,14 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// compute maxwidth
topbuf = _("Menu Preview");
mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
maxwidth = width + 2.0f * UI_BOX_LR_BORDER;
std::string sampletxt[5];
@ -606,8 +603,8 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
for (auto & elem: sampletxt)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
}
@ -619,7 +616,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y2 = y1 + bottom - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -628,7 +625,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y2 -= UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// compute our bounds for menu preview
@ -638,7 +635,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y2 = y1 + 5.0f * line_height + 2.0f * UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, m_color_table[MUI_BACKGROUND_COLOR].color);
ui().draw_outlined_box(container, x1, y1, x2, y2, m_color_table[MUI_BACKGROUND_COLOR].color);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -646,29 +643,29 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw normal text
mui.draw_text_full(container, sampletxt[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, sampletxt[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, m_color_table[MUI_TEXT_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw subitem text
mui.draw_text_full(container, sampletxt[1].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, sampletxt[1].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, m_color_table[MUI_SUBITEM_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw selected text
highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_SELECTED_BG_COLOR].color);
mui.draw_text_full(container, sampletxt[2].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, sampletxt[2].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, m_color_table[MUI_SELECTED_COLOR].color, m_color_table[MUI_SELECTED_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw mouse over text
highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_MOUSEOVER_BG_COLOR].color);
mui.draw_text_full(container, sampletxt[3].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, sampletxt[3].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, m_color_table[MUI_MOUSEOVER_COLOR].color, m_color_table[MUI_MOUSEOVER_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw clone text
mui.draw_text_full(container, sampletxt[4].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, sampletxt[4].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, m_color_table[MUI_CLONE_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
}
@ -688,7 +685,7 @@ void ui_menu_colors_ui::restore_colors()
// ctor
//-------------------------------------------------
ui_menu_rgb_ui::ui_menu_rgb_ui(running_machine &machine, render_container *container, rgb_t *_color, std::string _title) : ui_menu(machine, container)
ui_menu_rgb_ui::ui_menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) : ui_menu(mui, container)
{
m_color = _color;
m_key_active = false;
@ -811,7 +808,7 @@ void ui_menu_rgb_ui::handle()
case PALETTE_CHOOSE:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_palette_sel>(machine(), container, *m_color));
ui_menu::stack_push(global_alloc_clear<ui_menu_palette_sel>(ui(), container, *m_color));
break;
}
}
@ -866,7 +863,7 @@ void ui_menu_rgb_ui::populate()
item_append(_("Choose from palette"), nullptr, 0, (void *)(FPTR)PALETTE_CHOOSE);
item_append(ui_menu_item_type::SEPARATOR);
custombottom = customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -876,12 +873,11 @@ void ui_menu_rgb_ui::populate()
void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width, maxwidth = origx2 - origx1;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// top text
std::string topbuf = std::string(m_title).append(_(" - ARGB Settings"));
mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -892,7 +888,7 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -900,13 +896,13 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
std::string sampletxt(_("Color preview ="));
maxwidth = origx2 - origx1;
mui.draw_text_full(container, sampletxt.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, sampletxt.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -917,7 +913,7 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -925,15 +921,15 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f
y1 += UI_BOX_TB_BORDER;
// draw the normal text
mui.draw_text_full(container, sampletxt.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr);
ui().draw_text_full(container, sampletxt.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, rgb_t::white, rgb_t::black, nullptr, nullptr);
float t_x2 = x1 - UI_BOX_LR_BORDER + maxwidth;
x1 = x2 + 2.0f * UI_BOX_LR_BORDER;
x2 = t_x2;
y1 -= UI_BOX_TB_BORDER;
mui.draw_outlined_box(container, x1, y1, x2, y2, *m_color);
ui().draw_outlined_box(container, x1, y1, x2, y2, *m_color);
}
@ -1015,8 +1011,8 @@ ui_menu_palette_sel::palcolor ui_menu_palette_sel::m_palette[] = {
// ctor
//-------------------------------------------------
ui_menu_palette_sel::ui_menu_palette_sel(running_machine &machine, render_container *container, rgb_t &_color)
: ui_menu(machine, container), m_original(_color)
ui_menu_palette_sel::ui_menu_palette_sel(mame_ui_manager &mui, render_container *container, rgb_t &_color)
: ui_menu(mui, container), m_original(_color)
{
}

View File

@ -20,7 +20,7 @@
class ui_menu_custom_ui : public ui_menu
{
public:
ui_menu_custom_ui(running_machine &machine, render_container *container);
ui_menu_custom_ui(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_custom_ui();
virtual void populate() override;
virtual void handle() override;
@ -46,7 +46,7 @@ private:
class ui_menu_font_ui : public ui_menu
{
public:
ui_menu_font_ui(running_machine &machine, render_container *container);
ui_menu_font_ui(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_font_ui();
virtual void populate() override;
virtual void handle() override;
@ -81,7 +81,7 @@ private:
class ui_menu_colors_ui : public ui_menu
{
public:
ui_menu_colors_ui(running_machine &machine, render_container *container);
ui_menu_colors_ui(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_colors_ui();
virtual void populate() override;
virtual void handle() override;
@ -126,7 +126,7 @@ private:
class ui_menu_rgb_ui : public ui_menu
{
public:
ui_menu_rgb_ui(running_machine &machine, render_container *container, rgb_t *_color, std::string _title);
ui_menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title);
virtual ~ui_menu_rgb_ui();
virtual void populate() override;
virtual void handle() override;
@ -158,7 +158,7 @@ private:
class ui_menu_palette_sel : public ui_menu
{
public:
ui_menu_palette_sel(running_machine &machine, render_container *container, rgb_t &_color);
ui_menu_palette_sel(mame_ui_manager &mui, render_container *container, rgb_t &_color);
virtual ~ui_menu_palette_sel();
virtual void populate() override;
virtual void handle() override;

View File

@ -10,7 +10,7 @@
#include "emu.h"
#include "drivenum.h"
#include "ui/ui.h"
#include "ui/moptions.h"
#include "ui/datfile.h"
#include "ui/utils.h"
@ -58,9 +58,9 @@ bool datfile_manager::first_run = true;
//-------------------------------------------------
// ctor
//-------------------------------------------------
datfile_manager::datfile_manager(running_machine &machine) : m_machine(machine)
datfile_manager::datfile_manager(running_machine &machine, ui_options &moptions) : m_machine(machine), m_options(moptions)
{
if (mame_machine_manager::instance()->ui().options().enabled_dats() && first_run)
if (m_options.enabled_dats() && first_run)
{
first_run = false;
if (parseopen("mameinfo.dat"))
@ -577,7 +577,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(mame_machine_manager::instance()->ui().options().history_path(), OPEN_FLAG_READ);
emu_file file(m_options.history_path(), OPEN_FLAG_READ);
if (file.open(filename) != osd_file::error::NONE)
return false;

View File

@ -13,6 +13,8 @@
#ifndef __UI_DATFILE_H__
#define __UI_DATFILE_H__
class ui_options;
//-------------------------------------------------
// Datafile Manager
//-------------------------------------------------
@ -20,7 +22,7 @@ class datfile_manager
{
public:
// construction/destruction
datfile_manager(running_machine &machine);
datfile_manager(running_machine &machine, ui_options &moptions);
// getters
running_machine &machine() const { return m_machine; }
@ -86,6 +88,7 @@ private:
// internal state
running_machine &m_machine; // reference to our machine
ui_options &m_options;
std::string m_fullpath;
static std::string m_history_rev, m_mame_rev, m_mess_rev, m_sysinfo_rev, m_story_rev, m_ginit_rev;
FILE *fp = nullptr;

View File

@ -9,6 +9,7 @@
*********************************************************************/
#include "emu.h"
#include "mame.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "rendfont.h"
@ -21,14 +22,14 @@
// ctor / dtor
//-------------------------------------------------
ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, const game_driver *driver)
: ui_menu(machine, container)
ui_menu_dats_view::ui_menu_dats_view(mame_ui_manager &mui, render_container *container, const game_driver *driver)
: ui_menu(mui, container)
, m_actual(0)
, m_driver((driver == nullptr) ? &machine.system() : driver)
, m_driver((driver == nullptr) ? &mui.machine().system() : driver)
, m_issoft(false)
{
for (device_image_interface &image : image_interface_iterator(machine.root_device()))
for (device_image_interface &image : image_interface_iterator(mui.machine().root_device()))
{
if (image.filename())
{
@ -46,10 +47,10 @@ ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container
// ctor
//-------------------------------------------------
ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, ui_software_info *swinfo, const game_driver *driver)
: ui_menu(machine, container)
ui_menu_dats_view::ui_menu_dats_view(mame_ui_manager &mui, render_container *container, ui_software_info *swinfo, const game_driver *driver)
: ui_menu(mui, container)
, m_actual(0)
, m_driver((driver == nullptr) ? &machine.system() : driver)
, m_driver((driver == nullptr) ? &mui.machine().system() : driver)
, m_swinfo(swinfo)
, m_list(swinfo->listname)
, m_short(swinfo->shortname)
@ -108,8 +109,8 @@ void ui_menu_dats_view::populate()
(m_issoft == true) ? get_data_sw() : get_data();
item_append(MENU_SEPARATOR_ITEM, nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), nullptr);
customtop = 2.0f * mame_machine_manager::instance()->ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
custombottom = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = 2.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
if (!paused)
machine().resume();
@ -121,13 +122,12 @@ void ui_menu_dats_view::populate()
void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float maxwidth = origx2 - origx1;
float width;
std::string driver = (m_issoft == true) ? m_swinfo->longname : m_driver->description;
mui.draw_text_full(container, driver.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, driver.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -135,24 +135,24 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
float x1 = 0.5f - 0.5f * maxwidth;
float x2 = x1 + maxwidth;
float y1 = origy1 - top;
float y2 = origy1 - 2.0f * UI_BOX_TB_BORDER - mui.get_line_height();
float y2 = origy1 - 2.0f * UI_BOX_TB_BORDER - ui().get_line_height();
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
x2 -= UI_BOX_LR_BORDER;
y1 += UI_BOX_TB_BORDER;
mui.draw_text_full(container, driver.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, driver.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
maxwidth = 0;
for (auto & elem : m_items_list)
{
mui.draw_text_full(container, elem.label.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.label.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
maxwidth += width;
}
@ -162,10 +162,10 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
x1 -= UI_BOX_LR_BORDER;
x2 += UI_BOX_LR_BORDER;
y1 = y2 + UI_BOX_TB_BORDER;
y2 += mui.get_line_height() + 2.0f * UI_BOX_TB_BORDER;
y2 += ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x2 -= UI_BOX_LR_BORDER;
@ -178,13 +178,13 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
x1 += space;
rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR;
rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR;
mui.draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NONE, fcolor, bcolor, &width, nullptr);
ui().draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NONE, fcolor, bcolor, &width, nullptr);
if (bcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NORMAL, fcolor, bcolor, &width, nullptr);
ui().draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NORMAL, fcolor, bcolor, &width, nullptr);
x1 += width + space;
++x;
}
@ -192,7 +192,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
// bottom
std::string revision;
revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision);
mui.draw_text_full(container, revision.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, revision.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(origx2 - origx1, width);
@ -203,7 +203,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -211,7 +211,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, revision.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, revision.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -244,7 +244,7 @@ void ui_menu_dats_view::get_data()
else
mame_machine_manager::instance()->datfile().load_data_info(m_driver, buffer, m_items_list[m_actual].option);
int lines = mame_machine_manager::instance()->ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend);
int lines = ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend);
for (int x = 0; x < lines; ++x)
{
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
@ -267,7 +267,7 @@ void ui_menu_dats_view::get_data_sw()
mame_machine_manager::instance()->datfile().load_software_info(m_swinfo->listname, buffer, m_swinfo->shortname, m_swinfo->parentname);
}
int lines = mame_machine_manager::instance()->ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend);
int lines = ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend);
for (int x = 0; x < lines; ++x)
{
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));

View File

@ -23,8 +23,8 @@ struct ui_software_info;
class ui_menu_dats_view : public ui_menu
{
public:
ui_menu_dats_view(running_machine &machine, render_container *container, ui_software_info *swinfo, const game_driver *driver = nullptr);
ui_menu_dats_view(running_machine &machine, render_container *container, const game_driver *driver = nullptr);
ui_menu_dats_view(mame_ui_manager &mui, render_container *container, ui_software_info *swinfo, const game_driver *driver = nullptr);
ui_menu_dats_view(mame_ui_manager &mui, render_container *container, const game_driver *driver = nullptr);
virtual ~ui_menu_dats_view();
virtual void populate() override;
virtual void handle() override;

View File

@ -27,7 +27,7 @@ template<class _DeviceType>
class ui_menu_device_control : public ui_menu
{
public:
ui_menu_device_control(running_machine &machine, render_container *container, _DeviceType *device);
ui_menu_device_control(mame_ui_manager &mui, render_container *container, _DeviceType *device);
protected:
_DeviceType *current_device() { return m_device; }
@ -53,10 +53,10 @@ private:
//-------------------------------------------------
template<class _DeviceType>
ui_menu_device_control<_DeviceType>::ui_menu_device_control(running_machine &machine, render_container *container, _DeviceType *device)
: ui_menu(machine, container)
ui_menu_device_control<_DeviceType>::ui_menu_device_control(mame_ui_manager &mui, render_container *container, _DeviceType *device)
: ui_menu(mui, container)
{
iterator iter(machine.root_device());
iterator iter(mui.machine().root_device());
m_count = iter.count();
m_device = device ? device : iter.first();
}

View File

@ -18,7 +18,7 @@
menu
-------------------------------------------------*/
ui_menu_device_config::ui_menu_device_config(running_machine &machine, render_container *container, device_slot_interface *slot, device_slot_option *option) : ui_menu(machine, container)
ui_menu_device_config::ui_menu_device_config(mame_ui_manager &mui, render_container *container, device_slot_interface *slot, device_slot_option *option) : ui_menu(mui, container)
{
m_option = option;
m_owner = slot;

View File

@ -15,7 +15,7 @@
class ui_menu_device_config : public ui_menu {
public:
ui_menu_device_config(running_machine &machine, render_container *container, device_slot_interface *slot, device_slot_option *option);
ui_menu_device_config(mame_ui_manager &mui, render_container *container, device_slot_interface *slot, device_slot_option *option);
virtual ~ui_menu_device_config();
virtual void populate() override;
virtual void handle() override;

View File

@ -10,6 +10,7 @@
#include "emu.h"
#include "emuopts.h"
#include "mame.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "ui/dirmenu.h"
@ -67,13 +68,13 @@ static const folders_entry s_folders[] =
// ctor / dtor
//-------------------------------------------------
ui_menu_directory::ui_menu_directory(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_directory::ui_menu_directory(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
ui_menu_directory::~ui_menu_directory()
{
save_ui_options(machine());
ui().save_ui_options();
ui_globals::reset = true;
mame_machine_manager::instance()->datfile().reset_run();
}
@ -88,7 +89,7 @@ void ui_menu_directory::handle()
const ui_menu_event *m_event = process(0);
if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_display_actual>(machine(), container, selected));
ui_menu::stack_push(global_alloc_clear<ui_menu_display_actual>(ui(), container, selected));
}
//-------------------------------------------------
@ -101,7 +102,7 @@ void ui_menu_directory::populate()
item_append(_(elem.name), nullptr, 0, (void *)(FPTR)elem.action);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -111,11 +112,10 @@ void ui_menu_directory::populate()
void ui_menu_directory::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// get the size of the text
mui.draw_text_full(container, _("Folders Setup"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Folders Setup"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
float maxwidth = MAX(width, origx2 - origx1);
@ -126,7 +126,7 @@ void ui_menu_directory::custom_render(void *selectedref, float top, float bottom
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -134,7 +134,7 @@ void ui_menu_directory::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Folders Setup"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Folders Setup"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -145,8 +145,8 @@ 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(machine, container), m_ref(ref)
ui_menu_display_actual::ui_menu_display_actual(mame_ui_manager &mui, render_container *container, int ref)
: ui_menu(mui, container), m_ref(ref)
{
}
@ -166,11 +166,11 @@ void ui_menu_display_actual::handle()
switch ((FPTR)m_event->itemref)
{
case REMOVE:
ui_menu::stack_push(global_alloc_clear<ui_menu_remove_folder>(machine(), container, m_ref));
ui_menu::stack_push(global_alloc_clear<ui_menu_remove_folder>(ui(), container, m_ref));
break;
case ADD_CHANGE:
ui_menu::stack_push(global_alloc_clear<ui_menu_add_change_folder>(machine(), container, m_ref));
ui_menu::stack_push(global_alloc_clear<ui_menu_add_change_folder>(ui(), container, m_ref));
break;
}
}
@ -182,8 +182,8 @@ void ui_menu_display_actual::handle()
void ui_menu_display_actual::populate()
{
m_tempbuf = string_format(_("Current %1$s Folders"), _(s_folders[m_ref].name));
if (mame_machine_manager::instance()->ui().options().exists(s_folders[m_ref].option))
m_searchpath.assign(mame_machine_manager::instance()->ui().options().value(s_folders[m_ref].option));
if (ui().options().exists(s_folders[m_ref].option))
m_searchpath.assign(ui().options().value(s_folders[m_ref].option));
else
m_searchpath.assign(machine().options().value(s_folders[m_ref].option));
@ -199,7 +199,7 @@ void ui_menu_display_actual::populate()
item_append(_("Remove Folder"), nullptr, 0, (void *)REMOVE);
item_append(ui_menu_item_type::SEPARATOR);
customtop = (m_folders.size() + 1) * mame_machine_manager::instance()->ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER;
customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -209,18 +209,17 @@ void ui_menu_display_actual::populate()
void ui_menu_display_actual::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width, maxwidth = origx2 - origx1;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float lineh = mui.get_line_height();
float lineh = ui().get_line_height();
for (auto & elem : m_folders)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
maxwidth = MAX(maxwidth, width);
}
// get the size of the text
mui.draw_text_full(container, m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
maxwidth = MAX(width, maxwidth);
@ -231,7 +230,7 @@ void ui_menu_display_actual::custom_render(void *selectedref, float top, float b
float y2 = y1 + lineh + 2.0f * UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -239,7 +238,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,
ui().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
@ -249,7 +248,7 @@ void ui_menu_display_actual::custom_render(void *selectedref, float top, float b
y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -259,7 +258,7 @@ void ui_menu_display_actual::custom_render(void *selectedref, float top, float b
// draw the text within it
for (auto & elem : m_folders)
{
mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_LEFT, WRAP_TRUNCATE,
ui().draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_LEFT, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
y1 += lineh;
}
@ -273,7 +272,7 @@ MENU ADD FOLDER
// ctor / dtor
//-------------------------------------------------
ui_menu_add_change_folder::ui_menu_add_change_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container)
ui_menu_add_change_folder::ui_menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref) : ui_menu(mui, container)
{
m_ref = ref;
m_change = (s_folders[ref].action == CHANGE);
@ -283,10 +282,10 @@ ui_menu_add_change_folder::ui_menu_add_change_folder(running_machine &machine, r
osd_get_full_path(m_current_path, ".");
std::string searchpath;
if (mame_machine_manager::instance()->ui().options().exists(s_folders[m_ref].option))
searchpath = mame_machine_manager::instance()->ui().options().value(s_folders[m_ref].option);
if (mui.options().exists(s_folders[m_ref].option))
searchpath = mui.options().value(s_folders[m_ref].option);
else
searchpath = machine.options().value(s_folders[m_ref].option);
searchpath = mui.machine().options().value(s_folders[m_ref].option);
path_iterator path(searchpath.c_str());
std::string curpath;
@ -365,8 +364,8 @@ void ui_menu_add_change_folder::handle()
std::string error_string;
if (m_change)
{
if (mame_machine_manager::instance()->ui().options().exists(s_folders[m_ref].option))
mame_machine_manager::instance()->ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
if (ui().options().exists(s_folders[m_ref].option))
ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
else 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);
@ -385,8 +384,8 @@ void ui_menu_add_change_folder::handle()
tmppath.append(";");
}
if (mame_machine_manager::instance()->ui().options().exists(s_folders[m_ref].option))
mame_machine_manager::instance()->ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
if (ui().options().exists(s_folders[m_ref].option))
ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
else 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);
@ -479,8 +478,8 @@ void ui_menu_add_change_folder::populate()
item_append(ui_menu_item_type::SEPARATOR);
// configure the custom rendering
customtop = 2.0f * mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = 1.0f * mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = 1.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -490,7 +489,6 @@ void ui_menu_add_change_folder::populate()
void ui_menu_add_change_folder::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width, maxwidth = origx2 - origx1;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
std::string tempbuf[2];
tempbuf[0] = string_format(
(m_change)
@ -503,8 +501,8 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
// get the size of the text
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
maxwidth = MAX(width, maxwidth);
}
@ -516,7 +514,7 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -526,16 +524,16 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
// draw the text within it
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
y1 = y1 + mui.get_line_height();
y1 = y1 + ui().get_line_height();
}
// bottom text
tempbuf[0] = _("Press TAB to set");
mui.draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -546,7 +544,7 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -554,7 +552,7 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, tempbuf[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, tempbuf[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -566,13 +564,13 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
// ctor / dtor
//-------------------------------------------------
ui_menu_remove_folder::ui_menu_remove_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container)
ui_menu_remove_folder::ui_menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref) : ui_menu(mui, container)
{
m_ref = ref;
if (mame_machine_manager::instance()->ui().options().exists(s_folders[m_ref].option))
m_searchpath.assign(mame_machine_manager::instance()->ui().options().value(s_folders[m_ref].option));
if (mui.options().exists(s_folders[m_ref].option))
m_searchpath.assign(mui.options().value(s_folders[m_ref].option));
else
m_searchpath.assign(machine.options().value(s_folders[m_ref].option));
m_searchpath.assign(mui.machine().options().value(s_folders[m_ref].option));
path_iterator path(m_searchpath.c_str());
std::string curpath;
@ -603,8 +601,8 @@ void ui_menu_remove_folder::handle()
tmppath.append(";");
}
if (mame_machine_manager::instance()->ui().options().exists(s_folders[m_ref].option))
mame_machine_manager::instance()->ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
if (ui().options().exists(s_folders[m_ref].option))
ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
else 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);
@ -627,7 +625,7 @@ void ui_menu_remove_folder::populate()
item_append(elem.c_str(), nullptr, 0, (void *)(FPTR)++folders_count);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -637,11 +635,10 @@ void ui_menu_remove_folder::populate()
void ui_menu_remove_folder::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
std::string tempbuf = string_format(_("Remove %1$s Folder"), _(s_folders[m_ref].name));
// get the size of the text
mui.draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
float maxwidth = MAX(width, origx2 - origx1);
@ -652,7 +649,7 @@ void ui_menu_remove_folder::custom_render(void *selectedref, float top, float bo
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -660,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,
ui().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);
}

View File

@ -20,7 +20,7 @@
class ui_menu_directory : public ui_menu
{
public:
ui_menu_directory(running_machine &machine, render_container *container);
ui_menu_directory(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_directory();
virtual void populate() override;
virtual void handle() override;
@ -34,7 +34,7 @@ public:
class ui_menu_display_actual : public ui_menu
{
public:
ui_menu_display_actual(running_machine &machine, render_container *container, int selectedref);
ui_menu_display_actual(mame_ui_manager &mui, render_container *container, int selectedref);
virtual ~ui_menu_display_actual();
virtual void populate() override;
virtual void handle() override;
@ -59,7 +59,7 @@ private:
class ui_menu_remove_folder : public ui_menu
{
public:
ui_menu_remove_folder(running_machine &machine, render_container *container, int ref);
ui_menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref);
virtual ~ui_menu_remove_folder();
virtual void populate() override;
virtual void handle() override;
@ -78,7 +78,7 @@ private:
class ui_menu_add_change_folder : public ui_menu
{
public:
ui_menu_add_change_folder(running_machine &machine, render_container *container, int ref);
ui_menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref);
virtual ~ui_menu_add_change_folder();
virtual void populate() override;
virtual void handle() override;

View File

@ -30,7 +30,7 @@
// ctor
//-------------------------------------------------
ui_menu_file_manager::ui_menu_file_manager(running_machine &machine, render_container *container, const char *warnings) : ui_menu(machine, container), selected_device(nullptr)
ui_menu_file_manager::ui_menu_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings) : ui_menu(mui, container), selected_device(nullptr)
{
// This warning string is used when accessing from the force_file_manager call, i.e.
// when the file manager is loaded top front in the case of mandatory image devices
@ -62,8 +62,7 @@ void ui_menu_file_manager::custom_render(void *selectedref, float top, float bot
// access the path
path = selected_device ? selected_device->filename() : nullptr;
extra_text_render(container, top, bottom,
origx1, origy1, origx2, origy2, nullptr, path);
extra_text_render(top, bottom, origx1, origy1, origx2, origy2, nullptr, path);
}
@ -156,7 +155,7 @@ void ui_menu_file_manager::populate()
item_append(ui_menu_item_type::SEPARATOR);
item_append("Reset", nullptr, 0, (void *)1);
custombottom = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
@ -185,11 +184,11 @@ void ui_menu_file_manager::handle()
floppy_image_device *floppy_device = dynamic_cast<floppy_image_device *>(selected_device);
if (floppy_device != nullptr)
{
ui_menu::stack_push(global_alloc_clear<ui_menu_control_floppy_image>(machine(), container, floppy_device));
ui_menu::stack_push(global_alloc_clear<ui_menu_control_floppy_image>(ui(), container, floppy_device));
}
else
{
ui_menu::stack_push(global_alloc_clear<ui_menu_control_device_image>(machine(), container, selected_device));
ui_menu::stack_push(global_alloc_clear<ui_menu_control_device_image>(ui(), container, selected_device));
}
// reset the existing menu
reset(UI_MENU_RESET_REMEMBER_POSITION);
@ -199,20 +198,20 @@ void ui_menu_file_manager::handle()
}
// force file manager menu
void ui_menu_file_manager::force_file_manager(running_machine &machine, render_container *container, const char *warnings)
void ui_menu_file_manager::force_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings)
{
// reset the menu stack
ui_menu::stack_reset(machine);
ui_menu::stack_reset(mui.machine());
// add the quit entry followed by the game select entry
ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(machine, container);
ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(mui, container);
quit->set_special_main_menu(true);
ui_menu::stack_push(quit);
ui_menu::stack_push(global_alloc_clear<ui_menu_file_manager>(machine, container, warnings));
ui_menu::stack_push(global_alloc_clear<ui_menu_file_manager>(mui, container, warnings));
// force the menus on
mame_machine_manager::instance()->ui().show_menu();
mui.show_menu();
// make sure MAME is paused
machine.pause();
mui.machine().pause();
}

View File

@ -19,9 +19,9 @@ public:
std::string current_file;
device_image_interface *selected_device;
static void force_file_manager(running_machine &machine, render_container *container, const char *warnings);
static void force_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings);
ui_menu_file_manager(running_machine &machine, render_container *container, const char *warnings);
ui_menu_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings);
virtual ~ui_menu_file_manager();
virtual void populate() override;
virtual void handle() override;

View File

@ -65,67 +65,6 @@ static void input_character(char *buffer, size_t buffer_length, unicode_char uni
}
}
//-------------------------------------------------
// extra_text_draw_box - generically adds header
// or footer text
//-------------------------------------------------
static void extra_text_draw_box(render_container *container, float origx1, float origx2, float origy, float yspan, const char *text, int direction)
{
float text_width, text_height;
float width, maxwidth;
float x1, y1, x2, y2, temp;
// get the size of the text
mame_machine_manager::instance()->ui().draw_text_full(container,text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &text_width, &text_height);
width = text_width + (2 * UI_BOX_LR_BORDER);
maxwidth = MAX(width, origx2 - origx1);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
x2 = x1 + maxwidth;
y1 = origy + (yspan * direction);
y2 = origy + (UI_BOX_TB_BORDER * direction);
if (y1 > y2)
{
temp = y1;
y1 = y2;
y2 = temp;
}
// draw a box
mame_machine_manager::instance()->ui().draw_outlined_box(container,x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mame_machine_manager::instance()->ui().draw_text_full(container,text, x1, y1, text_width, JUSTIFY_LEFT, WRAP_WORD,
DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr);
}
//-------------------------------------------------
// extra_text_render - generically adds header
// and footer text
//-------------------------------------------------
void extra_text_render(render_container *container, float top, float bottom,
float origx1, float origy1, float origx2, float origy2,
const char *header, const char *footer)
{
header = ((header != nullptr) && (header[0] != '\0')) ? header : nullptr;
footer = ((footer != nullptr) && (footer[0] != '\0')) ? footer : nullptr;
if (header != nullptr)
extra_text_draw_box(container, origx1, origx2, origy1, top, header, -1);
if (footer != nullptr)
extra_text_draw_box(container, origx1, origx2, origy2, bottom, footer, +1);
}
/***************************************************************************
CONFIRM SAVE AS MENU
@ -135,8 +74,8 @@ void extra_text_render(render_container *container, float top, float bottom,
// ctor
//-------------------------------------------------
ui_menu_confirm_save_as::ui_menu_confirm_save_as(running_machine &machine, render_container *container, bool *yes)
: ui_menu(machine, container)
ui_menu_confirm_save_as::ui_menu_confirm_save_as(mame_ui_manager &mui, render_container *container, bool *yes)
: ui_menu(mui, container)
{
m_yes = yes;
*m_yes = false;
@ -217,8 +156,8 @@ static int is_valid_filename_char(unicode_char unichar)
// ctor
//-------------------------------------------------
ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool *ok)
: ui_menu(machine, container),
ui_menu_file_create::ui_menu_file_create(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool *ok)
: ui_menu(mui, container),
m_current_directory(current_directory),
m_current_file(current_file),
m_current_format(nullptr)
@ -246,7 +185,7 @@ ui_menu_file_create::~ui_menu_file_create()
void ui_menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
extra_text_render(container, top, bottom, origx1, origy1, origx2, origy2,
extra_text_render(top, bottom, origx1, origy1, origx2, origy2,
m_current_directory.c_str(),
nullptr);
}
@ -286,7 +225,7 @@ void ui_menu_file_create::populate()
item_append(ui_menu_item_type::SEPARATOR);
item_append(_("Create"), nullptr, 0, ITEMREF_CREATE);
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
@ -315,7 +254,7 @@ void ui_menu_file_create::handle()
ui_menu::stack_pop(machine());
}
else
mame_machine_manager::instance()->ui().popup_time(1, "%s", _("Please enter a file extension too"));
ui().popup_time(1, "%s", _("Please enter a file extension too"));
}
break;
@ -345,8 +284,8 @@ void ui_menu_file_create::handle()
// ctor
//-------------------------------------------------
ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool has_empty, bool has_softlist, bool has_create, int *result)
: ui_menu(machine, container),
ui_menu_file_selector::ui_menu_file_selector(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool has_empty, bool has_softlist, bool has_create, int *result)
: ui_menu(mui, container),
m_current_directory(current_directory),
m_current_file(current_file),
m_entrylist(nullptr)
@ -374,7 +313,7 @@ ui_menu_file_selector::~ui_menu_file_selector()
void ui_menu_file_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
extra_text_render(container, top, bottom,
extra_text_render(top, bottom,
origx1, origy1, origx2, origy2,
m_current_directory.c_str(),
nullptr);
@ -612,7 +551,7 @@ void ui_menu_file_selector::populate()
set_selection((void *) selected_entry);
// set up custom render proc
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
if (directory != nullptr)
util::zippath_closedir(directory);
@ -664,7 +603,7 @@ void ui_menu_file_selector::handle()
if (err != osd_file::error::NONE)
{
// this path is problematic; present the user with an error and bail
mame_machine_manager::instance()->ui().popup_time(1, "Error accessing %s", entry->fullpath);
ui().popup_time(1, "Error accessing %s", entry->fullpath);
break;
}
m_current_directory.assign(entry->fullpath);
@ -695,7 +634,7 @@ void ui_menu_file_selector::handle()
update_selected = TRUE;
if (ARRAY_LENGTH(m_filename_buffer) > 0)
mame_machine_manager::instance()->ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
}
// if it's any other key and we're not maxed out, update
else if (event->unichar >= ' ' && event->unichar < 0x7f)
@ -705,7 +644,7 @@ void ui_menu_file_selector::handle()
update_selected = TRUE;
if (ARRAY_LENGTH(m_filename_buffer) > 0)
mame_machine_manager::instance()->ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
}
if (update_selected)
@ -778,8 +717,8 @@ void ui_menu_file_selector::handle()
// ctor
//-------------------------------------------------
ui_menu_select_format::ui_menu_select_format(running_machine &machine, render_container *container, floppy_image_format_t **formats, int ext_match, int total_usable, int *result)
: ui_menu(machine, container)
ui_menu_select_format::ui_menu_select_format(mame_ui_manager &mui, render_container *container, floppy_image_format_t **formats, int ext_match, int total_usable, int *result)
: ui_menu(mui, container)
{
m_formats = formats;
m_ext_match = ext_match;
@ -839,9 +778,9 @@ void ui_menu_select_format::handle()
// ctor
//-------------------------------------------------
ui_menu_select_rw::ui_menu_select_rw(running_machine &machine, render_container *container,
ui_menu_select_rw::ui_menu_select_rw(mame_ui_manager &mui, render_container *container,
bool can_in_place, int *result)
: ui_menu(machine, container)
: ui_menu(mui, container)
{
m_can_in_place = can_in_place;
m_result = result;

View File

@ -18,7 +18,7 @@
class ui_menu_confirm_save_as : public ui_menu
{
public:
ui_menu_confirm_save_as(running_machine &machine, render_container *container, bool *yes);
ui_menu_confirm_save_as(mame_ui_manager &mui, render_container *container, bool *yes);
virtual ~ui_menu_confirm_save_as();
virtual void populate() override;
virtual void handle() override;
@ -33,7 +33,7 @@ private:
class ui_menu_file_create : public ui_menu
{
public:
ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool *ok);
ui_menu_file_create(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool *ok);
virtual ~ui_menu_file_create();
virtual void populate() override;
virtual void handle() override;
@ -57,7 +57,7 @@ class ui_menu_file_selector : public ui_menu
{
public:
enum { R_EMPTY, R_SOFTLIST, R_CREATE, R_FILE };
ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool has_empty, bool has_softlist, bool has_create, int *result);
ui_menu_file_selector(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string &current_directory, std::string &current_file, bool has_empty, bool has_softlist, bool has_create, int *result);
virtual ~ui_menu_file_selector();
virtual void populate() override;
virtual void handle() override;
@ -107,7 +107,7 @@ private:
class ui_menu_select_format : public ui_menu
{
public:
ui_menu_select_format(running_machine &machine, render_container *container,
ui_menu_select_format(mame_ui_manager &mui, render_container *container,
class floppy_image_format_t **formats, int ext_match, int total_usable, int *result);
virtual ~ui_menu_select_format();
virtual void populate() override;
@ -128,7 +128,7 @@ class ui_menu_select_rw : public ui_menu
{
public:
enum { READONLY, READWRITE, WRITE_OTHER, WRITE_DIFF };
ui_menu_select_rw(running_machine &machine, render_container *container,
ui_menu_select_rw(mame_ui_manager &mui, render_container *container,
bool can_in_place, int *result);
virtual ~ui_menu_select_rw();
virtual void populate() override;
@ -140,9 +140,4 @@ private:
int * m_result;
};
// helper
void extra_text_render(render_container *container, float top, float bottom,
float origx1, float origy1, float origx2, float origy2,
const char *header, const char *footer);
#endif /* __UI_FILESEL_H__ */

View File

@ -17,7 +17,7 @@
IMPLEMENTATION
***************************************************************************/
ui_menu_control_floppy_image::ui_menu_control_floppy_image(running_machine &machine, render_container *container, device_image_interface *_image) : ui_menu_control_device_image(machine, container, _image)
ui_menu_control_floppy_image::ui_menu_control_floppy_image(mame_ui_manager &mui, render_container *container, device_image_interface *_image) : ui_menu_control_device_image(mui, container, _image)
{
floppy_image_device *fd = static_cast<floppy_image_device *>(image);
const floppy_image_format_t *fif_list = fd->get_formats();
@ -91,7 +91,7 @@ void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist
can_in_place = false;
}
submenu_result = -1;
ui_menu::stack_push(global_alloc_clear<ui_menu_select_rw>(machine(), container, can_in_place, &submenu_result));
ui_menu::stack_push(global_alloc_clear<ui_menu_select_rw>(ui(), container, can_in_place, &submenu_result));
state = SELECT_RW;
}
@ -117,7 +117,7 @@ void ui_menu_control_floppy_image::handle()
format_array[total_usable++] = i;
}
submenu_result = -1;
ui_menu::stack_push(global_alloc_clear<ui_menu_select_format>(machine(), container, format_array, ext_match, total_usable, &submenu_result));
ui_menu::stack_push(global_alloc_clear<ui_menu_select_format>(ui(), container, format_array, ext_match, total_usable, &submenu_result));
state = SELECT_FORMAT;
break;
@ -154,7 +154,7 @@ void ui_menu_control_floppy_image::handle()
break;
case ui_menu_select_rw::WRITE_OTHER:
ui_menu::stack_push(global_alloc_clear<ui_menu_file_create>(machine(), container, image, current_directory, current_file, &create_ok));
ui_menu::stack_push(global_alloc_clear<ui_menu_file_create>(ui(), container, image, current_directory, current_file, &create_ok));
state = CHECK_CREATE;
break;

View File

@ -16,7 +16,7 @@
class ui_menu_control_floppy_image : public ui_menu_control_device_image {
public:
ui_menu_control_floppy_image(running_machine &machine, render_container *container, device_image_interface *image);
ui_menu_control_floppy_image(mame_ui_manager &ui, render_container *container, device_image_interface *image);
virtual ~ui_menu_control_floppy_image();
virtual void handle() override;

View File

@ -29,8 +29,8 @@
// ctor
//-------------------------------------------------
ui_menu_control_device_image::ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *_image)
: ui_menu(machine, container),
ui_menu_control_device_image::ui_menu_control_device_image(mame_ui_manager &mui, render_container *container, device_image_interface *_image)
: ui_menu(mui, container),
submenu_result(0),
create_ok(false),
create_confirmed(false)
@ -38,7 +38,7 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach
image = _image;
if (image->software_list_name())
sld = software_list_device::find_by_name(machine.config(), image->software_list_name());
sld = software_list_device::find_by_name(mui.machine().config(), image->software_list_name());
else
sld = nullptr;
swi = image->software_entry();
@ -110,7 +110,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf
case ENTTYPE_DIR:
/* a directory exists here - we can't save over it */
mame_machine_manager::instance()->ui().popup_time(5, "%s", _("Cannot save over directory"));
ui().popup_time(5, "%s", _("Cannot save over directory"));
can_create = false;
need_confirm = false;
break;
@ -187,20 +187,20 @@ void ui_menu_control_device_image::handle()
util::zippath_closedir(directory);
}
submenu_result = -1;
ui_menu::stack_push(global_alloc_clear<ui_menu_file_selector>(machine(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result));
ui_menu::stack_push(global_alloc_clear<ui_menu_file_selector>(ui(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result));
state = SELECT_FILE;
break;
}
case START_SOFTLIST:
sld = nullptr;
ui_menu::stack_push(global_alloc_clear<ui_menu_software>(machine(), container, image->image_interface(), &sld));
ui_menu::stack_push(global_alloc_clear<ui_menu_software>(ui(), container, image->image_interface(), &sld));
state = SELECT_SOFTLIST;
break;
case START_OTHER_PART: {
submenu_result = -1;
ui_menu::stack_push(global_alloc_clear<ui_menu_software_parts>(machine(), container, swi, swp->interface(), &swp, true, &submenu_result));
ui_menu::stack_push(global_alloc_clear<ui_menu_software_parts>(ui(), container, swi, swp->interface(), &swp, true, &submenu_result));
state = SELECT_OTHER_PART;
break;
}
@ -211,7 +211,7 @@ void ui_menu_control_device_image::handle()
break;
}
software_info_name = "";
ui_menu::stack_push(global_alloc_clear<ui_menu_software_list>(machine(), container, sld, image->image_interface(), software_info_name));
ui_menu::stack_push(global_alloc_clear<ui_menu_software_list>(ui(), container, sld, image->image_interface(), software_info_name));
state = SELECT_PARTLIST;
break;
@ -223,7 +223,7 @@ void ui_menu_control_device_image::handle()
{
submenu_result = -1;
swp = nullptr;
ui_menu::stack_push(global_alloc_clear<ui_menu_software_parts>(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result));
ui_menu::stack_push(global_alloc_clear<ui_menu_software_parts>(ui(), container, swi, image->image_interface(), &swp, false, &submenu_result));
state = SELECT_ONE_PART;
}
else
@ -287,7 +287,7 @@ void ui_menu_control_device_image::handle()
break;
case ui_menu_file_selector::R_CREATE:
ui_menu::stack_push(global_alloc_clear<ui_menu_file_create>(machine(), container, image, current_directory, current_file, &create_ok));
ui_menu::stack_push(global_alloc_clear<ui_menu_file_create>(ui(), container, image, current_directory, current_file, &create_ok));
state = CHECK_CREATE;
break;
@ -307,7 +307,7 @@ void ui_menu_control_device_image::handle()
test_create(can_create, need_confirm);
if(can_create) {
if(need_confirm) {
ui_menu::stack_push(global_alloc_clear<ui_menu_confirm_save_as>(machine(), container, &create_confirmed));
ui_menu::stack_push(global_alloc_clear<ui_menu_confirm_save_as>(ui(), container, &create_confirmed));
state = CREATE_CONFIRM;
} else {
state = DO_CREATE;

View File

@ -17,7 +17,7 @@
class ui_menu_control_device_image : public ui_menu {
public:
ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *image);
ui_menu_control_device_image(mame_ui_manager &mui, render_container *container, device_image_interface *image);
virtual ~ui_menu_control_device_image();
virtual void populate() override;
virtual void handle() override;

View File

@ -19,7 +19,7 @@
menu
-------------------------------------------------*/
ui_menu_game_info::ui_menu_game_info(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_game_info::ui_menu_game_info(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -30,7 +30,7 @@ ui_menu_game_info::~ui_menu_game_info()
void ui_menu_game_info::populate()
{
std::string tempstring;
item_append(mame_machine_manager::instance()->ui().game_info_astring(tempstring).c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr);
item_append(ui().game_info_astring(tempstring).c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr);
}
void ui_menu_game_info::handle()
@ -45,7 +45,7 @@ void ui_menu_game_info::handle()
menu
-------------------------------------------------*/
ui_menu_image_info::ui_menu_image_info(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_image_info::ui_menu_image_info(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}

View File

@ -15,7 +15,7 @@
class ui_menu_game_info : public ui_menu {
public:
ui_menu_game_info(running_machine &machine, render_container *container);
ui_menu_game_info(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_game_info();
virtual void populate() override;
virtual void handle() override;
@ -25,7 +25,7 @@ public:
class ui_menu_image_info : public ui_menu
{
public:
ui_menu_image_info(running_machine &machine, render_container *container);
ui_menu_image_info(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_image_info();
virtual void populate() override;
virtual void handle() override;

View File

@ -12,8 +12,8 @@
#include "ui/menu.h"
#include "ui/info_pty.h"
ui_menu_pty_info::ui_menu_pty_info(running_machine &machine, render_container *container) :
ui_menu(machine, container)
ui_menu_pty_info::ui_menu_pty_info(mame_ui_manager &mui, render_container *container) :
ui_menu(mui, container)
{
}

View File

@ -15,7 +15,7 @@
class ui_menu_pty_info : public ui_menu {
public:
ui_menu_pty_info(running_machine &machine, render_container *container);
ui_menu_pty_info(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_pty_info();
virtual void populate() override;
virtual void handle() override;

View File

@ -9,7 +9,7 @@
***************************************************************************/
#include "emu.h"
#include "ui/ui.h"
#include "ui/moptions.h"
#include "ui/inifile.h"
#include "softlist.h"
#include "drivenum.h"
@ -24,8 +24,8 @@ UINT16 inifile_manager::c_file = 0;
// ctor
//-------------------------------------------------
inifile_manager::inifile_manager(running_machine &machine)
: m_machine(machine)
inifile_manager::inifile_manager(running_machine &machine, ui_options &moptions)
: m_machine(machine), m_options(moptions)
{
ini_index.clear();
directory_scan();
@ -38,7 +38,7 @@ inifile_manager::inifile_manager(running_machine &machine)
void inifile_manager::directory_scan()
{
// open extra INIs folder
file_enumerator path(mame_machine_manager::instance()->ui().options().extraini_path());
file_enumerator path(m_options.extraini_path());
const osd_directory_entry *dir;
// loop into folder's file
@ -151,7 +151,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(mame_machine_manager::instance()->ui().options().extraini_path(), OPEN_FLAG_READ);
emu_file file(m_options.extraini_path(), OPEN_FLAG_READ);
if (file.open(filename) != osd_file::error::NONE)
return false;
@ -172,8 +172,8 @@ bool inifile_manager::parseopen(const char *filename)
// ctor
//-------------------------------------------------
favorite_manager::favorite_manager(running_machine &machine)
: m_machine(machine)
favorite_manager::favorite_manager(running_machine &machine, ui_options &moptions)
: m_machine(machine), m_options(moptions)
{
m_current = -1;
parse_favorite();
@ -357,7 +357,7 @@ bool favorite_manager::isgame_favorite(ui_software_info &swinfo)
void favorite_manager::parse_favorite()
{
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_READ);
emu_file file(m_options.ui_path(), OPEN_FLAG_READ);
if (file.open(favorite_filename) == osd_file::error::NONE)
{
char readbuf[1024];
@ -416,7 +416,7 @@ void favorite_manager::parse_favorite()
void favorite_manager::save_favorite_games()
{
// attempt to open the output file
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
emu_file file(m_options.ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(favorite_filename) == osd_file::error::NONE)
{
if (m_list.empty())

View File

@ -19,11 +19,13 @@
// INIFILE MANAGER
//-------------------------------------------------
class ui_options;
class inifile_manager
{
public:
// construction/destruction
inifile_manager(running_machine &machine);
inifile_manager(running_machine &machine, ui_options &moptions);
// getters
running_machine &machine() const { return m_machine; }
@ -64,6 +66,7 @@ private:
// internal state
running_machine &m_machine; // reference to our machine
ui_options &m_options;
std::string m_fullpath;
FILE *fp = nullptr;
};
@ -76,7 +79,7 @@ class favorite_manager
{
public:
// construction/destruction
favorite_manager(running_machine &machine);
favorite_manager(running_machine &machine, ui_options &moptions);
// favorite indices
std::vector<ui_software_info> m_list;
@ -112,6 +115,7 @@ private:
// internal state
running_machine &m_machine; // reference to our machine
ui_options &m_options;
};
#endif /* __UI_INIFILE_H__ */

View File

@ -40,7 +40,7 @@
input groups menu
-------------------------------------------------*/
ui_menu_input_groups::ui_menu_input_groups(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_input_groups::ui_menu_input_groups(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -73,7 +73,7 @@ void ui_menu_input_groups::handle()
/* process the menu */
const ui_menu_event *menu_event = process(0);
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_input_general>(machine(), container, int((long long)(menu_event->itemref)-1)));
ui_menu::stack_push(global_alloc_clear<ui_menu_input_general>(ui(), container, int((long long)(menu_event->itemref)-1)));
}
@ -83,7 +83,7 @@ void ui_menu_input_groups::handle()
input menu
-------------------------------------------------*/
ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_container *container, int _group) : ui_menu_input(machine, container)
ui_menu_input_general::ui_menu_input_general(mame_ui_manager &mui, render_container *container, int _group) : ui_menu_input(mui, container)
{
group = _group;
}
@ -146,7 +146,7 @@ ui_menu_input_general::~ui_menu_input_general()
input menu
-------------------------------------------------*/
ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_container *container) : ui_menu_input(machine, container)
ui_menu_input_specific::ui_menu_input_specific(mame_ui_manager &mui, render_container *container) : ui_menu_input(mui, container)
{
}
@ -224,7 +224,7 @@ ui_menu_input_specific::~ui_menu_input_specific()
/*-------------------------------------------------
menu_input - display a menu for inputs
-------------------------------------------------*/
ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container), last_sortorder(0), record_next(false)
ui_menu_input::ui_menu_input(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container), last_sortorder(0), record_next(false)
{
pollingitem = nullptr;
pollingref = nullptr;
@ -447,7 +447,7 @@ void ui_menu_input::populate_and_sort(input_item_data *itemlist)
switches menu
-------------------------------------------------*/
ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_DIPSWITCH)
ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(mame_ui_manager &mui, render_container *container) : ui_menu_settings(mui, container, IPT_DIPSWITCH)
{
}
@ -460,7 +460,7 @@ ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches()
driver config menu
-------------------------------------------------*/
ui_menu_settings_driver_config::ui_menu_settings_driver_config(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_CONFIG)
ui_menu_settings_driver_config::ui_menu_settings_driver_config(mame_ui_manager &mui, render_container *container) : ui_menu_settings(mui, container, IPT_CONFIG)
{
}
@ -530,7 +530,7 @@ void ui_menu_settings::handle()
switches menus
-------------------------------------------------*/
ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container), diplist(nullptr), dipcount(0)
ui_menu_settings::ui_menu_settings(mame_ui_manager &mui, render_container *container, UINT32 _type) : ui_menu(mui, container), diplist(nullptr), dipcount(0)
{
type = _type;
}
@ -642,7 +642,7 @@ void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top,
y2 = y1 + bottom;
// draw extra menu area
mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
y1 += (float)DIP_SWITCH_SPACING;
// iterate over DIP switches
@ -688,11 +688,11 @@ void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float
x1 += (x2 - x1 - numtoggles * switch_field_width) / 2;
/* draw the dip switch name */
mame_machine_manager::instance()->ui().draw_text_full( container,
ui().draw_text_full( container,
dip->name,
0,
y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2,
x1 - mame_machine_manager::instance()->ui().get_string_width(" "),
x1 - ui().get_string_width(" "),
JUSTIFY_RIGHT,
WRAP_NEVER,
DRAW_NORMAL,
@ -712,7 +712,7 @@ void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float
float innerx1;
/* first outline the switch */
mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
/* compute x1/x2 for the inner filled in switch */
innerx1 = x1 + (switch_field_width - switch_width) / 2;
@ -805,7 +805,7 @@ void ui_menu_analog::handle()
settings menu
-------------------------------------------------*/
ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_analog::ui_menu_analog(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}

View File

@ -15,7 +15,7 @@
class ui_menu_input_groups : public ui_menu {
public:
ui_menu_input_groups(running_machine &machine, render_container *container);
ui_menu_input_groups(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_input_groups();
virtual void populate() override;
virtual void handle() override;
@ -23,7 +23,7 @@ public:
class ui_menu_input : public ui_menu {
public:
ui_menu_input(running_machine &machine, render_container *container);
ui_menu_input(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_input();
virtual void handle() override;
@ -68,7 +68,7 @@ private:
class ui_menu_input_general : public ui_menu_input {
public:
ui_menu_input_general(running_machine &machine, render_container *container, int group);
ui_menu_input_general(mame_ui_manager &mui, render_container *container, int group);
virtual ~ui_menu_input_general();
virtual void populate() override;
@ -79,7 +79,7 @@ protected:
class ui_menu_input_specific : public ui_menu_input {
public:
ui_menu_input_specific(running_machine &machine, render_container *container);
ui_menu_input_specific(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_input_specific();
virtual void populate() override;
@ -89,7 +89,7 @@ protected:
class ui_menu_settings : public ui_menu {
public:
ui_menu_settings(running_machine &machine, render_container *container, UINT32 type);
ui_menu_settings(mame_ui_manager &mui, render_container *container, UINT32 type);
virtual ~ui_menu_settings();
virtual void populate() override;
virtual void handle() override;
@ -110,7 +110,7 @@ protected:
class ui_menu_settings_dip_switches : public ui_menu_settings {
public:
ui_menu_settings_dip_switches(running_machine &machine, render_container *container);
ui_menu_settings_dip_switches(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_settings_dip_switches();
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
@ -120,13 +120,13 @@ private:
class ui_menu_settings_driver_config : public ui_menu_settings {
public:
ui_menu_settings_driver_config(running_machine &machine, render_container *container);
ui_menu_settings_driver_config(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_settings_driver_config();
};
class ui_menu_analog : public ui_menu {
public:
ui_menu_analog(running_machine &machine, render_container *container);
ui_menu_analog(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_analog();
virtual void populate() override;
virtual void handle() override;

View File

@ -11,6 +11,7 @@
#include "emu.h"
#include "crsshair.h"
#include "emuopts.h"
#include "mame.h"
#include "ui/menu.h"
#include "ui/filemngr.h"
#include "ui/barcode.h"
@ -42,7 +43,7 @@
ui_menu_main constructor - populate the main menu
-------------------------------------------------*/
ui_menu_main::ui_menu_main(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_main::ui_menu_main(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -127,7 +128,7 @@ void ui_menu_main::populate()
item_append(_("Plugin Options"), nullptr, 0, (void *)PLUGINS);
// add dats menu
if (mame_machine_manager::instance()->ui().options().enabled_dats() && mame_machine_manager::instance()->datfile().has_data())
if (ui().options().enabled_dats() && mame_machine_manager::instance()->datfile().has_data())
item_append(_("External DAT View"), nullptr, 0, (void *)EXTERNAL_DATS);
item_append(ui_menu_item_type::SEPARATOR);
@ -161,103 +162,103 @@ void ui_menu_main::handle()
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) {
switch((long long)(menu_event->itemref)) {
case INPUT_GROUPS:
ui_menu::stack_push(global_alloc_clear<ui_menu_input_groups>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_input_groups>(ui(), container));
break;
case INPUT_SPECIFIC:
ui_menu::stack_push(global_alloc_clear<ui_menu_input_specific>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_input_specific>(ui(), container));
break;
case SETTINGS_DIP_SWITCHES:
ui_menu::stack_push(global_alloc_clear<ui_menu_settings_dip_switches>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_settings_dip_switches>(ui(), container));
break;
case SETTINGS_DRIVER_CONFIG:
ui_menu::stack_push(global_alloc_clear<ui_menu_settings_driver_config>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_settings_driver_config>(ui(), container));
break;
case ANALOG:
ui_menu::stack_push(global_alloc_clear<ui_menu_analog>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_analog>(ui(), container));
break;
case BOOKKEEPING:
ui_menu::stack_push(global_alloc_clear<ui_menu_bookkeeping>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_bookkeeping>(ui(), container));
break;
case GAME_INFO:
ui_menu::stack_push(global_alloc_clear<ui_menu_game_info>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_game_info>(ui(), container));
break;
case IMAGE_MENU_IMAGE_INFO:
ui_menu::stack_push(global_alloc_clear<ui_menu_image_info>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_image_info>(ui(), container));
break;
case IMAGE_MENU_FILE_MANAGER:
ui_menu::stack_push(global_alloc_clear<ui_menu_file_manager>(machine(), container, nullptr));
ui_menu::stack_push(global_alloc_clear<ui_menu_file_manager>(ui(), container, nullptr));
break;
case TAPE_CONTROL:
ui_menu::stack_push(global_alloc_clear<ui_menu_tape_control>(machine(), container, nullptr));
ui_menu::stack_push(global_alloc_clear<ui_menu_tape_control>(ui(), container, nullptr));
break;
case PTY_INFO:
ui_menu::stack_push(global_alloc_clear<ui_menu_pty_info>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_pty_info>(ui(), container));
break;
case SLOT_DEVICES:
ui_menu::stack_push(global_alloc_clear<ui_menu_slot_devices>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_slot_devices>(ui(), container));
break;
case NETWORK_DEVICES:
ui_menu::stack_push(global_alloc_clear<ui_menu_network_devices>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_network_devices>(ui(), container));
break;
case KEYBOARD_MODE:
ui_menu::stack_push(global_alloc_clear<ui_menu_keyboard_mode>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_keyboard_mode>(ui(), container));
break;
case SLIDERS:
ui_menu::stack_push(global_alloc_clear<ui_menu_sliders>(machine(), container, false));
ui_menu::stack_push(global_alloc_clear<ui_menu_sliders>(ui(), container, false));
break;
case VIDEO_TARGETS:
ui_menu::stack_push(global_alloc_clear<ui_menu_video_targets>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_video_targets>(ui(), container));
break;
case VIDEO_OPTIONS:
ui_menu::stack_push(global_alloc_clear<ui_menu_video_options>(machine(), container, machine().render().first_target()));
ui_menu::stack_push(global_alloc_clear<ui_menu_video_options>(ui(), container, machine().render().first_target()));
break;
case CROSSHAIR:
ui_menu::stack_push(global_alloc_clear<ui_menu_crosshair>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_crosshair>(ui(), container));
break;
case CHEAT:
ui_menu::stack_push(global_alloc_clear<ui_menu_cheat>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_cheat>(ui(), container));
break;
case PLUGINS:
ui_menu::stack_push(global_alloc_clear<ui_menu_plugin>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_plugin>(ui(), container));
break;
case SELECT_GAME:
if (strcmp(machine().options().ui(),"simple")==0) {
ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(machine(), container, nullptr));
ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(ui(), container, nullptr));
} else {
ui_menu::stack_push(global_alloc_clear<ui_menu_select_game>(machine(), container, nullptr));
ui_menu::stack_push(global_alloc_clear<ui_menu_select_game>(ui(), container, nullptr));
}
break;
case BIOS_SELECTION:
ui_menu::stack_push(global_alloc_clear<ui_menu_bios_selection>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_bios_selection>(ui(), container));
break;
case BARCODE_READ:
ui_menu::stack_push(global_alloc_clear<ui_menu_barcode_reader>(machine(), container, nullptr));
ui_menu::stack_push(global_alloc_clear<ui_menu_barcode_reader>(ui(), container, nullptr));
break;
case EXTERNAL_DATS:
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(ui(), container));
break;
case ADD_FAVORITE:
@ -272,7 +273,7 @@ void ui_menu_main::handle()
case QUIT_GAME:
ui_menu::stack_pop(machine());
mame_machine_manager::instance()->ui().request_quit();
ui().request_quit();
break;
default:

View File

@ -15,7 +15,7 @@
class ui_menu_main : public ui_menu {
public:
ui_menu_main(running_machine &machine, render_container *container);
ui_menu_main(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_main();
virtual void populate() override;
virtual void handle() override;

View File

@ -11,6 +11,7 @@
#include "emu.h"
#include "rendutil.h"
#include "cheat.h"
#include "mame.h"
#include "uiinput.h"
#include "ui/ui.h"
#include "ui/menu.h"
@ -130,7 +131,7 @@ inline bool ui_menu::exclusive_input_pressed(int key, int repeat)
// init - initialize the menu system
//-------------------------------------------------
void ui_menu::init(running_machine &machine)
void ui_menu::init(running_machine &machine, ui_options &mopt)
{
// initialize the menu stack
ui_menu::stack_reset(machine);
@ -151,7 +152,7 @@ void ui_menu::init(running_machine &machine)
arrow_texture = machine.render().texture_alloc(render_triangle);
// initialize ui
init_ui(machine);
init_ui(machine, mopt);
// add an exit callback to free memory
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_menu::exit), &machine));
@ -197,7 +198,7 @@ void ui_menu::exit(running_machine &machine)
// ui_menu - menu constructor
//-------------------------------------------------
ui_menu::ui_menu(running_machine &machine, render_container *_container) : m_machine(machine)
ui_menu::ui_menu(mame_ui_manager &mui, render_container *_container) : m_ui(mui)
{
m_special_main_menu = false;
container = _container;
@ -489,16 +490,16 @@ void ui_menu::set_selection(void *selected_itemref)
void ui_menu::draw(UINT32 flags, float origx0, float origy0)
{
// first draw the FPS counter
if (mame_machine_manager::instance()->ui().show_fps_counter())
if (ui().show_fps_counter())
{
mame_machine_manager::instance()->ui().draw_text_full(container, machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr);
ui().draw_text_full(container, machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, rgb_t::white, rgb_t::black, nullptr, nullptr);
}
bool customonly = (flags & UI_MENU_PROCESS_CUSTOM_ONLY);
bool noimage = (flags & UI_MENU_PROCESS_NOIMAGE);
bool noinput = (flags & UI_MENU_PROCESS_NOINPUT);
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
float ud_arrow_width = line_height * machine().render().ui_aspect();
float gutter_width = lr_arrow_width * 1.3f;
@ -508,8 +509,8 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
bool mouse_hit, mouse_button;
float mouse_x = -1, mouse_y = -1;
if (mame_machine_manager::instance()->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));
if (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, rgb_t::white, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// compute the width and height of the full menu
float visible_width = 0;
@ -520,11 +521,11 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
float total_width;
// compute width of left hand side
total_width = gutter_width + mame_machine_manager::instance()->ui().get_string_width(pitem.text) + gutter_width;
total_width = gutter_width + ui().get_string_width(pitem.text) + gutter_width;
// add in width of right hand side
if (pitem.subtext)
total_width += 2.0f * gutter_width + mame_machine_manager::instance()->ui().get_string_width(pitem.subtext);
total_width += 2.0f * gutter_width + ui().get_string_width(pitem.subtext);
// track the maximum
if (total_width > visible_width)
@ -598,7 +599,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
float x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER;
if (!customonly)
mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
if (top_line < 0 || selected == 0)
top_line = 0;
@ -718,11 +719,11 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
{
if (pitem.flags & MENU_FLAG_UI_HEADING)
{
float heading_width = mame_machine_manager::instance()->ui().get_string_width(itemtext);
float heading_width = ui().get_string_width(itemtext);
container->add_line(visible_left, line_y + 0.5f * line_height, visible_left + ((visible_width - heading_width) / 2) - UI_BOX_LR_BORDER, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_line(visible_left + visible_width - ((visible_width - heading_width) / 2) + UI_BOX_LR_BORDER, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
mame_machine_manager::instance()->ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
}
@ -734,14 +735,14 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
float item_width, subitem_width;
// draw the left-side text
mame_machine_manager::instance()->ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, nullptr);
// give 2 spaces worth of padding
item_width += 2.0f * gutter_width;
// if the subitem doesn't fit here, display dots
if (mame_machine_manager::instance()->ui().get_string_width(subitem_text) > effective_width - item_width)
if (ui().get_string_width(subitem_text) > effective_width - item_width)
{
subitem_text = "...";
if (itemnum == selected)
@ -759,7 +760,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
fgcolor2 = rgb_t(0xff,0xff,0xff,0x00);
// draw the subitem right-justified
mame_machine_manager::instance()->ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, nullptr);
// apply arrows
@ -798,8 +799,8 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
float target_x, target_y;
// compute the multi-line target width/height
mame_machine_manager::instance()->ui().draw_text_full(container, pitem.subtext, 0, 0, visible_width * 0.75f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);
ui().draw_text_full(container, pitem.subtext, 0, 0, visible_width * 0.75f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NONE, rgb_t::white, rgb_t::black, &target_width, &target_height);
// determine the target location
target_x = visible_left + visible_width - target_width - UI_BOX_LR_BORDER;
@ -808,12 +809,12 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0)
target_y = line_y - target_height - UI_BOX_TB_BORDER;
// add a box around that
mame_machine_manager::instance()->ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER,
ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER,
target_y - UI_BOX_TB_BORDER,
target_x + target_width + UI_BOX_LR_BORDER,
target_y + target_height + UI_BOX_TB_BORDER,
subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR);
mame_machine_manager::instance()->ui().draw_text_full(container, pitem.subtext, target_x, target_y, target_width,
ui().draw_text_full(container, pitem.subtext, target_x, target_y, target_width,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr);
}
@ -835,21 +836,21 @@ void ui_menu::draw_text_box()
{
const char *text = item[0].text;
const char *backtext = item[1].text;
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
float gutter_width = lr_arrow_width;
float target_width, target_height, prior_width;
float target_x, target_y;
// compute the multi-line target width/height
mame_machine_manager::instance()->ui().draw_text_full(container, text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER - 2.0f * gutter_width,
JUSTIFY_LEFT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);
ui().draw_text_full(container, text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER - 2.0f * gutter_width,
JUSTIFY_LEFT, WRAP_WORD, DRAW_NONE, rgb_t::white, rgb_t::black, &target_width, &target_height);
target_height += 2.0f * line_height;
if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER)
target_height = floorf((1.0f - 2.0f * UI_BOX_TB_BORDER) / line_height) * line_height;
// maximum against "return to prior menu" text
prior_width = mame_machine_manager::instance()->ui().get_string_width(backtext) + 2.0f * gutter_width;
prior_width = ui().get_string_width(backtext) + 2.0f * gutter_width;
target_width = MAX(target_width, prior_width);
// determine the target location
@ -867,12 +868,12 @@ void ui_menu::draw_text_box()
target_y = 1.0f - UI_BOX_TB_BORDER - target_height;
// add a box around that
mame_machine_manager::instance()->ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER - gutter_width,
ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER - gutter_width,
target_y - UI_BOX_TB_BORDER,
target_x + target_width + gutter_width + UI_BOX_LR_BORDER,
target_y + target_height + UI_BOX_TB_BORDER,
(item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR);
mame_machine_manager::instance()->ui().draw_text_full(container, text, target_x, target_y, target_width,
ui().draw_text_full(container, text, target_x, target_y, target_width,
JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// draw the "return to prior menu" text with a hilight behind it
@ -882,7 +883,7 @@ void ui_menu::draw_text_box()
target_x + target_width - 0.5f * UI_LINE_WIDTH,
target_y + target_height,
UI_SELECTED_BG_COLOR);
mame_machine_manager::instance()->ui().draw_text_full(container, backtext, target_x, target_y + target_height - line_height, target_width,
ui().draw_text_full(container, backtext, target_x, target_y + target_height - line_height, target_width,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr);
// artificially set the hover to the last item so a double-click exits
@ -1261,21 +1262,21 @@ void ui_menu::do_handle()
// and calls the menu handler
//-------------------------------------------------
UINT32 ui_menu::ui_handler(running_machine &machine, render_container *container, UINT32 state)
UINT32 ui_menu::ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state)
{
// if we have no menus stacked up, start with the main menu
if (menu_stack == nullptr)
stack_push(global_alloc_clear<ui_menu_main>(machine, container));
stack_push(global_alloc_clear<ui_menu_main>(mui, container));
// update the menu state
if (menu_stack != nullptr)
menu_stack->do_handle();
// clear up anything pending to be released
clear_free_list(machine);
clear_free_list(mui.machine());
// if the menus are to be hidden, return a cancel here
if (mame_machine_manager::instance()->ui().is_menu_active() && ((machine.ui_input().pressed(IPT_UI_CONFIGURE) && !stack_has_special_main_menu()) || menu_stack == nullptr))
if (mui.is_menu_active() && ((mui.machine().ui_input().pressed(IPT_UI_CONFIGURE) && !stack_has_special_main_menu()) || menu_stack == nullptr))
return UI_HANDLER_CANCEL;
return 0;
@ -1363,7 +1364,7 @@ void ui_menu::draw_arrow(render_container *container, float x0, float y0, float
// init - initialize the ui menu system
//-------------------------------------------------
void ui_menu::init_ui(running_machine &machine)
void ui_menu::init_ui(running_machine &machine, ui_options &mopt)
{
render_manager &mrender = machine.render();
// create a texture for hilighting items in main menu
@ -1408,7 +1409,6 @@ 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);
ui_options &mopt = mame_machine_manager::instance()->ui().options();
if (mopt.use_background_image() && &machine.system() == &GAME_NAME(___empty))
{
emu_file backgroundfile(".", OPEN_FLAG_READ);
@ -1462,7 +1462,7 @@ void ui_menu::init_ui(running_machine &machine)
void ui_menu::draw_select_game(UINT32 flags)
{
bool noinput = (flags & UI_MENU_PROCESS_NOINPUT);
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
float ud_arrow_width = line_height * machine().render().ui_aspect();
float gutter_width = 0.52f * ud_arrow_width;
mouse_x = -1, mouse_y = -1;
@ -1472,11 +1472,10 @@ void ui_menu::draw_select_game(UINT32 flags)
float primary_width = visible_width;
bool is_swlist = ((item[0].flags & MENU_FLAG_UI_SWLIST) != 0);
bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0);
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// draw background image if available
if (mame_machine_manager::instance()->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));
if (ui().options().use_background_image() && bgrnd_bitmap->valid())
container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, rgb_t::white, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
hover = item.size() + 1;
visible_items = (is_swlist) ? item.size() - 2 : item.size() - 2 - skip_main_items;
@ -1525,7 +1524,7 @@ void ui_menu::draw_select_game(UINT32 flags)
x1 = visible_left - UI_BOX_LR_BORDER;
x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
float line = visible_top + (float)(visible_lines * line_height);
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
if (visible_items < visible_lines)
visible_lines = visible_items;
@ -1566,7 +1565,7 @@ void ui_menu::draw_select_game(UINT32 flags)
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
fgcolor3 = rgb_t(0xff, 0xcc, 0xcc, 0x00);
mui.draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
// else if the mouse is over this item, draw with a different background
@ -1580,7 +1579,7 @@ void ui_menu::draw_select_game(UINT32 flags)
{
fgcolor = fgcolor3 = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
mui.draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
@ -1625,7 +1624,7 @@ void ui_menu::draw_select_game(UINT32 flags)
space = ud_arrow_width * 1.5f;
}
mui.draw_text_full(container, itemtext, effective_left + space, line_y, effective_width - space, JUSTIFY_LEFT, WRAP_TRUNCATE,
ui().draw_text_full(container, itemtext, effective_left + space, line_y, effective_width - space, JUSTIFY_LEFT, WRAP_TRUNCATE,
DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, nullptr, nullptr);
}
else
@ -1635,16 +1634,16 @@ void ui_menu::draw_select_game(UINT32 flags)
float item_width, subitem_width;
// compute right space for subitem
mui.draw_text_full(container, subitem_text, effective_left, line_y, mame_machine_manager::instance()->ui().get_string_width(pitem.subtext),
ui().draw_text_full(container, subitem_text, effective_left, line_y, ui().get_string_width(pitem.subtext),
JUSTIFY_RIGHT, WRAP_NEVER, DRAW_NONE, item_invert ? fgcolor3 : fgcolor, bgcolor, &subitem_width, nullptr);
subitem_width += gutter_width;
// draw the item left-justified
mui.draw_text_full(container, itemtext, effective_left, line_y, effective_width - subitem_width,
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width - subitem_width,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, &item_width, nullptr);
// draw the subitem right-justified
mui.draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
JUSTIFY_RIGHT, WRAP_NEVER, DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, nullptr, nullptr);
}
}
@ -1668,7 +1667,7 @@ void ui_menu::draw_select_game(UINT32 flags)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
mui.draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
// else if the mouse is over this item, draw with a different background
@ -1683,7 +1682,7 @@ void ui_menu::draw_select_game(UINT32 flags)
container->add_line(visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height,
UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
else
mui.draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
line += line_height;
}
@ -1737,7 +1736,7 @@ void ui_menu::get_title_search(std::string &snaptext, std::string &searchstr)
else
{
ui_options moptions;
searchstr = mame_machine_manager::instance()->ui().options().value(arts_info[ui_globals::curimage_view].path);
searchstr = ui().options().value(arts_info[ui_globals::curimage_view].path);
addpath = moptions.value(arts_info[ui_globals::curimage_view].path);
}
@ -2178,12 +2177,11 @@ void ui_menu::handle_main_events(UINT32 flags)
float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
float midl = (x2 - x1) * 0.5f;
// add outlined box for options
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// add separator line
container->add_line(x1 + midl, y1, x1 + midl, y1 + line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
@ -2196,7 +2194,7 @@ float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2)
float text_size = 1.0f;
for (auto & elem : buffer)
{
float textlen = mui.get_string_width(elem.c_str()) + 0.01f;
float textlen = ui().get_string_width(elem.c_str()) + 0.01f;
float tmp_size = (textlen > midl) ? (midl / textlen) : 1.0f;
text_size = MIN(text_size, tmp_size);
}
@ -2228,14 +2226,14 @@ float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
mui.draw_textured_box(container, x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
ui().draw_textured_box(container, x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
else if (bgcolor == UI_MOUSEOVER_BG_COLOR)
container->add_rect(x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, buffer[cells].c_str(), x1 + UI_LINE_WIDTH, y1, midl - UI_LINE_WIDTH,
ui().draw_text_full(container, buffer[cells].c_str(), x1 + UI_LINE_WIDTH, y1, midl - UI_LINE_WIDTH,
JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, text_size);
x1 += midl;
}
@ -2249,8 +2247,7 @@ float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2)
std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
std::string snaptext, searchstr;
float title_size = 0.0f;
float txt_lenght = 0.0f;
@ -2261,8 +2258,8 @@ std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2
// apply title to right panel
for (int x = FIRST_VIEW; x < LAST_VIEW; x++)
{
mui.draw_text_full(container, _(arts_info[x].title), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &txt_lenght, nullptr);
ui().draw_text_full(container, _(arts_info[x].title), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_TRUNCATE, DRAW_NONE, rgb_t::white, rgb_t::black, &txt_lenght, nullptr);
txt_lenght += 0.01f;
title_size = MAX(txt_lenght, title_size);
}
@ -2277,10 +2274,10 @@ std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2
title_size *= tmp_size;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
ui().draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, tmp_size);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::curimage_view, FIRST_VIEW, LAST_VIEW, title_size);
@ -2294,9 +2291,9 @@ std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2
void ui_menu::draw_star(float x0, float y0)
{
float y1 = y0 + mame_machine_manager::instance()->ui().get_line_height();
float x1 = x0 + mame_machine_manager::instance()->ui().get_line_height() * container->manager().ui_aspect();
container->add_quad(x0, y0, x1, y1, ARGB_WHITE, star_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_PACKABLE);
float y1 = y0 + ui().get_line_height();
float x1 = x0 + ui().get_line_height() * container->manager().ui_aspect();
container->add_quad(x0, y0, x1, y1, rgb_t::white, star_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_PACKABLE);
}
//-------------------------------------------------
@ -2305,9 +2302,8 @@ void ui_menu::draw_star(float x0, float y0)
void ui_menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -2340,9 +2336,9 @@ void ui_menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software
if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y)
{
hover = HOVER_B_FAV + z;
color = ARGB_WHITE;
float ypos = y2 + mame_machine_manager::instance()->ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
mui.draw_text_box(container, _(hover_msg[z]), JUSTIFY_CENTER, 0.5f, ypos, UI_BACKGROUND_COLOR);
color = rgb_t::white;
float ypos = y2 + ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
ui().draw_text_box(container, _(hover_msg[z]), JUSTIFY_CENTER, 0.5f, ypos, UI_BACKGROUND_COLOR);
}
container->add_quad(x1, y1, x2, y2, color, t_texture[z], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
@ -2360,7 +2356,7 @@ void ui_menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software
void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float origy1, float origx2, float origy2, bool software)
{
bool no_available = false;
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
// if it fails, use the default image
if (!tmp_bitmap->valid())
@ -2393,7 +2389,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 (mame_machine_manager::instance()->ui().options().forced_4x3_snapshot() && ratioI < 0.75f && ui_globals::curimage_view == SNAPSHOT_VIEW)
if (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;
@ -2403,7 +2399,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 || (mame_machine_manager::instance()->ui().options().enlarge_snaps() && !no_available))
else if (ratioW < 1 || ratioH < 1 || (ui().options().enlarge_snaps() && !no_available))
{
// smaller ratio will ensure that the image fits in the view
float ratio = MIN(ratioW, ratioH);
@ -2447,7 +2443,7 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float
void ui_menu::draw_common_arrow(float origx1, float origy1, float origx2, float origy2, int current, int dmin, int dmax, float title_size)
{
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
float gutter_width = lr_arrow_width * 1.3f;
@ -2468,14 +2464,14 @@ void ui_menu::draw_common_arrow(float origx1, float origy1, float origx2, float
// set hover
if (mouse_hit && ar_x0 <= mouse_x && ar_x1 > mouse_x && ar_y0 <= mouse_y && ar_y1 > mouse_y && current != dmax)
{
mame_machine_manager::instance()->ui().draw_textured_box(container, ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
hover = HOVER_UI_RIGHT;
fgcolor_right = UI_MOUSEOVER_COLOR;
}
else if (mouse_hit && al_x0 <= mouse_x && al_x1 > mouse_x && al_y0 <= mouse_y && al_y1 > mouse_y && current != dmin)
{
mame_machine_manager::instance()->ui().draw_textured_box(container, al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
hover = HOVER_UI_LEFT;
fgcolor_left = UI_MOUSEOVER_COLOR;
@ -2500,8 +2496,8 @@ void ui_menu::draw_common_arrow(float origx1, float origy1, float origx2, float
void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0)
{
static const game_driver *olddriver[MAX_ICONS_RENDER] = { nullptr };
float x1 = x0 + mame_machine_manager::instance()->ui().get_line_height() * container->manager().ui_aspect(container);
float y1 = y0 + mame_machine_manager::instance()->ui().get_line_height();
float x1 = x0 + ui().get_line_height() * container->manager().ui_aspect(container);
float y1 = y0 + ui().get_line_height();
const game_driver *driver = (const game_driver *)selectedref;
if (olddriver[linenum] != driver || ui_globals::redraw_icon)
@ -2518,9 +2514,9 @@ void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0)
}
// get search path
path_iterator path(mame_machine_manager::instance()->ui().options().icons_directory());
path_iterator path(ui().options().icons_directory());
std::string curpath;
std::string searchstr(mame_machine_manager::instance()->ui().options().icons_directory());
std::string searchstr(ui().options().icons_directory());
// iterate over path and add path for zipped formats
while (path.next(curpath))
@ -2595,7 +2591,7 @@ void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0)
}
if (icons_bitmap[linenum] != nullptr && icons_bitmap[linenum]->valid())
container->add_quad(x0, y0, x1, y1, ARGB_WHITE, icons_texture[linenum], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_quad(x0, y0, x1, y1, rgb_t::white, icons_texture[linenum], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
//-------------------------------------------------
@ -2609,7 +2605,7 @@ void ui_menu::info_arrow(int ub, float origx1, float origx2, float oy1, float li
if (mouse_hit && origx1 <= mouse_x && origx2 > mouse_x && oy1 <= mouse_y && oy1 + (line_height * text_size) > mouse_y)
{
mame_machine_manager::instance()->ui().draw_textured_box(container, origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), UI_MOUSEOVER_BG_COLOR,
ui().draw_textured_box(container, origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), UI_MOUSEOVER_BG_COLOR,
rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
hover = (!ub) ? HOVER_DAT_UP : HOVER_DAT_DOWN;
fgcolor = UI_MOUSEOVER_COLOR;
@ -2625,15 +2621,14 @@ void ui_menu::info_arrow(int ub, float origx1, float origx2, float oy1, float li
void ui_menu::draw_palette_menu()
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
float ud_arrow_width = line_height * machine().render().ui_aspect();
float gutter_width = lr_arrow_width * 1.3f;
int itemnum, linenum;
if (mame_machine_manager::instance()->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));
if (ui().options().use_background_image() && machine().options().system() == nullptr && bgrnd_bitmap->valid())
container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, rgb_t::white, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// compute the width and height of the full menu
float visible_width = 0;
@ -2643,11 +2638,11 @@ void ui_menu::draw_palette_menu()
const ui_menu_item &pitem = item[itemnum];
// compute width of left hand side
float total_width = gutter_width + mui.get_string_width(pitem.text) + gutter_width;
float total_width = gutter_width + ui().get_string_width(pitem.text) + gutter_width;
// add in width of right hand side
if (pitem.subtext)
total_width += 2.0f * gutter_width + mui.get_string_width(pitem.subtext);
total_width += 2.0f * gutter_width + ui().get_string_width(pitem.subtext);
// track the maximum
if (total_width > visible_width)
@ -2687,7 +2682,7 @@ void ui_menu::draw_palette_menu()
float y1 = visible_top - UI_BOX_TB_BORDER;
float x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER;
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// determine the first visible line based on the current selection
int top_line = selected - visible_lines / 2;
@ -2780,7 +2775,7 @@ void ui_menu::draw_palette_menu()
// if we don't have a subitem, just draw the string centered
else if (pitem.subtext == nullptr)
mui.draw_text_full(container, itemtext, effective_left, line_y, effective_width,
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
// otherwise, draw the item on the left and the subitem text on the right
@ -2790,13 +2785,13 @@ void ui_menu::draw_palette_menu()
rgb_t color = rgb_t((UINT32)strtoul(subitem_text, nullptr, 16));
// draw the left-side text
mui.draw_text_full(container, itemtext, effective_left, line_y, effective_width,
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
// give 2 spaces worth of padding
float subitem_width = mui.get_string_width("FF00FF00");
float subitem_width = ui().get_string_width("FF00FF00");
mui.draw_outlined_box(container, effective_left + effective_width - subitem_width, line_y0,
ui().draw_outlined_box(container, effective_left + effective_width - subitem_width, line_y0,
effective_left + effective_width, line_y1, color);
}
}
@ -2814,17 +2809,16 @@ void ui_menu::draw_palette_menu()
void ui_menu::draw_dats_menu()
{
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
float ud_arrow_width = line_height * machine().render().ui_aspect();
float gutter_width = 0.52f * line_height * machine().render().ui_aspect();
mouse_x = -1, mouse_y = -1;
float visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER;
float visible_left = (1.0f - visible_width) * 0.5f;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
// draw background image if available
if (mame_machine_manager::instance()->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));
if (ui().options().use_background_image() && bgrnd_bitmap->valid())
container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, rgb_t::white, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
hover = item.size() + 1;
visible_items = item.size() - 2;
@ -2857,7 +2851,7 @@ void ui_menu::draw_dats_menu()
float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height;
float line = visible_top + (float)(visible_lines * line_height);
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
if (visible_items < visible_lines)
visible_lines = visible_items;
@ -2917,7 +2911,7 @@ void ui_menu::draw_dats_menu()
// draw dats text
else if (pitem.subtext == nullptr)
{
mui.draw_text_full(container, itemtext, effective_left, line_y, effective_width, JUSTIFY_LEFT, WRAP_NEVER,
ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width, JUSTIFY_LEFT, WRAP_NEVER,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
}
}
@ -2942,7 +2936,7 @@ void ui_menu::draw_dats_menu()
else
{
highlight(container, line_x0, line_y0, line_x1, line_y1, bgcolor);
mui.draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
}
line += line_height;
@ -2960,3 +2954,65 @@ void ui_menu::set_pressed()
(m_repeat == 0) ? m_repeat = osd_ticks() + osd_ticks_per_second() / 2 : m_repeat = osd_ticks() + osd_ticks_per_second() / 4;
m_pressed = true;
}
//-------------------------------------------------
// extra_text_draw_box - generically adds header
// or footer text
//-------------------------------------------------
void ui_menu::extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction)
{
float text_width, text_height;
float width, maxwidth;
float x1, y1, x2, y2, temp;
// get the size of the text
ui().draw_text_full(container,text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD,
DRAW_NONE, rgb_t::white, rgb_t::black, &text_width, &text_height);
width = text_width + (2 * UI_BOX_LR_BORDER);
maxwidth = MAX(width, origx2 - origx1);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
x2 = x1 + maxwidth;
y1 = origy + (yspan * direction);
y2 = origy + (UI_BOX_TB_BORDER * direction);
if (y1 > y2)
{
temp = y1;
y1 = y2;
y2 = temp;
}
// draw a box
ui().draw_outlined_box(container,x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
y1 += UI_BOX_TB_BORDER;
// draw the text within it
ui().draw_text_full(container,text, x1, y1, text_width, JUSTIFY_LEFT, WRAP_WORD,
DRAW_NORMAL, rgb_t::white, rgb_t::black, nullptr, nullptr);
}
//-------------------------------------------------
// extra_text_render - generically adds header
// and footer text
//-------------------------------------------------
void ui_menu::extra_text_render(float top, float bottom,
float origx1, float origy1, float origx2, float origy2,
const char *header, const char *footer)
{
header = ((header != nullptr) && (header[0] != '\0')) ? header : nullptr;
footer = ((footer != nullptr) && (footer[0] != '\0')) ? footer : nullptr;
if (header != nullptr)
extra_text_draw_box(origx1, origx2, origy1, top, header, -1);
if (footer != nullptr)
extra_text_draw_box(origx1, origx2, origy2, bottom, footer, +1);
}

View File

@ -15,7 +15,7 @@
#include "render.h"
#include "language.h"
#include "ui/uimain.h"
#include "ui/ui.h"
/***************************************************************************
@ -77,10 +77,11 @@ struct ui_menu_pool
class ui_menu
{
public:
ui_menu(running_machine &machine, render_container *container);
ui_menu(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu();
running_machine &machine() const { return m_machine; }
mame_ui_manager &ui() const { return m_ui; }
running_machine &machine() const { return m_ui.machine(); }
render_container *container; // render_container we render to
ui_menu_event menu_event; // the UI menu_event that occurred
@ -126,7 +127,7 @@ public:
void set_special_main_menu(bool disable);
// Global initialization
static void init(running_machine &machine);
static void init(running_machine &machine, ui_options &mopt);
static void exit(running_machine &machine);
// reset the menus, clearing everything
@ -148,7 +149,7 @@ public:
static void draw_arrow(render_container *container, float x0, float y0, float x1, float y1, rgb_t fgcolor, UINT32 orientation);
// master handler
static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state);
static UINT32 ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state);
// Used by sliders
void validate_selection(int scandir);
@ -171,7 +172,7 @@ private:
static render_texture *hilight_texture, *arrow_texture;
bool m_special_main_menu;
running_machine &m_machine; // machine we are attached to
mame_ui_manager &m_ui; // UI we are attached to
void draw(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f);
void draw_text_box();
@ -217,7 +218,7 @@ public:
void draw_star(float x0, float y0);
// Global initialization
static void init_ui(running_machine &machine);
static void init_ui(running_machine &machine, ui_options &mopt);
// get arrows status
template <typename _T1, typename _T2, typename _T3>
@ -248,6 +249,9 @@ protected:
std::string arts_render_common(float origx1, float origy1, float origx2, float origy2);
void arts_render_images(bitmap_argb32 *bitmap, float origx1, float origy1, float origx2, float origy2, bool software);
// draw header and footer text
void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer);
int visible_lines; // main box visible lines
int right_visible_lines; // right box lines
@ -292,6 +296,7 @@ private:
void handle_main_events(UINT32 flags);
void draw_icon(int linenum, void *selectedref, float x1, float y1);
void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction);
};
#endif // __UI_MENU_H__

View File

@ -12,6 +12,7 @@
#include "mame.h"
#include "osdnet.h"
#include "mameopts.h"
#include "pluginopts.h"
#include "drivenum.h"
#include "uiinput.h"
@ -30,13 +31,13 @@
ui_menu_keyboard_mode - menu that
-------------------------------------------------*/
ui_menu_keyboard_mode::ui_menu_keyboard_mode(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_keyboard_mode::ui_menu_keyboard_mode(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
void ui_menu_keyboard_mode::populate()
{
bool natural = mame_machine_manager::instance()->ui().use_natural_keyboard();
bool natural = ui().use_natural_keyboard();
item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, nullptr);
}
@ -46,7 +47,7 @@ ui_menu_keyboard_mode::~ui_menu_keyboard_mode()
void ui_menu_keyboard_mode::handle()
{
bool natural = mame_machine_manager::instance()->ui().use_natural_keyboard();
bool natural = ui().use_natural_keyboard();
/* process the menu */
const ui_menu_event *menu_event = process(0);
@ -55,7 +56,7 @@ void ui_menu_keyboard_mode::handle()
{
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{
mame_machine_manager::instance()->ui().set_use_natural_keyboard(natural ^ true);
ui().set_use_natural_keyboard(natural ^ true);
reset(UI_MENU_RESET_REMEMBER_REF);
}
}
@ -67,7 +68,7 @@ void ui_menu_keyboard_mode::handle()
bios selection menu
-------------------------------------------------*/
ui_menu_bios_selection::ui_menu_bios_selection(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_bios_selection::ui_menu_bios_selection(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -140,7 +141,7 @@ void ui_menu_bios_selection::handle()
ui_menu_network_devices::ui_menu_network_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_network_devices::ui_menu_network_devices(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -223,7 +224,7 @@ void ui_menu_bookkeeping::handle()
menu_bookkeeping - handle the bookkeeping
information menu
-------------------------------------------------*/
ui_menu_bookkeeping::ui_menu_bookkeeping(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_bookkeeping::ui_menu_bookkeeping(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -372,7 +373,7 @@ void ui_menu_crosshair::handle()
crosshair settings menu
-------------------------------------------------*/
ui_menu_crosshair::ui_menu_crosshair(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_crosshair::ui_menu_crosshair(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -534,7 +535,7 @@ ui_menu_crosshair::~ui_menu_crosshair()
quitting the game
-------------------------------------------------*/
ui_menu_quit_game::ui_menu_quit_game(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_quit_game::ui_menu_quit_game(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -559,8 +560,8 @@ void ui_menu_quit_game::handle()
// ctor / dtor
//-------------------------------------------------
ui_menu_export::ui_menu_export(running_machine &machine, render_container *container, std::vector<const game_driver *> drvlist)
: ui_menu(machine, container), m_list(drvlist)
ui_menu_export::ui_menu_export(mame_ui_manager &mui, render_container *container, std::vector<const game_driver *> drvlist)
: ui_menu(mui, container), m_list(drvlist)
{
}
@ -587,7 +588,7 @@ void ui_menu_export::handle()
if (m_event->iptkey == IPT_UI_SELECT)
{
std::string filename("exported");
emu_file infile(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_READ);
emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ);
if (infile.open(filename.c_str(), ".xml") == osd_file::error::NONE)
for (int seq = 0; ; ++seq)
{
@ -600,7 +601,7 @@ void ui_menu_export::handle()
}
// attempt to open the output file
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(filename.c_str(), ".xml") == osd_file::error::NONE)
{
FILE *pfile;
@ -627,7 +628,7 @@ void ui_menu_export::handle()
if (m_event->iptkey == IPT_UI_SELECT)
{
std::string filename("exported");
emu_file infile(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_READ);
emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ);
if (infile.open(filename.c_str(), ".txt") == osd_file::error::NONE)
for (int seq = 0; ; ++seq)
{
@ -640,7 +641,7 @@ void ui_menu_export::handle()
}
// attempt to open the output file
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(filename.c_str(), ".txt") == osd_file::error::NONE)
{
// print the header
@ -685,10 +686,10 @@ void ui_menu_export::populate()
// ctor / dtor
//-------------------------------------------------
ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev, float _x0, float _y0)
: ui_menu(machine, container)
ui_menu_machine_configure::ui_menu_machine_configure(mame_ui_manager &mui, render_container *container, const game_driver *prev, float _x0, float _y0)
: ui_menu(mui, container)
, m_drv(prev)
, m_opts(machine.options())
, m_opts(mui.machine().options())
, x0(_x0)
, y0(_y0)
, m_curbios(0)
@ -727,7 +728,7 @@ void ui_menu_machine_configure::handle()
{
std::string inistring = m_opts.output_ini();
file.puts(inistring.c_str());
mame_machine_manager::instance()->ui().popup_time(2, "%s", _("\n Configuration saved \n\n"));
ui().popup_time(2, "%s", _("\n Configuration saved \n\n"));
}
break;
}
@ -742,15 +743,15 @@ void ui_menu_machine_configure::handle()
break;
case CONTROLLER:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, control_submenu_options, m_drv, &m_opts));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, control_submenu_options, m_drv, &m_opts));
break;
case VIDEO:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, video_submenu_options, m_drv, &m_opts));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, video_submenu_options, m_drv, &m_opts));
break;
case ADVANCED:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, advanced_submenu_options, m_drv, &m_opts));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, advanced_submenu_options, m_drv, &m_opts));
break;
default:
break;
@ -797,7 +798,7 @@ void ui_menu_machine_configure::populate()
item_append(ui_menu_item_type::SEPARATOR);
item_append(_("Save machine configuration"), nullptr, 0, (void *)(FPTR)SAVE);
item_append(ui_menu_item_type::SEPARATOR);
customtop = 2.0f * mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -807,7 +808,6 @@ void ui_menu_machine_configure::populate()
void ui_menu_machine_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
std::string text[2];
float maxwidth = origx2 - origx1;
@ -816,8 +816,8 @@ void ui_menu_machine_configure::custom_render(void *selectedref, float top, floa
for (auto & elem : text)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
}
@ -830,7 +830,7 @@ void ui_menu_machine_configure::custom_render(void *selectedref, float top, floa
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -840,9 +840,9 @@ void ui_menu_machine_configure::custom_render(void *selectedref, float top, floa
// draw the text within it
for (auto & elem : text)
{
mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
y1 += mui.get_line_height();
y1 += ui().get_line_height();
}
}
@ -889,8 +889,8 @@ void ui_menu_machine_configure::setup_bios()
// ctor / dtor
//-------------------------------------------------
ui_menu_plugins_configure::ui_menu_plugins_configure(running_machine &machine, render_container *container)
: ui_menu(machine, container)
ui_menu_plugins_configure::ui_menu_plugins_configure(mame_ui_manager &mui, render_container *container)
: ui_menu(mui, container)
{
}
@ -946,7 +946,7 @@ void ui_menu_plugins_configure::populate()
}
}
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}
//-------------------------------------------------
@ -956,10 +956,9 @@ void ui_menu_plugins_configure::populate()
void ui_menu_plugins_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _("Plugins"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Plugins"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -970,7 +969,7 @@ void ui_menu_plugins_configure::custom_render(void *selectedref, float top, floa
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -978,6 +977,6 @@ void ui_menu_plugins_configure::custom_render(void *selectedref, float top, floa
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Plugins"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Plugins"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}

View File

@ -20,7 +20,7 @@ using s_bios = std::vector<std::pair<std::string, int>>;
class ui_menu_keyboard_mode : public ui_menu {
public:
ui_menu_keyboard_mode(running_machine &machine, render_container *container);
ui_menu_keyboard_mode(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_keyboard_mode();
virtual void populate() override;
virtual void handle() override;
@ -28,7 +28,7 @@ public:
class ui_menu_network_devices : public ui_menu {
public:
ui_menu_network_devices(running_machine &machine, render_container *container);
ui_menu_network_devices(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_network_devices();
virtual void populate() override;
virtual void handle() override;
@ -36,7 +36,7 @@ public:
class ui_menu_bookkeeping : public ui_menu {
public:
ui_menu_bookkeeping(running_machine &machine, render_container *container);
ui_menu_bookkeeping(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_bookkeeping();
virtual void populate() override;
virtual void handle() override;
@ -47,7 +47,7 @@ private:
class ui_menu_crosshair : public ui_menu {
public:
ui_menu_crosshair(running_machine &machine, render_container *container);
ui_menu_crosshair(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_crosshair();
virtual void populate() override;
virtual void handle() override;
@ -73,7 +73,7 @@ private:
class ui_menu_quit_game : public ui_menu {
public:
ui_menu_quit_game(running_machine &machine, render_container *container);
ui_menu_quit_game(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_quit_game();
virtual void populate() override;
virtual void handle() override;
@ -81,7 +81,7 @@ public:
class ui_menu_bios_selection : public ui_menu {
public:
ui_menu_bios_selection(running_machine &machine, render_container *container);
ui_menu_bios_selection(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_bios_selection();
virtual void populate() override;
virtual void handle() override;
@ -95,7 +95,7 @@ public:
class ui_menu_export : public ui_menu
{
public:
ui_menu_export(running_machine &machine, render_container *container, std::vector<const game_driver*> list);
ui_menu_export(mame_ui_manager &mui, render_container *container, std::vector<const game_driver*> list);
virtual ~ui_menu_export();
virtual void populate() override;
virtual void handle() override;
@ -111,7 +111,7 @@ private:
class ui_menu_machine_configure : public ui_menu
{
public:
ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev, float x0 = 0.0f, float y0 = 0.0f);
ui_menu_machine_configure(mame_ui_manager &mui, render_container *container, const game_driver *prev, float x0 = 0.0f, float y0 = 0.0f);
virtual ~ui_menu_machine_configure();
virtual void populate() override;
virtual void handle() override;
@ -144,7 +144,7 @@ private:
class ui_menu_plugins_configure : public ui_menu
{
public:
ui_menu_plugins_configure(running_machine &machine, render_container *container);
ui_menu_plugins_configure(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_plugins_configure();
virtual void populate() override;
virtual void handle() override;

View File

@ -9,6 +9,7 @@
*********************************************************************/
#include "emu.h"
#include "mame.h"
#include "mameopts.h"
#include "ui/ui.h"
#include "ui/menu.h"
@ -27,7 +28,7 @@
// ctor
//-------------------------------------------------
ui_menu_game_options::ui_menu_game_options(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_game_options::ui_menu_game_options(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
m_main = main_filters::actual;
}
@ -41,7 +42,7 @@ ui_menu_game_options::~ui_menu_game_options()
main_filters::actual = m_main;
if (ui_menu::menu_stack != nullptr)
ui_menu::menu_stack->reset(UI_MENU_RESET_SELECT_FIRST);
save_ui_options(machine());
ui().save_ui_options();
ui_globals::switch_image = true;
}
@ -82,7 +83,7 @@ void ui_menu_game_options::handle()
for (int index = 0; index < total; ++index)
s_sel[index] = main_filters::text[index];
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, m_main));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, m_main));
}
break;
}
@ -107,7 +108,7 @@ void ui_menu_game_options::handle()
for (size_t index = 0; index < total; ++index)
s_sel[index] = ifile.get_file(index);
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ifile.cur_file(), SELECTOR_INIFILE));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, ifile.cur_file(), SELECTOR_INIFILE));
}
break;
}
@ -131,7 +132,7 @@ void ui_menu_game_options::handle()
for (int index = 0; index < total; ++index)
s_sel[index] = ifile.get_category(index);
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ifile.cur_cat(), SELECTOR_CATEGORY));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, ifile.cur_cat(), SELECTOR_CATEGORY));
}
break;
}
@ -142,7 +143,7 @@ void ui_menu_game_options::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, c_mnfct::ui, c_mnfct::actual));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, c_mnfct::ui, c_mnfct::actual));
break;
case YEAR_CAT_FILTER:
@ -152,60 +153,60 @@ void ui_menu_game_options::handle()
changed = true;
}
else if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, c_year::ui, c_year::actual));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, c_year::ui, c_year::actual));
break;
case CONF_DIR:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_directory>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_directory>(ui(), container));
break;
case MISC_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
{
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, misc_submenu_options));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, misc_submenu_options));
ui_globals::reset = true;
}
break;
case SOUND_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
{
ui_menu::stack_push(global_alloc_clear<ui_menu_sound_options>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_sound_options>(ui(), container));
ui_globals::reset = true;
}
break;
case DISPLAY_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
{
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, video_submenu_options));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, video_submenu_options));
ui_globals::reset = true;
}
break;
case CUSTOM_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_custom_ui>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_custom_ui>(ui(), container));
break;
case CONTROLLER_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, control_submenu_options));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, control_submenu_options));
break;
case CGI_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_input_groups>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_input_groups>(ui(), container));
break;
case CUSTOM_FILTER:
if (m_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_custom_filter>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_custom_filter>(ui(), container));
break;
case ADVANCED_MENU:
if (m_event->iptkey == IPT_UI_SELECT)
{
ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, advanced_submenu_options));
ui_menu::stack_push(global_alloc_clear<ui_submenu>(ui(), container, advanced_submenu_options));
ui_globals::reset = true;
}
break;
case SAVE_CONFIG:
if (m_event->iptkey == IPT_UI_SELECT)
save_main_option(machine());
ui().save_main_option();
break;
}
@ -282,8 +283,8 @@ void ui_menu_game_options::populate()
item_append(ui_menu_item_type::SEPARATOR);
item_append(_("Save Configuration"), nullptr, 0, (void *)(FPTR)SAVE_CONFIG);
custombottom = 2.0f * mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
//-------------------------------------------------
@ -293,9 +294,8 @@ void ui_menu_game_options::populate()
void ui_menu_game_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _("Settings"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Settings"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -306,7 +306,7 @@ void ui_menu_game_options::custom_render(void *selectedref, float top, float bot
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -314,76 +314,6 @@ void ui_menu_game_options::custom_render(void *selectedref, float top, float bot
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Settings"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Settings"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
//-------------------------------------------------
// save ui options
//-------------------------------------------------
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("ui.ini") == osd_file::error::NONE)
{
// generate the updated INI
std::string initext = mame_machine_manager::instance()->ui().options().output_ini();
file.puts(initext.c_str());
file.close();
}
else
machine.popmessage(_("**Error saving ui.ini**"));
}
//-------------------------------------------------
// save main option
//-------------------------------------------------
void save_main_option(running_machine &machine)
{
// 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") == osd_file::error::NONE)
{
bool result = options.parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
if (!result)
{
osd_printf_error("**Error loading %s.ini**", emulator_info::get_configname());
return;
}
}
}
for (emu_options::entry &f_entry : machine.options())
{
if (f_entry.is_changed())
{
options.set_value(f_entry.name(), f_entry.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") == osd_file::error::NONE)
{
// generate the updated INI
std::string initext = options.output_ini();
file.puts(initext.c_str());
file.close();
}
else {
machine.popmessage(_("**Error saving %s.ini**"), emulator_info::get_configname());
return;
}
}
mame_machine_manager::instance()->ui().popup_time(3, "%s", _("\n Configuration saved \n\n"));
}

View File

@ -16,7 +16,7 @@
class ui_menu_game_options : public ui_menu
{
public:
ui_menu_game_options(running_machine &machine, render_container *container);
ui_menu_game_options(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_game_options();
virtual void populate() override;
virtual void handle() override;
@ -46,8 +46,4 @@ private:
};
};
// save options to file
void save_ui_options(running_machine &machine);
void save_main_option(running_machine &machine);
#endif /* __UI_OPTSMENU_H__ */

View File

@ -21,12 +21,12 @@ void ui_menu_plugin::handle()
if (menu_event != nullptr && menu_event->itemref != nullptr)
{
if (menu_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_plugin_opt>(machine(), container, (char *)menu_event->itemref));
ui_menu::stack_push(global_alloc_clear<ui_menu_plugin_opt>(ui(), container, (char *)menu_event->itemref));
}
}
ui_menu_plugin::ui_menu_plugin(running_machine &machine, render_container *container) :
ui_menu(machine, container),
ui_menu_plugin::ui_menu_plugin(mame_ui_manager &mui, render_container *container) :
ui_menu(mui, container),
m_plugins(mame_machine_manager::instance()->lua()->get_menu())
{
}
@ -42,8 +42,8 @@ ui_menu_plugin::~ui_menu_plugin()
{
}
ui_menu_plugin_opt::ui_menu_plugin_opt(running_machine &machine, render_container *container, char *menu) :
ui_menu(machine, container),
ui_menu_plugin_opt::ui_menu_plugin_opt(mame_ui_manager &mui, render_container *container, char *menu) :
ui_menu(mui, container),
m_menu(menu)
{
}

View File

@ -18,7 +18,7 @@
class ui_menu_plugin : public ui_menu {
public:
ui_menu_plugin(running_machine &machine, render_container *container);
ui_menu_plugin(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_plugin();
virtual void populate() override;
virtual void handle() override;
@ -28,7 +28,7 @@ private:
class ui_menu_plugin_opt : public ui_menu {
public:
ui_menu_plugin_opt(running_machine &machine, render_container *container, char *menu);
ui_menu_plugin_opt(mame_ui_manager &mui, render_container *container, char *menu);
virtual ~ui_menu_plugin_opt();
virtual void populate() override;
virtual void handle() override;

View File

@ -9,6 +9,7 @@
*********************************************************************/
#include "emu.h"
#include "mame.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "ui/selector.h"
@ -18,8 +19,8 @@
// ctor / dtor
//-------------------------------------------------
ui_menu_selector::ui_menu_selector(running_machine &machine, render_container *container, std::vector<std::string> const &s_sel, UINT16 &s_actual, int category, int _hover)
: ui_menu(machine, container)
ui_menu_selector::ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> const &s_sel, UINT16 &s_actual, int category, int _hover)
: ui_menu(mui, container)
, m_selector(s_actual)
, m_category(category)
, m_hover(_hover)
@ -30,8 +31,8 @@ ui_menu_selector::ui_menu_selector(running_machine &machine, render_container *c
m_searchlist[0] = nullptr;
}
ui_menu_selector::ui_menu_selector(running_machine &machine, render_container *container, std::vector<std::string> &&s_sel, UINT16 &s_actual, int category, int _hover)
: ui_menu(machine, container)
ui_menu_selector::ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> &&s_sel, UINT16 &s_actual, int category, int _hover)
: ui_menu(mui, container)
, m_selector(s_actual)
, m_category(category)
, m_hover(_hover)
@ -150,7 +151,7 @@ void ui_menu_selector::populate()
}
item_append(ui_menu_item_type::SEPARATOR);
customtop = custombottom = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
m_first_pass = false;
}
@ -161,12 +162,11 @@ void ui_menu_selector::populate()
void ui_menu_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
std::string tempbuf = std::string(_("Selection List - Search: ")).append(m_search).append("_");
// get the size of the text
mui.draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
float maxwidth = MAX(width, origx2 - origx1);
@ -177,7 +177,7 @@ void ui_menu_selector::custom_render(void *selectedref, float top, float bottom,
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -185,7 +185,7 @@ void ui_menu_selector::custom_render(void *selectedref, float top, float bottom,
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_TRUNCATE,
ui().draw_text_full(container, tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// bottom text
@ -193,8 +193,8 @@ void ui_menu_selector::custom_render(void *selectedref, float top, float bottom,
std::string ui_select_text = machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD));
tempbuf = string_format(_("Double click or press %1$s to select"), ui_select_text);
mui.draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
@ -205,7 +205,7 @@ void ui_menu_selector::custom_render(void *selectedref, float top, float bottom,
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -213,7 +213,7 @@ void ui_menu_selector::custom_render(void *selectedref, float top, float bottom,
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,
ui().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);
}

View File

@ -28,8 +28,8 @@ enum
class ui_menu_selector : public ui_menu
{
public:
ui_menu_selector(running_machine &machine, render_container *container, std::vector<std::string> const &_sel, UINT16 &_actual, int _category = 0, int _hover = 0);
ui_menu_selector(running_machine &machine, render_container *container, std::vector<std::string> &&_sel, UINT16 &_actual, int _category = 0, int _hover = 0);
ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> const &_sel, UINT16 &_actual, int _category = 0, int _hover = 0);
ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> &&_sel, UINT16 &_actual, int _category = 0, int _hover = 0);
virtual ~ui_menu_selector();
virtual void populate() override;
virtual void handle() override;

View File

@ -50,12 +50,12 @@ int ui_menu_select_game::m_isabios = 0;
// ctor
//-------------------------------------------------
ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container)
ui_menu_select_game::ui_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : ui_menu(mui, container)
{
m_focus = focused_menu::main;
highlight = 0;
std::string error_string, last_filter, sub_filter;
ui_options &moptions = mame_machine_manager::instance()->ui().options();
ui_options &moptions = mui.options();
// load drivers cache
init_sorted_list();
@ -122,8 +122,8 @@ ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_contai
if (!moptions.remember_last())
reselect_last::reset();
machine.options().set_value(OPTION_SNAPNAME, "%g/%i", OPTION_PRIORITY_CMDLINE, error_string);
machine.options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string);
mui.machine().options().set_value(OPTION_SNAPNAME, "%g/%i", OPTION_PRIORITY_CMDLINE, error_string);
mui.machine().options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string);
ui_globals::curimage_view = FIRST_VIEW;
ui_globals::curdats_view = UI_FIRST_LOAD;
@ -142,7 +142,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;
ui_options &mopt = mame_machine_manager::instance()->ui().options();
ui_options &mopt = ui().options();
if (isfavorite())
swinfo = (selected >= 0 && selected < item.size()) ? (ui_software_info *)item[selected].ref : nullptr;
else
@ -163,7 +163,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_ui_options(machine());
ui().save_ui_options();
}
//-------------------------------------------------
@ -176,7 +176,7 @@ void ui_menu_select_game::handle()
m_prev_selected = item[0].ref;
bool check_filter = false;
bool enabled_dats = mame_machine_manager::instance()->ui().options().enabled_dats();
bool enabled_dats = ui().options().enabled_dats();
// if i have to load datfile, performe an hard reset
if (ui_globals::reset)
@ -191,7 +191,7 @@ void ui_menu_select_game::handle()
if (reselect_last::get())
{
const game_driver *driver = (const game_driver *)item[selected].ref;
ui_menu::stack_push(global_alloc_clear<ui_menu_select_software>(machine(), container, driver));
ui_menu::stack_push(global_alloc_clear<ui_menu_select_software>(ui(), container, driver));
return;
}
@ -231,7 +231,7 @@ void ui_menu_select_game::handle()
else if (m_event->iptkey == IPT_CUSTOM)
{
if (!isfavorite())
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, (const game_driver *)m_prev_selected, m_event->mouse.x0, m_event->mouse.y0));
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(ui(), container, (const game_driver *)m_prev_selected, m_event->mouse.x0, m_event->mouse.y0));
}
// handle UI_LEFT
@ -348,7 +348,7 @@ void ui_menu_select_game::handle()
{
const game_driver *driver = (const game_driver *)m_event->itemref;
if ((FPTR)driver > skip_main_items && mame_machine_manager::instance()->datfile().has_data(driver))
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, driver));
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(ui(), container, driver));
}
else
{
@ -358,9 +358,9 @@ void ui_menu_select_game::handle()
if ((FPTR)ui_swinfo > skip_main_items)
{
if (ui_swinfo->startempty == 1 && mdat.has_history(ui_swinfo->driver))
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo->driver));
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(ui(), container, ui_swinfo->driver));
else if (mdat.has_software(ui_swinfo->listname, ui_swinfo->shortname, ui_swinfo->parentname) || !ui_swinfo->usage.empty())
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo));
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(ui(), container, ui_swinfo));
}
}
}
@ -373,15 +373,16 @@ void ui_menu_select_game::handle()
const game_driver *driver = (const game_driver *)m_event->itemref;
if ((FPTR)driver > skip_main_items)
{
if (!mame_machine_manager::instance()->favorite().isgame_favorite(driver))
favorite_manager &mfav = mame_machine_manager::instance()->favorite();
if (!mfav.isgame_favorite(driver))
{
mame_machine_manager::instance()->favorite().add_favorite_game(driver);
mfav.add_favorite_game(driver);
machine().popmessage(_("%s\n added to favorites list."), driver->description);
}
else
{
mame_machine_manager::instance()->favorite().remove_favorite_game();
mfav.remove_favorite_game();
machine().popmessage(_("%s\n removed from favorites list."), driver->description);
}
}
@ -404,11 +405,11 @@ void ui_menu_select_game::handle()
// handle UI_AUDIT_FAST
else if (m_event->iptkey == IPT_UI_AUDIT_FAST && !m_unavailsortedlist.empty())
ui_menu::stack_push(global_alloc_clear<ui_menu_audit>(machine(), container, m_availsortedlist, m_unavailsortedlist, 1));
ui_menu::stack_push(global_alloc_clear<ui_menu_audit>(ui(), container, m_availsortedlist, m_unavailsortedlist, 1));
// handle UI_AUDIT_ALL
else if (m_event->iptkey == IPT_UI_AUDIT_ALL)
ui_menu::stack_push(global_alloc_clear<ui_menu_audit>(machine(), container, m_availsortedlist, m_unavailsortedlist, 2));
ui_menu::stack_push(global_alloc_clear<ui_menu_audit>(ui(), container, m_availsortedlist, m_unavailsortedlist, 2));
// typed characters append to the buffer
else if (m_event->iptkey == IPT_SPECIAL)
@ -453,7 +454,7 @@ void ui_menu_select_game::handle()
// if we're in an error state, overlay an error message
if (ui_error)
mame_machine_manager::instance()->ui().draw_text_box(container, _("The selected machine is missing one or more required ROM or CHD images. "
ui().draw_text_box(container, _("The selected machine is missing one or more required ROM or CHD images. "
"Please select a different machine.\n\nPress any key to continue."), JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
// handle filters selection from key shortcuts
@ -463,17 +464,17 @@ void ui_menu_select_game::handle()
if (l_hover == FILTER_CATEGORY)
{
main_filters::actual = l_hover;
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(ui(), container));
}
else if (l_hover == FILTER_CUSTOM)
{
main_filters::actual = l_hover;
ui_menu::stack_push(global_alloc_clear<ui_menu_custom_filter>(machine(), container, true));
ui_menu::stack_push(global_alloc_clear<ui_menu_custom_filter>(ui(), container, true));
}
else if (l_hover == FILTER_MANUFACTURER)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, c_mnfct::ui, c_mnfct::actual, SELECTOR_GAME, l_hover));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, c_mnfct::ui, c_mnfct::actual, SELECTOR_GAME, l_hover));
else if (l_hover == FILTER_YEAR)
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, c_year::ui, c_year::actual, SELECTOR_GAME, l_hover));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, c_year::ui, c_year::actual, SELECTOR_GAME, l_hover));
else
{
if (l_hover >= FILTER_ALL)
@ -604,8 +605,8 @@ void ui_menu_select_game::populate()
skip_main_items = 0;
// configure the custom rendering
customtop = 3.0f * mame_machine_manager::instance()->ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER;
custombottom = 5.0f * mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = 3.0f * ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER;
custombottom = 5.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
// reselect prior game launched, if any
if (old_item_selected != -1)
@ -750,8 +751,8 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
std::string tempbuf[5];
rgb_t color = UI_BACKGROUND_COLOR;
bool isstar = false;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float tbarspace = mui.get_line_height();
inifile_manager &inifile = mame_machine_manager::instance()->inifile();
float tbarspace = ui().get_line_height();
float text_size = 1.0f;
tempbuf[0] = string_format(_("%1$s %2$s ( %3$d / %4$d machines (%5$d BIOS) )"),
@ -762,12 +763,12 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
m_isabios);
std::string filtered;
if (main_filters::actual == FILTER_CATEGORY && mame_machine_manager::instance()->inifile().total() > 0)
if (main_filters::actual == FILTER_CATEGORY && inifile.total() > 0)
{
filtered = string_format(_("%1$s (%2$s - %3$s) - "),
main_filters::text[main_filters::actual],
mame_machine_manager::instance()->inifile().get_file(),
mame_machine_manager::instance()->inifile().get_category());
inifile.get_file(),
inifile.get_category());
}
else if (main_filters::actual == FILTER_MANUFACTURER)
{
@ -791,8 +792,8 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
// get the size of the text
for (int line = 0; line < 2; ++line)
{
mui.draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(width, maxwidth);
}
@ -810,7 +811,7 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
float y2 = origy1 - 3.0f * UI_BOX_TB_BORDER - tbarspace;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -820,9 +821,9 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
// draw the text within it
for (int line = 0; line < 2; ++line)
{
mui.draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
y1 += mui.get_line_height();
y1 += ui().get_line_height();
}
// determine the text to render below
@ -945,8 +946,8 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
}
@ -964,7 +965,7 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, color);
ui().draw_outlined_box(container, x1, y1, x2, y2, color);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -978,9 +979,9 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
// draw all lines
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
y1 += mui.get_line_height();
y1 += ui().get_line_height();
}
}
@ -989,22 +990,22 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott
// and inescapable
//-------------------------------------------------
void ui_menu_select_game::force_game_select(running_machine &machine, render_container *container)
void ui_menu_select_game::force_game_select(mame_ui_manager &mui, render_container *container)
{
// reset the menu stack
ui_menu::stack_reset(machine);
ui_menu::stack_reset(mui.machine());
// add the quit entry followed by the game select entry
ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(machine, container);
ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(mui, container);
quit->set_special_main_menu(true);
ui_menu::stack_push(quit);
ui_menu::stack_push(global_alloc_clear<ui_menu_select_game>(machine, container, nullptr));
ui_menu::stack_push(global_alloc_clear<ui_menu_select_game>(mui, container, nullptr));
// force the menus on
mame_machine_manager::instance()->ui().show_menu();
mui.show_menu();
// make sure MAME is paused
machine.pause();
mui.machine().pause();
}
//-------------------------------------------------
@ -1017,13 +1018,13 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
// special case for configure options
if ((FPTR)driver == CONF_OPTS)
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(ui(), container));
// special case for configure machine
else if ((FPTR)driver == CONF_MACHINE)
{
if (m_prev_selected != nullptr)
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, (const game_driver *)m_prev_selected));
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(ui(), container, (const game_driver *)m_prev_selected));
else
return;
}
@ -1031,7 +1032,7 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
// special case for configure plugins
else if ((FPTR)driver == CONF_PLUGINS)
{
ui_menu::stack_push(global_alloc_clear<ui_menu_plugins_configure>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_plugins_configure>(ui(), container));
}
// anything else is a driver
else
@ -1050,14 +1051,14 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
for (software_list_device &swlistdev : software_list_device_iterator(enumerator.config().root_device()))
if (!swlistdev.get_info().empty())
{
ui_menu::stack_push(global_alloc_clear<ui_menu_select_software>(machine(), container, driver));
ui_menu::stack_push(global_alloc_clear<ui_menu_select_software>(ui(), container, driver));
return;
}
}
s_bios biosname;
if (!mame_machine_manager::instance()->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));
if (!ui().options().skip_bios_menu() && has_multiple_bios(driver, biosname))
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(ui(), container, biosname, (void *)driver, false, false));
else
{
reselect_last::driver = driver->name;
@ -1084,11 +1085,11 @@ 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;
ui_options &mopt = mame_machine_manager::instance()->ui().options();
ui_options &mopt = ui().options();
// special case for configure options
if ((FPTR)ui_swinfo == CONF_OPTS)
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(ui(), container));
/* special case for configure machine TODO
else if ((FPTR)ui_swinfo == CONF_MACHINE)
{
@ -1096,7 +1097,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
{
ui_software_info *swinfo = (ui_software_info *)m_prev_selected;
if (swinfo->startempty == 1)
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, swinfo->driver));
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(ui(), container, swinfo->driver));
}
else
return;
@ -1104,7 +1105,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
// special case for configure plugins
else if ((FPTR)ui_swinfo == CONF_PLUGINS)
{
ui_menu::stack_push(global_alloc_clear<ui_menu_plugins_configure>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_plugins_configure>(ui(), container));
}
else if (ui_swinfo->startempty == 1)
{
@ -1119,7 +1120,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
{
s_bios biosname;
if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname))
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo->driver, false, false));
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(ui(), container, biosname, (void *)ui_swinfo->driver, false, false));
else
{
reselect_last::driver = ui_swinfo->driver->name;
@ -1153,7 +1154,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
s_bios biosname;
if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname))
{
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo, true, false));
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(ui(), container, biosname, (void *)ui_swinfo, true, false));
return;
}
else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str()))
@ -1169,7 +1170,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
parts.emplace(swpart.name(), menu_part_name);
}
}
ui_menu::stack_push(global_alloc_clear<ui_software_parts>(machine(), container, parts, ui_swinfo));
ui_menu::stack_push(global_alloc_clear<ui_software_parts>(ui(), container, parts, ui_swinfo));
return;
}
@ -1589,7 +1590,7 @@ void ui_menu_select_game::general_info(const game_driver *driver, std::string &b
util::stream_format(str, _("Requires CHD: %1$s\n"), found ? _("Yes") : _("No"));
// audit the game first to see if we're going to work
if (mame_machine_manager::instance()->ui().options().info_audit())
if (ui().options().info_audit())
{
driver_enumerator enumerator(machine().options(), *driver);
enumerator.next();
@ -1630,7 +1631,7 @@ void ui_menu_select_game::inkey_export()
{
list = m_displaylist;
}
ui_menu::stack_push(global_alloc_clear<ui_menu_export>(machine(), container, list));
ui_menu::stack_push(global_alloc_clear<ui_menu_export>(ui(), container, list));
}
//-------------------------------------------------
@ -1669,7 +1670,7 @@ void ui_menu_select_game::init_sorted_list()
bool ui_menu_select_game::load_available_machines()
{
// try to load available drivers from file
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_READ);
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
if (file.open(emulator_info::get_configname(), "_avail.ini") != osd_file::error::NONE)
return false;
@ -1721,7 +1722,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(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_READ);
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == osd_file::error::NONE)
{
char buffer[MAX_CHAR_INFO];
@ -1780,14 +1781,13 @@ void ui_menu_select_game::load_custom_filters()
float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
if (ui_globals::panels_status == SHOW_PANELS || ui_globals::panels_status == HIDE_RIGHT_PANEL)
{
float origy1 = y1;
float origy2 = y2;
float text_size = mame_machine_manager::instance()->ui().options().infos_size();
float text_size = ui().options().infos_size();
float line_height_max = line_height * text_size;
float left_width = 0.0f;
int text_lenght = main_filters::length;
@ -1803,13 +1803,13 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
line_height_max = line_height * text_size;
}
float text_sign = mui.get_string_width("_# ", text_size);
float text_sign = ui().get_string_width("_# ", text_size);
for (int x = 0; x < text_lenght; ++x)
{
float total_width;
// compute width of left hand side
total_width = mui.get_string_width(text[x], text_size);
total_width = ui().get_string_width(text[x], text_size);
total_width += text_sign;
// track the maximum
@ -1818,7 +1818,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
}
x2 = x1 + left_width + 2.0f * UI_BOX_LR_BORDER;
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -1844,7 +1844,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
mui.draw_textured_box(container, x1, y1, x2, y1 + line_height_max, bgcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, x1, y1, x2, y1 + line_height_max, bgcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
@ -1878,7 +1878,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
convert_command_glyph(str);
}
mui.draw_text_full(container, str.c_str(), x1t, y1, x2 - x1, JUSTIFY_LEFT, WRAP_NEVER,
ui().draw_text_full(container, str.c_str(), x1t, y1, x2 - x1, JUSTIFY_LEFT, WRAP_NEVER,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, text_size);
y1 += line_height_max;
}
@ -1897,7 +1897,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
float ar_x1 = ar_x0 + lr_arrow_width;
float ar_y1 = 0.5f * (y2 + y1) + 0.9f * space;
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y)
{
@ -1920,7 +1920,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
float ar_x1 = ar_x0 + lr_arrow_width;
float ar_y1 = 0.5f * (y2 + y1) + 0.9f * space;
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y)
{
@ -1939,12 +1939,11 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y
void ui_menu_select_game::infos_render(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
static std::string buffer;
std::vector<int> xstart;
std::vector<int> xend;
float text_size = mame_machine_manager::instance()->ui().options().infos_size();
float text_size = 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);
@ -1988,7 +1987,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
for (int x = UI_FIRST_LOAD; x < UI_LAST_LOAD; ++x)
{
mui.draw_text_full(container, _(dats_info[x]), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
ui().draw_text_full(container, _(dats_info[x]), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_NEVER, DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_length, nullptr);
txt_length += 0.01f;
title_size = (std::max)(txt_length, title_size);
@ -2010,10 +2009,10 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
title_size *= tmp_size;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
ui().draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
ui().draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_NEVER, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, tmp_size);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::curdats_view, UI_FIRST_LOAD, UI_LAST_LOAD, title_size);
@ -2050,14 +2049,14 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
if (buffer.empty())
{
mui.draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
ui().draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
return;
}
else if (ui_globals::curdats_view != UI_STORY_LOAD && ui_globals::curdats_view != UI_COMMAND_LOAD)
totallines = mui.wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
totallines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
else
totallines = mui.wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (2.0f * gutter_width), xstart, xend, text_size);
totallines = ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (2.0f * gutter_width), xstart, xend, text_size);
int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size));
if (totallines < r_visible_lines)
@ -2083,13 +2082,13 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
else if (ui_globals::curdats_view == UI_STORY_LOAD)
{
// check size
float textlen = mui.get_string_width(tempbuf.c_str(), text_size);
float textlen = ui().get_string_width(tempbuf.c_str(), text_size);
float tmp_size2 = (textlen > sc) ? text_size * (sc / textlen) : text_size;
size_t last_underscore = tempbuf.find_last_of("_");
if (last_underscore == std::string::npos)
{
mui.draw_text_full(container, tempbuf.c_str(), origx1, oy1, origx2 - origx1, JUSTIFY_CENTER,
ui().draw_text_full(container, tempbuf.c_str(), origx1, oy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size2);
}
else
@ -2100,10 +2099,10 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
std::string first_part(tempbuf.substr(0, tempbuf.find("___")));
float item_width;
mui.draw_text_full(container, first_part.c_str(), effective_left, oy1, effective_width,
ui().draw_text_full(container, first_part.c_str(), effective_left, oy1, effective_width,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &item_width, nullptr, tmp_size2);
mui.draw_text_full(container, last_part.c_str(), effective_left + item_width, oy1,
ui().draw_text_full(container, last_part.c_str(), effective_left + item_width, oy1,
origx2 - origx1 - 2.0f * gutter_width - item_width, JUSTIFY_RIGHT, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size2);
}
@ -2113,7 +2112,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
else if (ui_globals::curdats_view == UI_COMMAND_LOAD || ui_globals::curdats_view == UI_GENERAL_LOAD)
{
// check size
float textlen = mui.get_string_width(tempbuf.c_str(), text_size);
float textlen = ui().get_string_width(tempbuf.c_str(), text_size);
float tmp_size3 = (textlen > sc) ? text_size * (sc / textlen) : text_size;
int first_dspace = (ui_globals::curdats_view == UI_COMMAND_LOAD) ? tempbuf.find(" ") : tempbuf.find(":");
@ -2124,18 +2123,18 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
std::string first_part(tempbuf.substr(0, first_dspace));
std::string last_part(tempbuf.substr(first_dspace + 1));
strtrimspace(last_part);
mui.draw_text_full(container, first_part.c_str(), effective_left, oy1, effective_width, JUSTIFY_LEFT,
ui().draw_text_full(container, first_part.c_str(), effective_left, oy1, effective_width, JUSTIFY_LEFT,
WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3);
mui.draw_text_full(container, last_part.c_str(), effective_left, oy1, origx2 - origx1 - 2.0f * gutter_width,
ui().draw_text_full(container, last_part.c_str(), effective_left, oy1, origx2 - origx1 - 2.0f * gutter_width,
JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3);
}
else
mui.draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, JUSTIFY_LEFT,
ui().draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, JUSTIFY_LEFT,
WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3);
}
else
mui.draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, JUSTIFY_LEFT,
ui().draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, JUSTIFY_LEFT,
WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
oy1 += (line_height * text_size);
@ -2153,7 +2152,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
// apply title to right panel
if (soft->usage.empty())
{
mui.draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
ui_globals::cur_sw_dats_view = 0;
}
@ -2167,7 +2166,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
for (auto & elem: t_text)
{
mui.draw_text_full(container, elem.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, elem.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_length, nullptr);
txt_length += 0.01f;
title_size = (std::max)(txt_length, title_size);
@ -2184,10 +2183,10 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
ui().draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
ui().draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::cur_sw_dats_view, 0, 1, title_size);
@ -2211,12 +2210,12 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
if (buffer.empty())
{
mui.draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
ui().draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
return;
}
else
totallines = mui.wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
totallines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size));
if (totallines < r_visible_lines)
@ -2238,7 +2237,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
else if (r == r_visible_lines - 1 && itemline != totallines - 1)
info_arrow(1, origx1, origx2, oy1, line_height, text_size, ud_arrow_width);
else
mui.draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, JUSTIFY_LEFT,
ui().draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, JUSTIFY_LEFT,
WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
oy1 += (line_height * text_size);
}
@ -2254,7 +2253,6 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
void ui_menu_select_game::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
rgb_t fgcolor = UI_TEXT_COLOR;
bool hide = (ui_globals::panels_status == HIDE_RIGHT_PANEL || ui_globals::panels_status == HIDE_BOTH);
float x2 = (hide) ? origx2 : origx1 + 2.0f * UI_BOX_LR_BORDER;
@ -2267,7 +2265,7 @@ void ui_menu_select_game::draw_right_panel(void *selectedref, float origx1, floa
float ar_x1 = ar_x0 + lr_arrow_width;
float ar_y1 = 0.5f * (origy2 + origy1) + 0.9f * space;
mui.draw_outlined_box(container, origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
if (mouse_hit && origx1 <= mouse_x && x2 > mouse_x && origy1 <= mouse_y && origy2 > mouse_y)
{
@ -2297,8 +2295,7 @@ void ui_menu_select_game::draw_right_panel(void *selectedref, float origx1, floa
void ui_menu_select_game::arts_render(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0);
static ui_software_info *oldsoft = nullptr;
static const game_driver *olddriver = nullptr;
@ -2398,7 +2395,7 @@ void ui_menu_select_game::arts_render(void *selectedref, float origx1, float ori
float y2 = origy2 - UI_BOX_TB_BORDER - line_height;
// apply texture
container->add_quad( x1, y1, x2, y2, ARGB_WHITE, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_quad( x1, y1, x2, y2, rgb_t::white, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
else if (soft != nullptr)
@ -2487,7 +2484,7 @@ void ui_menu_select_game::arts_render(void *selectedref, float origx1, float ori
float y2 = origy2 - UI_BOX_TB_BORDER - line_height;
// apply texture
container->add_quad(x1, y1, x2, y2, ARGB_WHITE, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_quad(x1, y1, x2, y2, rgb_t::white, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
}

View File

@ -18,14 +18,14 @@
class ui_menu_select_game : public ui_menu
{
public:
ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename);
ui_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename);
virtual ~ui_menu_select_game();
virtual void populate() override;
virtual void handle() override;
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
// force game select menu
static void force_game_select(running_machine &machine, render_container *container);
static void force_game_select(mame_ui_manager &mui, render_container *container);
virtual bool menu_has_search_active() override { return (m_search[0] != 0); }

View File

@ -121,7 +121,7 @@ bool has_multiple_bios(const game_driver *driver, s_bios &biosname)
// ctor
//-------------------------------------------------
ui_menu_select_software::ui_menu_select_software(running_machine &machine, render_container *container, const game_driver *driver) : ui_menu(machine, container)
ui_menu_select_software::ui_menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver) : ui_menu(mui, container)
{
if (reselect_last::get())
reselect_last::set(false);
@ -138,7 +138,7 @@ ui_menu_select_software::ui_menu_select_software(running_machine &machine, rende
ui_globals::cur_sw_dats_view = UI_FIRST_LOAD;
std::string error_string;
machine.options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string);
mui.machine().options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string);
}
//-------------------------------------------------
@ -243,15 +243,15 @@ void ui_menu_select_software::handle()
}
// handle UI_DATS
else if (m_event->iptkey == IPT_UI_DATS && mame_machine_manager::instance()->ui().options().enabled_dats())
else if (m_event->iptkey == IPT_UI_DATS && ui().options().enabled_dats())
{
ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
datfile_manager &mdat = mame_machine_manager::instance()->datfile();
if (ui_swinfo->startempty == 1 && mdat.has_history(ui_swinfo->driver))
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo->driver));
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(ui(), container, ui_swinfo->driver));
else if (mdat.has_software(ui_swinfo->listname, ui_swinfo->shortname, ui_swinfo->parentname) || !ui_swinfo->usage.empty())
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo));
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(ui(), container, ui_swinfo));
}
// handle UI_LEFT_PANEL
@ -276,16 +276,17 @@ void ui_menu_select_software::handle()
if ((FPTR)swinfo > 2)
{
if (!mame_machine_manager::instance()->favorite().isgame_favorite(*swinfo))
favorite_manager &mfav = mame_machine_manager::instance()->favorite();
if (!mfav.isgame_favorite(*swinfo))
{
mame_machine_manager::instance()->favorite().add_favorite_game(*swinfo);
mfav.add_favorite_game(*swinfo);
machine().popmessage(_("%s\n added to favorites list."), swinfo->longname.c_str());
}
else
{
machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str());
mame_machine_manager::instance()->favorite().remove_favorite_game();
mfav.remove_favorite_game();
}
}
}
@ -378,7 +379,7 @@ void ui_menu_select_software::handle()
// if we're in an error state, overlay an error message
if (ui_error)
mame_machine_manager::instance()->ui().draw_text_box(container, _("The selected software is missing one or more required files. "
ui().draw_text_box(container, _("The selected software is missing one or more required files. "
"Please select a different software.\n\nPress any key to continue."),
JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
@ -389,28 +390,28 @@ void ui_menu_select_software::handle()
switch (l_sw_hover)
{
case UI_SW_REGION:
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.region.ui,
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.region.ui,
m_filter.region.actual, SELECTOR_SOFTWARE, l_sw_hover));
break;
case UI_SW_YEARS:
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.year.ui,
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.year.ui,
m_filter.year.actual, SELECTOR_SOFTWARE, l_sw_hover));
break;
case UI_SW_LIST:
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.swlist.description,
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.swlist.description,
m_filter.swlist.actual, SELECTOR_SOFTWARE, l_sw_hover));
break;
case UI_SW_TYPE:
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.type.ui,
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.type.ui,
m_filter.type.actual, SELECTOR_SOFTWARE, l_sw_hover));
break;
case UI_SW_PUBLISHERS:
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, m_filter.publisher.ui,
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, m_filter.publisher.ui,
m_filter.publisher.actual, SELECTOR_SOFTWARE, l_sw_hover));
break;
case UI_SW_CUSTOM:
sw_filters::actual = l_sw_hover;
ui_menu::stack_push(global_alloc_clear<ui_menu_swcustom_filter>(machine(), container, m_driver, m_filter));
ui_menu::stack_push(global_alloc_clear<ui_menu_swcustom_filter>(ui(), container, m_driver, m_filter));
break;
default:
sw_filters::actual = l_sw_hover;
@ -506,8 +507,8 @@ void ui_menu_select_software::populate()
item_append(MENU_SEPARATOR_ITEM, nullptr, flags_ui, nullptr);
// configure the custom rendering
customtop = 4.0f * mame_machine_manager::instance()->ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER;
custombottom = 5.0f * mame_machine_manager::instance()->ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
customtop = 4.0f * ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER;
custombottom = 5.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
if (old_software != -1)
{
@ -668,12 +669,11 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
{
ui_software_info *swinfo = (selectedref != nullptr) ? (ui_software_info *)selectedref : ((m_prev_selected != nullptr) ? (ui_software_info *)m_prev_selected : nullptr);
const game_driver *driver = nullptr;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float width;
std::string tempbuf[5], filtered;
rgb_t color = UI_BACKGROUND_COLOR;
bool isstar = false;
float tbarspace = mui.get_line_height();
float tbarspace = ui().get_line_height();
float text_size = 1.0f;
// determine the text for the header
@ -699,8 +699,8 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
for (int line = 0; line < 3; ++line)
{
mui.draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(width, maxwidth);
}
@ -718,7 +718,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
float y2 = origy1 - 3.0f * UI_BOX_TB_BORDER - tbarspace;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -728,9 +728,9 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
// draw the text within it
for (int line = 0; line < 3; ++line)
{
mui.draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
y1 += mui.get_line_height();
y1 += ui().get_line_height();
}
// determine the text to render below
@ -850,8 +850,8 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
}
@ -869,7 +869,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, color);
ui().draw_outlined_box(container, x1, y1, x2, y2, color);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -883,9 +883,9 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
// draw all lines
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
y1 += mame_machine_manager::instance()->ui().get_line_height();
y1 += ui().get_line_height();
}
}
@ -896,13 +896,13 @@ 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;
ui_options &mopt = mame_machine_manager::instance()->ui().options();
ui_options &mopt = ui().options();
if (ui_swinfo->startempty == 1)
{
s_bios biosname;
if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname))
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo->driver, false, true));
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(ui(), container, biosname, (void *)ui_swinfo->driver, false, true));
else
{
reselect_last::driver = ui_swinfo->driver->name;
@ -931,7 +931,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
s_bios biosname;
if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname))
{
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo, true, false));
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(ui(), container, biosname, (void *)ui_swinfo, true, false));
return;
}
else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str()))
@ -947,7 +947,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
parts.emplace(swpart.name(), menu_part_name);
}
}
ui_menu::stack_push(global_alloc_clear<ui_software_parts>(machine(), container, parts, ui_swinfo));
ui_menu::stack_push(global_alloc_clear<ui_software_parts>(ui(), container, parts, ui_swinfo));
return;
}
std::string error_string;
@ -1060,7 +1060,7 @@ void ui_menu_select_software::inkey_configure(const ui_menu_event *m_event)
void ui_menu_select_software::load_sw_custom_filters()
{
// attempt to open the output file
emu_file file(mame_machine_manager::instance()->ui().options().ui_path(), OPEN_FLAG_READ);
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
if (file.open("custom_", m_driver->name, "_filter.ini") == osd_file::error::NONE)
{
char buffer[MAX_CHAR_INFO];
@ -1390,14 +1390,12 @@ void ui_menu_select_software::build_custom()
float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, float y2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
if (ui_globals::panels_status == SHOW_PANELS || ui_globals::panels_status == HIDE_RIGHT_PANEL)
{
float origy1 = y1;
float origy2 = y2;
float text_size = 0.75f;
float l_height = mui.get_line_height();
float l_height = ui().get_line_height();
float line_height = l_height * text_size;
float left_width = 0.0f;
int text_lenght = sw_filters::length;
@ -1413,13 +1411,13 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
line_height = l_height * text_size;
}
float text_sign = mui.get_string_width("_# ", text_size);
float text_sign = ui().get_string_width("_# ", text_size);
for (int x = 0; x < text_lenght; ++x)
{
float total_width;
// compute width of left hand side
total_width = mui.get_string_width(text[x], text_size);
total_width = ui().get_string_width(text[x], text_size);
total_width += text_sign;
// track the maximum
@ -1428,7 +1426,7 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
}
x2 = x1 + left_width + 2.0f * UI_BOX_LR_BORDER;
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -1456,7 +1454,7 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
}
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, x1, y1, x2, y1 + line_height, bgcolor, rgb_t(255, 43, 43, 43),
ui().draw_textured_box(container, x1, y1, x2, y1 + line_height, bgcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
float x1t = x1 + text_sign;
@ -1489,7 +1487,7 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
convert_command_glyph(str);
}
mui.draw_text_full(container, str.c_str(), x1t, y1, x2 - x1, JUSTIFY_LEFT, WRAP_NEVER,
ui().draw_text_full(container, str.c_str(), x1t, y1, x2 - x1, JUSTIFY_LEFT, WRAP_NEVER,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, text_size);
y1 += line_height;
}
@ -1508,7 +1506,7 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
float ar_x1 = ar_x0 + lr_arrow_width;
float ar_y1 = 0.5f * (y2 + y1) + 0.9f * space;
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y)
{
@ -1531,7 +1529,7 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
float ar_x1 = ar_x0 + lr_arrow_width;
float ar_y1 = 0.5f * (y2 + y1) + 0.9f * space;
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y)
{
@ -1550,12 +1548,11 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
void ui_menu_select_software::infos_render(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
static std::string buffer;
std::vector<int> xstart;
std::vector<int> xend;
float text_size = mame_machine_manager::instance()->ui().options().infos_size();
float text_size = ui().options().infos_size();
ui_software_info *soft = (selectedref != nullptr) ? (ui_software_info *)selectedref : ((m_prev_selected != nullptr) ? (ui_software_info *)m_prev_selected : nullptr);
static ui_software_info *oldsoft = nullptr;
static int old_sw_view = -1;
@ -1569,7 +1566,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
{
float title_size = 0.0f;
mui.draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &title_size, nullptr);
title_size += 0.01f;
@ -1584,10 +1581,10 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
ui().draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
ui_globals::cur_sw_dats_view = 0;
}
@ -1601,7 +1598,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
for (auto & elem : t_text)
{
mui.draw_text_full(container, elem.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, elem.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_lenght, nullptr);
txt_lenght += 0.01f;
title_size = MAX(txt_lenght, title_size);
@ -1623,10 +1620,10 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
title_size *= tmp_size;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
ui().draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
ui().draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, tmp_size);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::cur_sw_dats_view, 0, 1, title_size);
@ -1650,12 +1647,12 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
if (buffer.empty())
{
mui.draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
ui().draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
return;
}
else
totallines = mui.wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
totallines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size));
if (totallines < r_visible_lines)
@ -1678,7 +1675,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
else if (r == r_visible_lines - 1 && itemline != totallines - 1)
info_arrow(1, origx1, origx2, oy1, line_height, text_size, ud_arrow_width);
else
mui.draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1,
ui().draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr, text_size);
oy1 += (line_height * text_size);
@ -1694,8 +1691,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
void ui_menu_select_software::arts_render(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
float line_height = mui.get_line_height();
float line_height = ui().get_line_height();
static ui_software_info *oldsoft = nullptr;
static const game_driver *olddriver = nullptr;
const game_driver *driver = nullptr;
@ -1785,7 +1781,7 @@ void ui_menu_select_software::arts_render(void *selectedref, float origx1, float
float y2 = origy2 - UI_BOX_TB_BORDER - line_height;
// apply texture
container->add_quad( x1, y1, x2, y2, ARGB_WHITE, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_quad( x1, y1, x2, y2, rgb_t::white, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
else if (soft != nullptr)
@ -1873,14 +1869,13 @@ void ui_menu_select_software::arts_render(void *selectedref, float origx1, float
float y2 = origy2 - UI_BOX_TB_BORDER - line_height;
// apply texture
container->add_quad(x1, y1, x2, y2, ARGB_WHITE, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_quad(x1, y1, x2, y2, rgb_t::white, snapx_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
}
void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
rgb_t fgcolor = UI_TEXT_COLOR;
bool hide = (ui_globals::panels_status == HIDE_RIGHT_PANEL || ui_globals::panels_status == HIDE_BOTH);
float x2 = (hide) ? origx2 : origx1 + 2.0f * UI_BOX_LR_BORDER;
@ -1893,7 +1888,7 @@ void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1,
float ar_x1 = ar_x0 + lr_arrow_width;
float ar_y1 = 0.5f * (origy2 + origy1) + 0.9f * space;
mui.draw_outlined_box(container, origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
ui().draw_outlined_box(container, origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
if (mouse_hit && origx1 <= mouse_x && x2 > mouse_x && origy1 <= mouse_y && origy2 > mouse_y)
{
@ -1921,7 +1916,7 @@ void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1,
// ctor
//-------------------------------------------------
ui_software_parts::ui_software_parts(running_machine &machine, render_container *container, s_parts parts, ui_software_info *ui_info) : ui_menu(machine, container)
ui_software_parts::ui_software_parts(mame_ui_manager &mui, render_container *container, s_parts parts, ui_software_info *ui_info) : ui_menu(mui, container)
{
m_parts = parts;
m_uiinfo = ui_info;
@ -1945,7 +1940,7 @@ void ui_software_parts::populate()
item_append(elem.first.c_str(), elem.second.c_str(), 0, (void *)&elem);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}
//-------------------------------------------------
@ -1985,9 +1980,8 @@ void ui_software_parts::handle()
void ui_software_parts::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _("Software part selection:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Software part selection:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -1998,7 +1992,7 @@ void ui_software_parts::custom_render(void *selectedref, float top, float bottom
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -2006,7 +2000,7 @@ void ui_software_parts::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Software part selection:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Software part selection:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
@ -2014,7 +2008,7 @@ void ui_software_parts::custom_render(void *selectedref, float top, float bottom
// ctor
//-------------------------------------------------
ui_bios_selection::ui_bios_selection(running_machine &machine, render_container *container, s_bios biosname, void *_driver, bool _software, bool _inlist) : ui_menu(machine, container)
ui_bios_selection::ui_bios_selection(mame_ui_manager &mui, render_container *container, s_bios biosname, void *_driver, bool _software, bool _inlist) : ui_menu(mui, container)
{
m_bios = biosname;
m_driver = _driver;
@ -2040,7 +2034,7 @@ void ui_bios_selection::populate()
item_append(elem.first.c_str(), nullptr, 0, (void *)&elem.first);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}
//-------------------------------------------------
@ -2084,7 +2078,7 @@ void ui_bios_selection::handle()
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());
if (!mame_machine_manager::instance()->ui().options().skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str()))
if (!ui().options().skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str()))
{
s_parts parts;
for (const software_part &swpart : swinfo->parts())
@ -2097,7 +2091,7 @@ void ui_bios_selection::handle()
parts.emplace(swpart.name(), menu_part_name);
}
}
ui_menu::stack_push(global_alloc_clear<ui_software_parts>(machine(), container, parts, ui_swinfo));
ui_menu::stack_push(global_alloc_clear<ui_software_parts>(ui(), container, parts, ui_swinfo));
return;
}
std::string error_string;
@ -2123,9 +2117,8 @@ void ui_bios_selection::handle()
void ui_bios_selection::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _("Bios selection:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Bios selection:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -2136,7 +2129,7 @@ void ui_bios_selection::custom_render(void *selectedref, float top, float bottom
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -2144,6 +2137,6 @@ void ui_bios_selection::custom_render(void *selectedref, float top, float bottom
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Bios selection:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Bios selection:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}

View File

@ -21,7 +21,7 @@ using s_parts = std::unordered_map<std::string, std::string>;
class ui_menu_select_software : public ui_menu
{
public:
ui_menu_select_software(running_machine &machine, render_container *container, const game_driver *driver);
ui_menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver);
virtual ~ui_menu_select_software();
virtual void populate() override;
virtual void handle() override;
@ -65,7 +65,7 @@ private:
class ui_software_parts : public ui_menu
{
public:
ui_software_parts(running_machine &machine, render_container *container, s_parts parts, ui_software_info *ui_info);
ui_software_parts(mame_ui_manager &mui, render_container *container, s_parts parts, ui_software_info *ui_info);
virtual ~ui_software_parts();
virtual void populate() override;
virtual void handle() override;
@ -79,7 +79,7 @@ private:
class ui_bios_selection : public ui_menu
{
public:
ui_bios_selection(running_machine &machine, render_container *container, s_bios biosname, void *driver, bool software, bool inlist);
ui_bios_selection(mame_ui_manager &mui, render_container *container, s_bios biosname, void *driver, bool software, bool inlist);
virtual ~ui_bios_selection();
virtual void populate() override;
virtual void handle() override;

View File

@ -26,7 +26,7 @@
// ctor
//-------------------------------------------------
ui_simple_menu_select_game::ui_simple_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container), m_driverlist(driver_list::total() + 1)
ui_simple_menu_select_game::ui_simple_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : ui_menu(mui, container), m_driverlist(driver_list::total() + 1)
{
build_driver_list();
if(gamename)
@ -129,7 +129,7 @@ void ui_simple_menu_select_game::handle()
// if we're in an error state, overlay an error message
if (m_error)
mame_machine_manager::instance()->ui().draw_text_box(container,
ui().draw_text_box(container,
"The selected game is missing one or more required ROM or CHD images. "
"Please select a different game.\n\nPress any key to continue.",
JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
@ -146,7 +146,7 @@ void ui_simple_menu_select_game::inkey_select(const ui_menu_event *menu_event)
// special case for configure inputs
if ((FPTR)driver == 1)
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(ui(), container));
// anything else is a driver
else
{
@ -268,8 +268,8 @@ void ui_simple_menu_select_game::populate()
}
// configure the custom rendering
customtop = mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = 4.0f * mame_machine_manager::instance()->ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
custombottom = 4.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
@ -293,8 +293,8 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
tempbuf[0] = _("Type name or select: (random)");
// get the size of the text
mame_machine_manager::instance()->ui().draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(width, origx2 - origx1);
@ -305,7 +305,7 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -313,7 +313,7 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mame_machine_manager::instance()->ui().draw_text_full(container, tempbuf[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, tempbuf[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// determine the text to render below
@ -383,8 +383,8 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
maxwidth = origx2 - origx1;
for (line = 0; line < 4; line++)
{
mame_machine_manager::instance()->ui().draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
}
@ -403,7 +403,7 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
color = UI_YELLOW_COLOR;
if (driver != nullptr && (driver->flags & (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION)) != 0)
color = UI_RED_COLOR;
mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x2, y2, color);
ui().draw_outlined_box(container, x1, y1, x2, y2, color);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -413,9 +413,9 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
// draw all lines
for (line = 0; line < 4; line++)
{
mame_machine_manager::instance()->ui().draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
y1 += mame_machine_manager::instance()->ui().get_line_height();
y1 += ui().get_line_height();
}
}
@ -425,22 +425,22 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo
// select menu to be visible and inescapable
//-------------------------------------------------
void ui_simple_menu_select_game::force_game_select(running_machine &machine, render_container *container)
void ui_simple_menu_select_game::force_game_select(mame_ui_manager &mui, render_container *container)
{
char *gamename = (char *)machine.options().system_name();
char *gamename = (char *)mui.machine().options().system_name();
// reset the menu stack
ui_menu::stack_reset(machine);
ui_menu::stack_reset(mui.machine());
// add the quit entry followed by the game select entry
ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(machine, container);
ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(mui, container);
quit->set_special_main_menu(true);
ui_menu::stack_push(quit);
ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(machine, container, gamename));
ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(mui, container, gamename));
// force the menus on
mame_machine_manager::instance()->ui().show_menu();
mui.show_menu();
// make sure MAME is paused
machine.pause();
mui.machine().pause();
}

View File

@ -19,14 +19,14 @@ class driver_enumerator;
class ui_simple_menu_select_game : public ui_menu {
public:
ui_simple_menu_select_game(running_machine &machine, render_container *container, const char *gamename);
ui_simple_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename);
virtual ~ui_simple_menu_select_game();
virtual void populate() override;
virtual void handle() override;
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
// force game select menu
static void force_game_select(running_machine &machine, render_container *container);
static void force_game_select(mame_ui_manager &mui, render_container *container);
virtual bool menu_has_search_active() override { return (m_search[0] != 0); }
private:

View File

@ -16,7 +16,7 @@
#include "ui/sliders.h"
ui_menu_sliders::ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode) : ui_menu(machine, container)
ui_menu_sliders::ui_menu_sliders(mame_ui_manager &mui, render_container *container, bool menuless_mode) : ui_menu(mui, container)
{
m_menuless_mode = m_hidden = menuless_mode;
}
@ -139,7 +139,7 @@ void ui_menu_sliders::populate()
std::string tempstring;
/* add UI sliders */
std::vector<ui_menu_item> ui_sliders = mame_machine_manager::instance()->ui().get_slider_list();
std::vector<ui_menu_item> ui_sliders = ui().get_slider_list();
for (ui_menu_item item : ui_sliders)
{
if (item.type == ui_menu_item_type::SLIDER)
@ -182,7 +182,7 @@ void ui_menu_sliders::populate()
}
}
custombottom = 2.0f * mame_machine_manager::instance()->ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
custombottom = 2.0f * ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
}
/*-------------------------------------------------
@ -196,7 +196,7 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom,
if (curslider != nullptr)
{
float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x;
float line_height = mame_machine_manager::instance()->ui().get_line_height();
float line_height = ui().get_line_height();
float percentage, default_percentage;
std::string tempstring;
float text_height;
@ -219,12 +219,12 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom,
x2 = 1.0f - UI_BOX_LR_BORDER;
/* draw extra menu area */
mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
y1 += UI_BOX_TB_BORDER;
/* determine the text height */
mame_machine_manager::instance()->ui().draw_text_full(container, tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, nullptr, &text_height);
ui().draw_text_full(container, tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, rgb_t::white, rgb_t::black, nullptr, &text_height);
/* draw the thermometer */
bar_left = x1 + UI_BOX_LR_BORDER;
@ -250,7 +250,7 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom,
container->add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw the actual text */
mame_machine_manager::instance()->ui().draw_text_full(container, tempstring.c_str(), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
ui().draw_text_full(container, tempstring.c_str(), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, &text_height);
}
}
@ -262,20 +262,20 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom,
standard menu handler
-------------------------------------------------*/
UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state)
UINT32 ui_menu_sliders::ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state)
{
UINT32 result;
/* if this is the first call, push the sliders menu */
if (state)
ui_menu::stack_push(global_alloc_clear<ui_menu_sliders>(machine, container, true));
ui_menu::stack_push(global_alloc_clear<ui_menu_sliders>(mui, container, true));
/* handle standard menus */
result = ui_menu::ui_handler(machine, container, state);
result = ui_menu::ui_handler(mui, container, state);
/* if we are cancelled, pop the sliders menu */
if (result == UI_HANDLER_CANCEL)
ui_menu::stack_pop(machine);
ui_menu::stack_pop(mui.machine());
ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack);
return uim && uim->m_menuless_mode ? 0 : UI_HANDLER_CANCEL;

View File

@ -17,14 +17,14 @@
class ui_menu_sliders : public ui_menu {
public:
ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false);
ui_menu_sliders(mame_ui_manager &mui, render_container *container, bool menuless_mode = false);
virtual ~ui_menu_sliders();
virtual void populate() override;
virtual void handle() override;
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state);
static UINT32 ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state);
private:
enum {

View File

@ -145,7 +145,7 @@ void ui_menu_slot_devices::set_slot_device(device_slot_interface &slot, const ch
slot device menu
-------------------------------------------------*/
ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_slot_devices::ui_menu_slot_devices(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -204,7 +204,7 @@ void ui_menu_slot_devices::handle()
device_slot_interface *slot = (device_slot_interface *)menu_event->itemref;
device_slot_option *option = slot_get_current_option(*slot);
if (option)
ui_menu::stack_push(global_alloc_clear<ui_menu_device_config>(machine(), container, slot, option));
ui_menu::stack_push(global_alloc_clear<ui_menu_device_config>(ui(), container, slot, option));
}
}
}

View File

@ -15,7 +15,7 @@
class ui_menu_slot_devices : public ui_menu {
public:
ui_menu_slot_devices(running_machine &machine, render_container *container);
ui_menu_slot_devices(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_slot_devices();
virtual void populate() override;
virtual void handle() override;

View File

@ -21,13 +21,13 @@ const int ui_menu_sound_options::m_sound_rate[] = { 11025, 22050, 44100, 48000 }
// ctor
//-------------------------------------------------
ui_menu_sound_options::ui_menu_sound_options(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_sound_options::ui_menu_sound_options(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
osd_options &options = downcast<osd_options &>(machine.options());
osd_options &options = downcast<osd_options &>(mui.machine().options());
m_sample_rate = machine.options().sample_rate();
m_sample_rate = mui.machine().options().sample_rate();
m_sound = (strcmp(options.sound(), OSDOPTVAL_NONE) && strcmp(options.sound(), "0"));
m_samples = machine.options().samples();
m_samples = mui.machine().options().samples();
int total = ARRAY_LENGTH(m_sound_rate);
@ -101,7 +101,7 @@ void ui_menu_sound_options::handle()
for (int index = 0; index < total; index++)
s_sel[index] = std::to_string(m_sound_rate[index]);
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, m_cur_rates));
ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(ui(), container, s_sel, m_cur_rates));
}
break;
@ -135,7 +135,7 @@ void ui_menu_sound_options::populate()
item_append(_("Use External Samples"), m_samples ? _("On") : _("Off"), m_samples ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)ENABLE_SAMPLES);
item_append(ui_menu_item_type::SEPARATOR);
customtop = mame_machine_manager::instance()->ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}
//-------------------------------------------------
@ -145,9 +145,8 @@ void ui_menu_sound_options::populate()
void ui_menu_sound_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _("Sound Options"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _("Sound Options"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -158,7 +157,7 @@ void ui_menu_sound_options::custom_render(void *selectedref, float top, float bo
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -166,6 +165,6 @@ void ui_menu_sound_options::custom_render(void *selectedref, float top, float bo
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _("Sound Options"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _("Sound Options"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}

View File

@ -19,7 +19,7 @@
class ui_menu_sound_options : public ui_menu
{
public:
ui_menu_sound_options(running_machine &machine, render_container *container);
ui_menu_sound_options(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_sound_options();
virtual void populate() override;
virtual void handle() override;

View File

@ -18,14 +18,14 @@
// ctor / dtor
//-------------------------------------------------
ui_submenu::ui_submenu(running_machine &machine, render_container *container, std::vector<ui_submenu::option> &suboptions, const game_driver *drv, emu_options *options)
: ui_menu(machine, container)
ui_submenu::ui_submenu(mame_ui_manager &mui, render_container *container, std::vector<ui_submenu::option> &suboptions, const game_driver *drv, emu_options *options)
: ui_menu(mui, container)
, m_options(suboptions)
, m_driver(drv)
{
core_options *opts = nullptr;
if (m_driver == nullptr)
opts = dynamic_cast<core_options*>(&machine.options());
opts = dynamic_cast<core_options*>(&mui.machine().options());
else
opts = dynamic_cast<core_options*>(options);
@ -84,8 +84,8 @@ ui_submenu::ui_submenu(running_machine &machine, render_container *container, st
}
break;
case ui_submenu::UI:
sm_option.entry = mame_machine_manager::instance()->ui().options().get_entry(sm_option.name);
sm_option.options = dynamic_cast<core_options*>(&mame_machine_manager::instance()->ui().options());
sm_option.entry = mui.options().get_entry(sm_option.name);
sm_option.options = dynamic_cast<core_options*>(&mui.options());
break;
default:
break;
@ -298,7 +298,7 @@ void ui_submenu::populate()
}
item_append(ui_menu_item_type::SEPARATOR);
custombottom = customtop = mame_machine_manager::instance()->ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
custombottom = customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}
//-------------------------------------------------
@ -308,10 +308,9 @@ void ui_submenu::populate()
void ui_submenu::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
mame_ui_manager &mui = mame_machine_manager::instance()->ui();
mui.draw_text_full(container, _(m_options[0].description), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, _(m_options[0].description), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
@ -322,7 +321,7 @@ void ui_submenu::custom_render(void *selectedref, float top, float bottom, float
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -330,7 +329,7 @@ void ui_submenu::custom_render(void *selectedref, float top, float bottom, float
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, _(m_options[0].description), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
ui().draw_text_full(container, _(m_options[0].description), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
if (selectedref != nullptr)
@ -338,8 +337,8 @@ void ui_submenu::custom_render(void *selectedref, float top, float bottom, float
ui_submenu::option *selected_sm_option = (ui_submenu::option *)selectedref;
if (selected_sm_option->entry != nullptr)
{
mui.draw_text_full(container, selected_sm_option->entry->description(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
ui().draw_text_full(container, selected_sm_option->entry->description(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(origx2 - origx1, width);
@ -351,7 +350,7 @@ void ui_submenu::custom_render(void *selectedref, float top, float bottom, float
y2 = origy2 + bottom;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
ui().draw_outlined_box(container, x1, y1, x2, y2, UI_RED_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
@ -359,7 +358,7 @@ void ui_submenu::custom_render(void *selectedref, float top, float bottom, float
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, selected_sm_option->entry->description(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
ui().draw_text_full(container, selected_sm_option->entry->description(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}
}

View File

@ -46,7 +46,7 @@ public:
std::vector<std::string> value;
};
ui_submenu(running_machine &machine, render_container *container, std::vector<ui_submenu::option> &suboptions, const game_driver *drv = nullptr, emu_options *options = nullptr);
ui_submenu(mame_ui_manager &mui, render_container *container, std::vector<ui_submenu::option> &suboptions, const game_driver *drv = nullptr, emu_options *options = nullptr);
virtual ~ui_submenu();
virtual void populate() override;
virtual void handle() override;

View File

@ -31,8 +31,8 @@
// ctor
//-------------------------------------------------
ui_menu_software_parts::ui_menu_software_parts(running_machine &machine, render_container *container, const software_info *info, const char *interface, const software_part **part, bool other_opt, int *result)
: ui_menu(machine, container)
ui_menu_software_parts::ui_menu_software_parts(mame_ui_manager &mui, render_container *container, const software_info *info, const char *interface, const software_part **part, bool other_opt, int *result)
: ui_menu(mui, container)
{
m_info = info;
m_interface = interface;
@ -121,8 +121,8 @@ void ui_menu_software_parts::handle()
// ctor
//-------------------------------------------------
ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, std::string &result)
: ui_menu(machine, container), m_result(result)
ui_menu_software_list::ui_menu_software_list(mame_ui_manager &mui, render_container *container, software_list_device *swlist, const char *interface, std::string &result)
: ui_menu(mui, container), m_result(result)
{
m_swlist = swlist;
m_interface = interface;
@ -286,7 +286,7 @@ void ui_menu_software_list::handle()
update_selected = true;
if (ARRAY_LENGTH(m_filename_buffer) > 0)
mame_machine_manager::instance()->ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
}
// if it's any other key and we're not maxed out, update
else if (event->unichar >= ' ' && event->unichar < 0x7f)
@ -296,7 +296,7 @@ void ui_menu_software_list::handle()
update_selected = true;
if (ARRAY_LENGTH(m_filename_buffer) > 0)
mame_machine_manager::instance()->ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);
}
if (update_selected)
@ -382,8 +382,8 @@ void ui_menu_software_list::handle()
// ctor
//-------------------------------------------------
ui_menu_software::ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result)
: ui_menu(machine, container)
ui_menu_software::ui_menu_software(mame_ui_manager &mui, render_container *container, const char *interface, software_list_device **result)
: ui_menu(mui, container)
{
m_interface = interface;
m_result = result;
@ -451,7 +451,7 @@ void ui_menu_software::handle()
const ui_menu_event *event = process(0);
if (event != nullptr && event->iptkey == IPT_UI_SELECT) {
// ui_menu::stack_push(global_alloc_clear<ui_menu_software_list>(machine(), container, (software_list_config *)event->itemref, image));
// ui_menu::stack_push(global_alloc_clear<ui_menu_software_list>(ui(), container, (software_list_config *)event->itemref, image));
*m_result = (software_list_device *)event->itemref;
ui_menu::stack_pop(machine());
}

View File

@ -16,7 +16,7 @@
class ui_menu_software_parts : public ui_menu {
public:
enum { T_EMPTY, T_FMGR, T_SWLIST, T_ENTRY };
ui_menu_software_parts(running_machine &machine, render_container *container, const software_info *info, const char *interface, const software_part **part, bool other_opt, int *result);
ui_menu_software_parts(mame_ui_manager &mui, render_container *container, const software_info *info, const char *interface, const software_part **part, bool other_opt, int *result);
virtual ~ui_menu_software_parts();
virtual void populate() override;
virtual void handle() override;
@ -40,7 +40,7 @@ private:
class ui_menu_software_list : public ui_menu {
public:
ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, std::string &result);
ui_menu_software_list(mame_ui_manager &mui, render_container *container, software_list_device *swlist, const char *interface, std::string &result);
virtual ~ui_menu_software_list();
virtual void populate() override;
virtual void handle() override;
@ -71,7 +71,7 @@ private:
class ui_menu_software : public ui_menu {
public:
ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result);
ui_menu_software(mame_ui_manager &mui, render_container *container, const char *interface, software_list_device **result);
virtual ~ui_menu_software();
virtual void populate() override;
virtual void handle() override;

View File

@ -34,8 +34,8 @@
// ctor
//-------------------------------------------------
ui_menu_tape_control::ui_menu_tape_control(running_machine &machine, render_container *container, cassette_image_device *device)
: ui_menu_device_control<cassette_image_device>(machine, container, device)
ui_menu_tape_control::ui_menu_tape_control(mame_ui_manager &mui, render_container *container, cassette_image_device *device)
: ui_menu_device_control<cassette_image_device>(mui, container, device)
{
}

View File

@ -18,7 +18,7 @@
class ui_menu_tape_control : public ui_menu_device_control<cassette_image_device> {
public:
ui_menu_tape_control(running_machine &machine, render_container *container, cassette_image_device *device);
ui_menu_tape_control(mame_ui_manager &mui, render_container *container, cassette_image_device *device);
virtual ~ui_menu_tape_control();
virtual void populate() override;
virtual void handle() override;

View File

@ -162,24 +162,6 @@ static INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std
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") == osd_file::error::NONE)
{
bool result = mame_machine_manager::instance()->ui().options().parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
if (!result)
osd_printf_error("**Error loading ui.ini**");
}
}
//-------------------------------------------------
// is_breakable_char - is a given unicode
// character a possible line break?
@ -284,9 +266,9 @@ mame_ui_manager::mame_ui_manager(running_machine &machine)
void mame_ui_manager::init()
{
load_ui_options(machine());
load_ui_options();
// initialize the other UI bits
ui_menu::init(machine());
ui_menu::init(machine(), options());
ui_gfx_init(machine());
get_font_rows(&machine());
@ -415,7 +397,7 @@ void mame_ui_manager::display_startup_screens(bool first_time)
{
std::string warning;
warning.assign(_("This driver requires images to be loaded in the following device(s): ")).append(messagebox_text.substr(0, messagebox_text.length() - 2));
ui_menu_file_manager::force_file_manager(machine(), &machine().render().ui_container(), warning.c_str());
ui_menu_file_manager::force_file_manager(*this, &machine().render().ui_container(), warning.c_str());
}
break;
}
@ -490,12 +472,12 @@ void mame_ui_manager::update_and_render(render_container *container)
if (machine().phase() >= MACHINE_PHASE_RESET)
{
mame_machine_manager::instance()->lua()->on_frame_done();
mame_machine_manager::instance()->cheat().render_text(*container);
mame_machine_manager::instance()->cheat().render_text(*this, *container);
}
// call the current UI handler
assert(m_handler_callback != nullptr);
m_handler_param = (*m_handler_callback)(machine(), container, m_handler_param);
m_handler_param = (*m_handler_callback)(*this, container, m_handler_param);
// display any popup messages
if (osd_ticks() < m_popup_text_end)
@ -515,7 +497,7 @@ void mame_ui_manager::update_and_render(render_container *container)
float mouse_y=-1,mouse_x=-1;
if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y))
{
const float cursor_size = 0.6 * mame_machine_manager::instance()->ui().get_line_height();
const float cursor_size = 0.6 * get_line_height();
container->add_quad(mouse_x, mouse_y, mouse_x + cursor_size*container->manager().ui_aspect(container), mouse_y + cursor_size, UI_TEXT_COLOR, m_mouse_arrow_texture, PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
@ -1285,9 +1267,9 @@ std::string &mame_ui_manager::game_info_astring(std::string &str)
// messagebox_text string but handles no input
//-------------------------------------------------
UINT32 mame_ui_manager::handler_messagebox(running_machine &machine, render_container *container, UINT32 state)
UINT32 mame_ui_manager::handler_messagebox(mame_ui_manager &mui, render_container *container, UINT32 state)
{
mame_machine_manager::instance()->ui().draw_text_box(container, messagebox_text.c_str(), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
mui.draw_text_box(container, messagebox_text.c_str(), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
return 0;
}
@ -1298,20 +1280,20 @@ UINT32 mame_ui_manager::handler_messagebox(running_machine &machine, render_cont
// any keypress
//-------------------------------------------------
UINT32 mame_ui_manager::handler_messagebox_anykey(running_machine &machine, render_container *container, UINT32 state)
UINT32 mame_ui_manager::handler_messagebox_anykey(mame_ui_manager &mui, render_container *container, UINT32 state)
{
// draw a standard message window
mame_machine_manager::instance()->ui().draw_text_box(container, messagebox_text.c_str(), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
mui.draw_text_box(container, messagebox_text.c_str(), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
// if the user cancels, exit out completely
if (machine.ui_input().pressed(IPT_UI_CANCEL))
if (mui.machine().ui_input().pressed(IPT_UI_CANCEL))
{
machine.schedule_exit();
mui.machine().schedule_exit();
state = UI_HANDLER_CANCEL;
}
// if any key is pressed, just exit
else if (machine.input().poll_switches() != INPUT_CODE_INVALID)
else if (mui.machine().input().poll_switches() != INPUT_CODE_INVALID)
state = UI_HANDLER_CANCEL;
return state;
@ -1384,7 +1366,7 @@ void mame_ui_manager::increase_frameskip()
machine().video().set_frameskip(newframeskip);
// display the FPS counter for 2 seconds
mame_machine_manager::instance()->ui().show_fps_temp(2.0);
show_fps_temp(2.0);
}
@ -1401,7 +1383,7 @@ void mame_ui_manager::decrease_frameskip()
machine().video().set_frameskip(newframeskip);
// display the FPS counter for 2 seconds
mame_machine_manager::instance()->ui().show_fps_temp(2.0);
show_fps_temp(2.0);
}
@ -1512,61 +1494,62 @@ void mame_ui_manager::image_display(const device_type &type, device_image_interf
// of the standard keypresses
//-------------------------------------------------
UINT32 mame_ui_manager::handler_ingame(running_machine &machine, render_container *container, UINT32 state)
UINT32 mame_ui_manager::handler_ingame(mame_ui_manager &mui, render_container *container, UINT32 state)
{
bool is_paused = machine.paused();
bool is_paused = mui.machine().paused();
// first draw the FPS counter
if (mame_machine_manager::instance()->ui().show_fps_counter())
if (mui.show_fps_counter())
{
mame_machine_manager::instance()->ui().draw_text_full(container, machine.video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr);
mui.draw_text_full(container, mui.machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, rgb_t::white, rgb_t::black, nullptr, nullptr);
}
// Show the duration of current part (intro or gameplay or extra)
if (mame_machine_manager::instance()->ui().show_timecode_counter()) {
if (mui.show_timecode_counter()) {
std::string tempstring;
mame_machine_manager::instance()->ui().draw_text_full(container, machine.video().timecode_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, rgb_t(0xf0,0xf0,0x10,0x10), ARGB_BLACK, nullptr, nullptr);
mui.draw_text_full(container, mui.machine().video().timecode_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, rgb_t(0xf0,0xf0,0x10,0x10), rgb_t::black, nullptr, nullptr);
}
// Show the total time elapsed for the video preview (all parts intro, gameplay, extras)
if (mame_machine_manager::instance()->ui().show_timecode_total()) {
if (mui.show_timecode_total()) {
std::string tempstring;
mame_machine_manager::instance()->ui().draw_text_full(container, machine.video().timecode_total_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, rgb_t(0xf0,0x10,0xf0,0x10), ARGB_BLACK, nullptr, nullptr);
mui.draw_text_full(container, mui.machine().video().timecode_total_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, rgb_t(0xf0,0x10,0xf0,0x10), rgb_t::black, nullptr, nullptr);
}
// draw the profiler if visible
if (mame_machine_manager::instance()->ui().show_profiler())
if (mui.show_profiler())
{
const char *text = g_profiler.text(machine);
mame_machine_manager::instance()->ui().draw_text_full(container, text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr);
const char *text = g_profiler.text(mui.machine());
mui.draw_text_full(container, text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, rgb_t::white, rgb_t::black, nullptr, nullptr);
}
// if we're single-stepping, pause now
if (mame_machine_manager::instance()->ui().single_step())
if (mui.single_step())
{
machine.pause();
mame_machine_manager::instance()->ui().set_single_step(false);
mui.machine().pause();
mui.set_single_step(false);
}
// determine if we should disable the rest of the UI
bool ui_disabled = (machine.ioport().has_keyboard() && !machine.ui_active());
bool has_keyboard = mui.machine().ioport().has_keyboard();
bool ui_disabled = (has_keyboard && !mui.machine().ui_active());
// is ScrLk UI toggling applicable here?
if (machine.ioport().has_keyboard())
if (has_keyboard)
{
// are we toggling the UI with ScrLk?
if (machine.ui_input().pressed(IPT_UI_TOGGLE_UI))
if (mui.machine().ui_input().pressed(IPT_UI_TOGGLE_UI))
{
// toggle the UI
machine.set_ui_active(!machine.ui_active());
mui.machine().set_ui_active(!mui.machine().ui_active());
// display a popup indicating the new status
if (machine.ui_active())
if (mui.machine().ui_active())
{
mame_machine_manager::instance()->ui().popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n",
mui.popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n",
_("Keyboard Emulation Status"),
"-------------------------",
_("Mode: PARTIAL Emulation"),
@ -1576,7 +1559,7 @@ UINT32 mame_ui_manager::handler_ingame(running_machine &machine, render_containe
}
else
{
mame_machine_manager::instance()->ui().popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n",
mui.popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n",
_("Keyboard Emulation Status"),
"-------------------------",
_("Mode: FULL Emulation"),
@ -1588,64 +1571,64 @@ UINT32 mame_ui_manager::handler_ingame(running_machine &machine, render_containe
}
// is the natural keyboard enabled?
if (mame_machine_manager::instance()->ui().use_natural_keyboard() && (machine.phase() == MACHINE_PHASE_RUNNING))
mame_machine_manager::instance()->ui().process_natural_keyboard();
if (mui.use_natural_keyboard() && (mui.machine().phase() == MACHINE_PHASE_RUNNING))
mui.process_natural_keyboard();
if (!ui_disabled)
{
// paste command
if (machine.ui_input().pressed(IPT_UI_PASTE))
mame_machine_manager::instance()->ui().paste();
if (mui.machine().ui_input().pressed(IPT_UI_PASTE))
mui.paste();
}
mame_machine_manager::instance()->ui().image_handler_ingame();
mui.image_handler_ingame();
// handle a save input timecode request
if (machine.ui_input().pressed(IPT_UI_TIMECODE))
machine.video().save_input_timecode();
if (mui.machine().ui_input().pressed(IPT_UI_TIMECODE))
mui.machine().video().save_input_timecode();
if (ui_disabled) return ui_disabled;
if (machine.ui_input().pressed(IPT_UI_CANCEL))
if (mui.machine().ui_input().pressed(IPT_UI_CANCEL))
{
mame_machine_manager::instance()->ui().request_quit();
mui.request_quit();
return 0;
}
// turn on menus if requested
if (machine.ui_input().pressed(IPT_UI_CONFIGURE))
return mame_machine_manager::instance()->ui().set_handler(ui_menu::ui_handler, 0);
if (mui.machine().ui_input().pressed(IPT_UI_CONFIGURE))
return mui.set_handler(ui_menu::ui_handler, 0);
// if the on-screen display isn't up and the user has toggled it, turn it on
if ((machine.debug_flags & DEBUG_FLAG_ENABLED) == 0 && machine.ui_input().pressed(IPT_UI_ON_SCREEN_DISPLAY))
return mame_machine_manager::instance()->ui().set_handler(ui_menu_sliders::ui_handler, 1);
if ((mui.machine().debug_flags & DEBUG_FLAG_ENABLED) == 0 && mui.machine().ui_input().pressed(IPT_UI_ON_SCREEN_DISPLAY))
return mui.set_handler(ui_menu_sliders::ui_handler, 1);
// handle a reset request
if (machine.ui_input().pressed(IPT_UI_RESET_MACHINE))
machine.schedule_hard_reset();
if (machine.ui_input().pressed(IPT_UI_SOFT_RESET))
machine.schedule_soft_reset();
if (mui.machine().ui_input().pressed(IPT_UI_RESET_MACHINE))
mui.machine().schedule_hard_reset();
if (mui.machine().ui_input().pressed(IPT_UI_SOFT_RESET))
mui.machine().schedule_soft_reset();
// handle a request to display graphics/palette
if (machine.ui_input().pressed(IPT_UI_SHOW_GFX))
if (mui.machine().ui_input().pressed(IPT_UI_SHOW_GFX))
{
if (!is_paused)
machine.pause();
return mame_machine_manager::instance()->ui().set_handler(ui_gfx_ui_handler, is_paused);
mui.machine().pause();
return mui.set_handler(ui_gfx_ui_handler, is_paused);
}
// handle a tape control key
if (machine.ui_input().pressed(IPT_UI_TAPE_START))
if (mui.machine().ui_input().pressed(IPT_UI_TAPE_START))
{
for (cassette_image_device &cass : cassette_device_iterator(machine.root_device()))
for (cassette_image_device &cass : cassette_device_iterator(mui.machine().root_device()))
{
cass.change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
return 0;
}
}
if (machine.ui_input().pressed(IPT_UI_TAPE_STOP))
if (mui.machine().ui_input().pressed(IPT_UI_TAPE_STOP))
{
for (cassette_image_device &cass : cassette_device_iterator(machine.root_device()))
for (cassette_image_device &cass : cassette_device_iterator(mui.machine().root_device()))
{
cass.change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
return 0;
@ -1653,87 +1636,87 @@ UINT32 mame_ui_manager::handler_ingame(running_machine &machine, render_containe
}
// handle a save state request
if (machine.ui_input().pressed(IPT_UI_SAVE_STATE))
if (mui.machine().ui_input().pressed(IPT_UI_SAVE_STATE))
{
machine.pause();
mame_machine_manager::instance()->ui().m_load_save_hold = true;
return mame_machine_manager::instance()->ui().set_handler(handler_load_save, LOADSAVE_SAVE);
mui.machine().pause();
mui.m_load_save_hold = true;
return mui.set_handler(handler_load_save, LOADSAVE_SAVE);
}
// handle a load state request
if (machine.ui_input().pressed(IPT_UI_LOAD_STATE))
if (mui.machine().ui_input().pressed(IPT_UI_LOAD_STATE))
{
machine.pause();
mame_machine_manager::instance()->ui().m_load_save_hold = true;
return mame_machine_manager::instance()->ui().set_handler(handler_load_save, LOADSAVE_LOAD);
mui.machine().pause();
mui.m_load_save_hold = true;
return mui.set_handler(handler_load_save, LOADSAVE_LOAD);
}
// handle a save snapshot request
if (machine.ui_input().pressed(IPT_UI_SNAPSHOT))
machine.video().save_active_screen_snapshots();
if (mui.machine().ui_input().pressed(IPT_UI_SNAPSHOT))
mui.machine().video().save_active_screen_snapshots();
// toggle pause
if (machine.ui_input().pressed(IPT_UI_PAUSE))
machine.toggle_pause();
if (mui.machine().ui_input().pressed(IPT_UI_PAUSE))
mui.machine().toggle_pause();
// pause single step
if (machine.ui_input().pressed(IPT_UI_PAUSE_SINGLE))
if (mui.machine().ui_input().pressed(IPT_UI_PAUSE_SINGLE))
{
mame_machine_manager::instance()->ui().set_single_step(true);
machine.resume();
mui.set_single_step(true);
mui.machine().resume();
}
// handle a toggle cheats request
if (machine.ui_input().pressed(IPT_UI_TOGGLE_CHEAT))
if (mui.machine().ui_input().pressed(IPT_UI_TOGGLE_CHEAT))
mame_machine_manager::instance()->cheat().set_enable(!mame_machine_manager::instance()->cheat().enabled());
// toggle movie recording
if (machine.ui_input().pressed(IPT_UI_RECORD_MOVIE))
machine.video().toggle_record_movie();
if (mui.machine().ui_input().pressed(IPT_UI_RECORD_MOVIE))
mui.machine().video().toggle_record_movie();
// toggle profiler display
if (machine.ui_input().pressed(IPT_UI_SHOW_PROFILER))
mame_machine_manager::instance()->ui().set_show_profiler(!mame_machine_manager::instance()->ui().show_profiler());
if (mui.machine().ui_input().pressed(IPT_UI_SHOW_PROFILER))
mui.set_show_profiler(!mui.show_profiler());
// toggle FPS display
if (machine.ui_input().pressed(IPT_UI_SHOW_FPS))
mame_machine_manager::instance()->ui().set_show_fps(!mame_machine_manager::instance()->ui().show_fps());
if (mui.machine().ui_input().pressed(IPT_UI_SHOW_FPS))
mui.set_show_fps(!mui.show_fps());
// increment frameskip?
if (machine.ui_input().pressed(IPT_UI_FRAMESKIP_INC))
mame_machine_manager::instance()->ui().increase_frameskip();
if (mui.machine().ui_input().pressed(IPT_UI_FRAMESKIP_INC))
mui.increase_frameskip();
// decrement frameskip?
if (machine.ui_input().pressed(IPT_UI_FRAMESKIP_DEC))
mame_machine_manager::instance()->ui().decrease_frameskip();
if (mui.machine().ui_input().pressed(IPT_UI_FRAMESKIP_DEC))
mui.decrease_frameskip();
// toggle throttle?
if (machine.ui_input().pressed(IPT_UI_THROTTLE))
machine.video().toggle_throttle();
if (mui.machine().ui_input().pressed(IPT_UI_THROTTLE))
mui.machine().video().toggle_throttle();
// toggle autofire
if (machine.ui_input().pressed(IPT_UI_TOGGLE_AUTOFIRE))
if (mui.machine().ui_input().pressed(IPT_UI_TOGGLE_AUTOFIRE))
{
if (!machine.options().cheat())
if (!mui.machine().options().cheat())
{
machine.popmessage(_("Autofire can't be enabled"));
mui.machine().popmessage(_("Autofire can't be enabled"));
}
else
{
bool autofire_toggle = machine.ioport().get_autofire_toggle();
machine.ioport().set_autofire_toggle(!autofire_toggle);
machine.popmessage("Autofire %s", autofire_toggle ? _("Enabled") : _("Disabled"));
bool autofire_toggle = mui.machine().ioport().get_autofire_toggle();
mui.machine().ioport().set_autofire_toggle(!autofire_toggle);
mui.machine().popmessage("Autofire %s", autofire_toggle ? _("Enabled") : _("Disabled"));
}
}
// check for fast forward
if (machine.ioport().type_pressed(IPT_UI_FAST_FORWARD))
if (mui.machine().ioport().type_pressed(IPT_UI_FAST_FORWARD))
{
machine.video().set_fastforward(true);
mame_machine_manager::instance()->ui().show_fps_temp(0.5);
mui.machine().video().set_fastforward(true);
mui.show_fps_temp(0.5);
}
else
machine.video().set_fastforward(false);
mui.machine().video().set_fastforward(false);
return 0;
}
@ -1744,7 +1727,7 @@ UINT32 mame_ui_manager::handler_ingame(running_machine &machine, render_containe
// specifying a game to save or load
//-------------------------------------------------
UINT32 mame_ui_manager::handler_load_save(running_machine &machine, render_container *container, UINT32 state)
UINT32 mame_ui_manager::handler_load_save(mame_ui_manager &mui, render_container *container, UINT32 state)
{
char filename[20];
char file = 0;
@ -1755,52 +1738,52 @@ UINT32 mame_ui_manager::handler_load_save(running_machine &machine, render_conta
// okay, we're waiting for a key to select a slot; display a message
if (state == LOADSAVE_SAVE)
mame_machine_manager::instance()->ui().draw_message_window(container, _("Select position to save to"));
mui.draw_message_window(container, _("Select position to save to"));
else
mame_machine_manager::instance()->ui().draw_message_window(container, _("Select position to load from"));
mui.draw_message_window(container, _("Select position to load from"));
// if load/save state sequence is still being pressed, do not read the filename yet
if (mame_machine_manager::instance()->ui().m_load_save_hold) {
if (mui.m_load_save_hold) {
bool seq_in_progress = false;
const input_seq &load_save_seq = state == LOADSAVE_SAVE ?
machine.ioport().type_seq(IPT_UI_SAVE_STATE) :
machine.ioport().type_seq(IPT_UI_LOAD_STATE);
mui.machine().ioport().type_seq(IPT_UI_SAVE_STATE) :
mui.machine().ioport().type_seq(IPT_UI_LOAD_STATE);
for (int i = 0; i < load_save_seq.length(); i++)
if (machine.input().code_pressed_once(load_save_seq[i]))
if (mui.machine().input().code_pressed_once(load_save_seq[i]))
seq_in_progress = true;
if (seq_in_progress)
return state;
else
mame_machine_manager::instance()->ui().m_load_save_hold = false;
mui.m_load_save_hold = false;
}
// check for cancel key
if (machine.ui_input().pressed(IPT_UI_CANCEL))
if (mui.machine().ui_input().pressed(IPT_UI_CANCEL))
{
// display a popup indicating things were cancelled
if (state == LOADSAVE_SAVE)
machine.popmessage(_("Save cancelled"));
mui.machine().popmessage(_("Save cancelled"));
else
machine.popmessage(_("Load cancelled"));
mui.machine().popmessage(_("Load cancelled"));
// reset the state
machine.resume();
mui.machine().resume();
return UI_HANDLER_CANCEL;
}
// check for A-Z or 0-9
for (input_item_id id = ITEM_ID_A; id <= ITEM_ID_Z; ++id)
if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
if (mui.machine().input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
file = id - ITEM_ID_A + 'a';
if (file == 0)
for (input_item_id id = ITEM_ID_0; id <= ITEM_ID_9; ++id)
if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
if (mui.machine().input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
file = id - ITEM_ID_0 + '0';
if (file == 0)
for (input_item_id id = ITEM_ID_0_PAD; id <= ITEM_ID_9_PAD; ++id)
if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
if (mui.machine().input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
file = id - ITEM_ID_0_PAD + '0';
if (file == 0)
{
@ -1808,7 +1791,7 @@ UINT32 mame_ui_manager::handler_load_save(running_machine &machine, render_conta
for (int joy_index = 0; joy_index <= MAX_SAVED_STATE_JOYSTICK; joy_index++)
for (input_item_id id = ITEM_ID_BUTTON1; id <= ITEM_ID_BUTTON32; ++id)
if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_JOYSTICK, joy_index, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
if (mui.machine().input().code_pressed_once(input_code(DEVICE_CLASS_JOYSTICK, joy_index, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
{
snprintf(filename, sizeof(filename), "joy%i-%i", joy_index, id - ITEM_ID_BUTTON1 + 1);
found = true;
@ -1826,20 +1809,20 @@ UINT32 mame_ui_manager::handler_load_save(running_machine &machine, render_conta
// display a popup indicating that the save will proceed
if (state == LOADSAVE_SAVE)
{
machine.popmessage(_("Save to position %s"), filename);
machine.schedule_save(filename);
mui.machine().popmessage(_("Save to position %s"), filename);
mui.machine().schedule_save(filename);
}
else
{
machine.popmessage(_("Load from position %s"), filename);
machine.schedule_load(filename);
mui.machine().popmessage(_("Load from position %s"), filename);
mui.machine().schedule_load(filename);
}
// avoid handling the name of the save state slot as a seperate input
machine.ui_input().mark_all_as_pressed();
mui.machine().ui_input().mark_all_as_pressed();
// remove the pause and reset the state
machine.resume();
mui.machine().resume();
return UI_HANDLER_CANCEL;
}
@ -1862,13 +1845,13 @@ void mame_ui_manager::request_quit()
// confirming quit emulation
//-------------------------------------------------
UINT32 mame_ui_manager::handler_confirm_quit(running_machine &machine, render_container *container, UINT32 state)
UINT32 mame_ui_manager::handler_confirm_quit(mame_ui_manager &mui, render_container *container, UINT32 state)
{
// get the text for 'UI Select'
std::string ui_select_text = machine.input().seq_name(machine.ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD));
std::string ui_select_text = mui.machine().input().seq_name(mui.machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD));
// get the text for 'UI Cancel'
std::string ui_cancel_text = machine.input().seq_name(machine.ioport().type_seq(IPT_UI_CANCEL, 0, SEQ_TYPE_STANDARD));
std::string ui_cancel_text = mui.machine().input().seq_name(mui.machine().ioport().type_seq(IPT_UI_CANCEL, 0, SEQ_TYPE_STANDARD));
// assemble the quit message
std::string quit_message = string_format(_("Are you sure you want to quit?\n\n"
@ -1877,17 +1860,17 @@ UINT32 mame_ui_manager::handler_confirm_quit(running_machine &machine, render_co
ui_select_text,
ui_cancel_text);
mame_machine_manager::instance()->ui().draw_text_box(container, quit_message.c_str(), JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
machine.pause();
mui.draw_text_box(container, quit_message.c_str(), JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
mui.machine().pause();
// if the user press ENTER, quit the game
if (machine.ui_input().pressed(IPT_UI_SELECT))
machine.schedule_exit();
if (mui.machine().ui_input().pressed(IPT_UI_SELECT))
mui.machine().schedule_exit();
// if the user press ESC, just continue
else if (machine.ui_input().pressed(IPT_UI_CANCEL))
else if (mui.machine().ui_input().pressed(IPT_UI_CANCEL))
{
machine.resume();
mui.machine().resume();
state = UI_HANDLER_CANCEL;
}
@ -2736,3 +2719,96 @@ void mame_ui_manager::popup_time_string(int seconds, std::string message)
// set a timer
m_popup_text_end = osd_ticks() + osd_ticks_per_second() * seconds;
}
/***************************************************************************
LOADING AND SAVING OPTIONS
***************************************************************************/
//-------------------------------------------------
// load ui options
//-------------------------------------------------
void mame_ui_manager::load_ui_options()
{
// 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") == osd_file::error::NONE)
{
bool result = options().parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
if (!result)
osd_printf_error("**Error loading ui.ini**");
}
}
//-------------------------------------------------
// save ui options
//-------------------------------------------------
void mame_ui_manager::save_ui_options()
{
// 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("ui.ini") == osd_file::error::NONE)
{
// generate the updated INI
std::string initext = options().output_ini();
file.puts(initext.c_str());
file.close();
}
else
machine().popmessage(_("**Error saving ui.ini**"));
}
//-------------------------------------------------
// save main option
//-------------------------------------------------
void mame_ui_manager::save_main_option()
{
// 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") == osd_file::error::NONE)
{
bool result = options.parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
if (!result)
{
osd_printf_error("**Error loading %s.ini**", emulator_info::get_configname());
return;
}
}
}
for (emu_options::entry &f_entry : machine().options())
{
if (f_entry.is_changed())
{
options.set_value(f_entry.name(), f_entry.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") == osd_file::error::NONE)
{
// generate the updated INI
std::string initext = options.output_ini();
file.puts(initext.c_str());
file.close();
}
else {
machine().popmessage(_("**Error saving %s.ini**"), emulator_info::get_configname());
return;
}
}
popup_time(3, "%s", _("\n Configuration saved \n\n"));
}

View File

@ -17,7 +17,6 @@
#include "render.h"
#include "moptions.h"
#include "mame.h"
#include "language.h"
#include "ui/uimain.h"
@ -41,8 +40,6 @@ class ui_menu_item;
#define UI_BOX_TB_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f)
/* handy colors */
#define ARGB_WHITE rgb_t(0xff,0xff,0xff,0xff)
#define ARGB_BLACK rgb_t(0xff,0x00,0x00,0x00)
#define UI_GREEN_COLOR rgb_t(0xef,0x10,0x60,0x10)
#define UI_YELLOW_COLOR rgb_t(0xef,0x60,0x60,0x10)
#define UI_RED_COLOR rgb_t(0xf0,0x60,0x10,0x10)
@ -95,7 +92,8 @@ enum
TYPE DEFINITIONS
***************************************************************************/
typedef UINT32 (*ui_callback)(running_machine &, render_container *, UINT32);
class mame_ui_manager;
typedef UINT32 (*ui_callback)(mame_ui_manager &, render_container *, UINT32);
// ======================> mame_ui_manager
@ -133,6 +131,11 @@ public:
void draw_text_box(render_container *container, const char *text, int justify, float xpos, float ypos, rgb_t backcolor);
void draw_message_window(render_container *container, const char *text);
// load/save options to file
void load_ui_options();
void save_ui_options();
void save_main_option();
template <typename Format, typename... Params> void popup_time(int seconds, Format &&fmt, Params &&... args);
void show_fps_temp(double seconds);
void set_show_fps(bool show);
@ -196,11 +199,11 @@ private:
std::string &warnings_string(std::string &buffer);
// UI handlers
static UINT32 handler_messagebox(running_machine &machine, render_container *container, UINT32 state);
static UINT32 handler_messagebox_anykey(running_machine &machine, render_container *container, UINT32 state);
static UINT32 handler_ingame(running_machine &machine, render_container *container, UINT32 state);
static UINT32 handler_load_save(running_machine &machine, render_container *container, UINT32 state);
static UINT32 handler_confirm_quit(running_machine &machine, render_container *container, UINT32 state);
static UINT32 handler_messagebox(mame_ui_manager &mui, render_container *container, UINT32 state);
static UINT32 handler_messagebox_anykey(mame_ui_manager &mui, render_container *container, UINT32 state);
static UINT32 handler_ingame(mame_ui_manager &mui, render_container *container, UINT32 state);
static UINT32 handler_load_save(mame_ui_manager &mui, render_container *container, UINT32 state);
static UINT32 handler_confirm_quit(mame_ui_manager &mui, render_container *container, UINT32 state);
// private methods
void exit();

View File

@ -24,7 +24,7 @@ void ui_menu_video_targets::handle()
/* process the menu */
const ui_menu_event *menu_event = process(0);
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT)
ui_menu::stack_push(global_alloc_clear<ui_menu_video_options>(machine(), container, static_cast<render_target *>(menu_event->itemref)));
ui_menu::stack_push(global_alloc_clear<ui_menu_video_options>(ui(), container, static_cast<render_target *>(menu_event->itemref)));
}
@ -33,7 +33,7 @@ void ui_menu_video_targets::handle()
video targets menu
-------------------------------------------------*/
ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container)
ui_menu_video_targets::ui_menu_video_targets(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container)
{
}
@ -164,7 +164,7 @@ void ui_menu_video_options::handle()
video options menu
-------------------------------------------------*/
ui_menu_video_options::ui_menu_video_options(running_machine &machine, render_container *container, render_target *_target) : ui_menu(machine, container)
ui_menu_video_options::ui_menu_video_options(mame_ui_manager &mui, render_container *container, render_target *_target) : ui_menu(mui, container)
{
target = _target;
}

View File

@ -16,7 +16,7 @@
class ui_menu_video_targets : public ui_menu {
public:
ui_menu_video_targets(running_machine &machine, render_container *container);
ui_menu_video_targets(mame_ui_manager &mui, render_container *container);
virtual ~ui_menu_video_targets();
virtual void populate() override;
virtual void handle() override;
@ -24,7 +24,7 @@ public:
class ui_menu_video_options : public ui_menu {
public:
ui_menu_video_options(running_machine &machine, render_container *container, render_target *target);
ui_menu_video_options(mame_ui_manager &mui, render_container *container, render_target *target);
virtual ~ui_menu_video_options();
virtual void populate() override;
virtual void handle() override;

View File

@ -111,18 +111,18 @@ static void ui_gfx_exit(running_machine &machine);
// palette handling
static void palette_set_device(running_machine &machine, ui_gfx_state &state);
static void palette_handle_keys(running_machine &machine, ui_gfx_state &state);
static void palette_handler(running_machine &machine, render_container *container, ui_gfx_state &state);
static void palette_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state);
// graphics set handling
static void gfxset_handle_keys(running_machine &machine, ui_gfx_state &state, int xcells, int ycells);
static void gfxset_draw_item(running_machine &machine, gfx_element &gfx, int index, bitmap_rgb32 &bitmap, int dstx, int dsty, int color, int rotate);
static void gfxset_update_bitmap(running_machine &machine, ui_gfx_state &state, int xcells, int ycells, gfx_element &gfx);
static void gfxset_handler(running_machine &machine, render_container *container, ui_gfx_state &state);
static void gfxset_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state);
// tilemap handling
static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, int viswidth, int visheight);
static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, int width, int height);
static void tilemap_handler(running_machine &machine, render_container *container, ui_gfx_state &state);
static void tilemap_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state);
@ -240,16 +240,16 @@ bool ui_gfx_is_relevant(running_machine &machine)
// ui_gfx_ui_handler - primary UI handler
//-------------------------------------------------
UINT32 ui_gfx_ui_handler(running_machine &machine, render_container *container, UINT32 uistate)
UINT32 ui_gfx_ui_handler(mame_ui_manager &mui, render_container *container, UINT32 uistate)
{
ui_gfx_state &state = ui_gfx;
// if we have nothing, implicitly cancel
if (!ui_gfx_is_relevant(machine))
if (!ui_gfx_is_relevant(mui.machine()))
goto cancel;
// if we're not paused, mark the bitmap dirty
if (!machine.paused())
if (!mui.machine().paused())
state.bitmap_dirty = true;
// switch off the state to display something
@ -260,7 +260,7 @@ again:
// if we have a palette, display it
if (state.palette.devcount > 0)
{
palette_handler(machine, container, state);
palette_handler(mui, container, state);
break;
}
@ -271,7 +271,7 @@ again:
// if we have graphics sets, display them
if (state.gfxset.devcount > 0)
{
gfxset_handler(machine, container, state);
gfxset_handler(mui, container, state);
break;
}
@ -280,9 +280,9 @@ again:
case UI_GFX_TILEMAP:
// if we have tilemaps, display them
if (machine.tilemap().count() > 0)
if (mui.machine().tilemap().count() > 0)
{
tilemap_handler(machine, container, state);
tilemap_handler(mui, container, state);
break;
}
@ -291,28 +291,28 @@ again:
}
// handle keys
if (machine.ui_input().pressed(IPT_UI_SELECT))
if (mui.machine().ui_input().pressed(IPT_UI_SELECT))
{
state.mode = (state.mode + 1) % 3;
state.bitmap_dirty = true;
}
if (machine.ui_input().pressed(IPT_UI_PAUSE))
if (mui.machine().ui_input().pressed(IPT_UI_PAUSE))
{
if (machine.paused())
machine.resume();
if (mui.machine().paused())
mui.machine().resume();
else
machine.pause();
mui.machine().pause();
}
if (machine.ui_input().pressed(IPT_UI_CANCEL) || machine.ui_input().pressed(IPT_UI_SHOW_GFX))
if (mui.machine().ui_input().pressed(IPT_UI_CANCEL) || mui.machine().ui_input().pressed(IPT_UI_SHOW_GFX))
goto cancel;
return uistate;
cancel:
if (!uistate)
machine.resume();
mui.machine().resume();
state.bitmap_dirty = true;
return UI_HANDLER_CANCEL;
}
@ -340,13 +340,13 @@ static void palette_set_device(running_machine &machine, ui_gfx_state &state)
// viewer
//-------------------------------------------------
static void palette_handler(running_machine &machine, render_container *container, ui_gfx_state &state)
static void palette_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state)
{
palette_device *palette = state.palette.device;
int total = state.palette.which ? palette->indirect_entries() : palette->entries();
const rgb_t *raw_color = palette->palette()->entry_list_raw();
render_font *ui_font = mame_machine_manager::instance()->ui().get_font();
render_font *ui_font = mui.get_font();
float cellwidth, cellheight;
float chwidth, chheight;
float titlewidth;
@ -357,8 +357,8 @@ static void palette_handler(running_machine &machine, render_container *containe
char title[100];
// add a half character padding for the box
chheight = mame_machine_manager::instance()->ui().get_line_height();
chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0');
chheight = mui.get_line_height();
chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0');
boxbounds.x0 = 0.0f + 0.5f * chwidth;
boxbounds.x1 = 1.0f - 0.5f * chwidth;
boxbounds.y0 = 0.0f + 0.5f * chheight;
@ -380,21 +380,21 @@ static void palette_handler(running_machine &machine, render_container *containe
// figure out the title and expand the outer box to fit
const char *suffix = palette->indirect_entries() == 0 ? "" : state.palette.which ? _(" COLORS") : _(" PENS");
sprintf(title, "'%s'%s", palette->tag(), suffix);
titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title);
titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title);
x0 = 0.0f;
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth));
// go ahead and draw the outer box now
mame_machine_manager::instance()->ui().draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
// draw the title
x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++)
{
container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]);
container->add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), title[x]);
}
// compute the cell size
@ -407,12 +407,12 @@ static void palette_handler(running_machine &machine, render_container *containe
{
x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth;
y0 = boxbounds.y0 + 2.0f * chheight;
container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, "0123456789ABCDEF"[x & 0xf]);
container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, "0123456789ABCDEF"[x & 0xf]);
// if we're skipping, draw a point between the character and the box to indicate which
// one it's referring to
if (skip != 0)
container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, rgb_t::white, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
// draw the side column headers
@ -429,14 +429,14 @@ static void palette_handler(running_machine &machine, render_container *containe
x0 = boxbounds.x0 + 5.5f * chwidth;
y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight;
if (skip != 0)
container->add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// draw the row header
sprintf(buffer, "%5X", state.palette.offset + y * state.palette.columns);
for (x = 4; x >= 0; x--)
{
x0 -= ui_font->char_width(chheight, machine.render().ui_aspect(), buffer[x]);
container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, buffer[x]);
x0 -= ui_font->char_width(chheight, mui.machine().render().ui_aspect(), buffer[x]);
container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, buffer[x]);
}
}
@ -455,7 +455,7 @@ static void palette_handler(running_machine &machine, render_container *containe
}
// handle keys
palette_handle_keys(machine, state);
palette_handle_keys(mui.machine(), state);
}
@ -547,9 +547,9 @@ static void palette_handle_keys(running_machine &machine, ui_gfx_state &state)
// viewer
//-------------------------------------------------
static void gfxset_handler(running_machine &machine, render_container *container, ui_gfx_state &state)
static void gfxset_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state)
{
render_font *ui_font = mame_machine_manager::instance()->ui().get_font();
render_font *ui_font = mui.get_font();
int dev = state.gfxset.devindex;
int set = state.gfxset.set;
ui_gfx_info &info = state.gfxdev[dev];
@ -564,8 +564,8 @@ static void gfxset_handler(running_machine &machine, render_container *container
render_bounds cellboxbounds;
render_bounds boxbounds;
int cellboxwidth, cellboxheight;
int targwidth = machine.render().ui_target().width();
int targheight = machine.render().ui_target().height();
int targwidth = mui.machine().render().ui_target().width();
int targheight = mui.machine().render().ui_target().height();
int cellxpix, cellypix;
int xcells, ycells;
int pixelscale = 0;
@ -573,8 +573,8 @@ static void gfxset_handler(running_machine &machine, render_container *container
char title[100];
// add a half character padding for the box
chheight = mame_machine_manager::instance()->ui().get_line_height();
chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0');
chheight = mui.get_line_height();
chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0');
boxbounds.x0 = 0.0f + 0.5f * chwidth;
boxbounds.x1 = 1.0f - 0.5f * chwidth;
boxbounds.y0 = 0.0f + 0.5f * chheight;
@ -643,21 +643,21 @@ static void gfxset_handler(running_machine &machine, render_container *container
set, info.setcount - 1,
gfx.width(), gfx.height(),
info.color[set]);
titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title);
titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title);
x0 = 0.0f;
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth));
// go ahead and draw the outer box now
mame_machine_manager::instance()->ui().draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
// draw the title
x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++)
{
container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]);
container->add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), title[x]);
}
// draw the top column headers
@ -666,12 +666,12 @@ static void gfxset_handler(running_machine &machine, render_container *container
{
x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth;
y0 = boxbounds.y0 + 2.0f * chheight;
container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, "0123456789ABCDEF"[x & 0xf]);
container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, "0123456789ABCDEF"[x & 0xf]);
// if we're skipping, draw a point between the character and the box to indicate which
// one it's referring to
if (skip != 0)
container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + boxbounds.y0 + 3.5f * chheight), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + boxbounds.y0 + 3.5f * chheight), UI_LINE_WIDTH, rgb_t::white, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
// draw the side column headers
@ -688,28 +688,28 @@ static void gfxset_handler(running_machine &machine, render_container *container
x0 = boxbounds.x0 + 5.5f * chwidth;
y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight;
if (skip != 0)
container->add_point(0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container->add_point(0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// draw the row header
sprintf(buffer, "%5X", info.offset[set] + y * xcells);
for (x = 4; x >= 0; x--)
{
x0 -= ui_font->char_width(chheight, machine.render().ui_aspect(), buffer[x]);
container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, buffer[x]);
x0 -= ui_font->char_width(chheight, mui.machine().render().ui_aspect(), buffer[x]);
container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, buffer[x]);
}
}
// update the bitmap
gfxset_update_bitmap(machine, state, xcells, ycells, gfx);
gfxset_update_bitmap(mui.machine(), state, xcells, ycells, gfx);
// add the final quad
container->add_quad(boxbounds.x0 + 6.0f * chwidth, boxbounds.y0 + 3.5f * chheight,
boxbounds.x0 + 6.0f * chwidth + (float)cellboxwidth / (float)targwidth,
boxbounds.y0 + 3.5f * chheight + (float)cellboxheight / (float)targheight,
ARGB_WHITE, state.texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
rgb_t::white, state.texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// handle keyboard navigation before drawing
gfxset_handle_keys(machine, state, xcells, ycells);
gfxset_handle_keys(mui.machine(), state, xcells, ycells);
}
@ -947,14 +947,14 @@ static void gfxset_draw_item(running_machine &machine, gfx_element &gfx, int ind
// viewer
//-------------------------------------------------
static void tilemap_handler(running_machine &machine, render_container *container, ui_gfx_state &state)
static void tilemap_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state)
{
render_font *ui_font = mame_machine_manager::instance()->ui().get_font();
render_font *ui_font = mui.get_font();
float chwidth, chheight;
render_bounds mapboxbounds;
render_bounds boxbounds;
int targwidth = machine.render().ui_target().width();
int targheight = machine.render().ui_target().height();
int targwidth = mui.machine().render().ui_target().width();
int targheight = mui.machine().render().ui_target().height();
float titlewidth;
float x0, y0;
int mapboxwidth, mapboxheight;
@ -964,15 +964,15 @@ static void tilemap_handler(running_machine &machine, render_container *containe
char title[100];
// get the size of the tilemap itself
tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which);
tilemap_t *tilemap = mui.machine().tilemap().find(state.tilemap.which);
mapwidth = tilemap->width();
mapheight = tilemap->height();
if (state.tilemap.rotate & ORIENTATION_SWAP_XY)
{ UINT32 temp = mapwidth; mapwidth = mapheight; mapheight = temp; }
// add a half character padding for the box
chheight = mame_machine_manager::instance()->ui().get_line_height();
chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0');
chheight = mui.get_line_height();
chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0');
boxbounds.x0 = 0.0f + 0.5f * chwidth;
boxbounds.x1 = 1.0f - 0.5f * chwidth;
boxbounds.y0 = 0.0f + 0.5f * chheight;
@ -1018,8 +1018,8 @@ static void tilemap_handler(running_machine &machine, render_container *containe
boxbounds.y1 = mapboxbounds.y1 + 0.5f * chheight;
// figure out the title and expand the outer box to fit
sprintf(title, "TILEMAP %d/%d %dx%d OFFS %d,%d", state.tilemap.which, machine.tilemap().count() - 1, mapwidth, mapheight, state.tilemap.xoffs, state.tilemap.yoffs);
titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title);
sprintf(title, "TILEMAP %d/%d %dx%d OFFS %d,%d", state.tilemap.which, mui.machine().tilemap().count() - 1, mapwidth, mapheight, state.tilemap.xoffs, state.tilemap.yoffs);
titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title);
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
{
boxbounds.x0 = 0.5f - 0.5f * (titlewidth + chwidth);
@ -1027,28 +1027,28 @@ static void tilemap_handler(running_machine &machine, render_container *containe
}
// go ahead and draw the outer box now
mame_machine_manager::instance()->ui().draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
mui.draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
// draw the title
x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++)
{
container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]);
container->add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, title[x]);
x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), title[x]);
}
// update the bitmap
tilemap_update_bitmap(machine, state, mapboxwidth / pixelscale, mapboxheight / pixelscale);
tilemap_update_bitmap(mui.machine(), state, mapboxwidth / pixelscale, mapboxheight / pixelscale);
// add the final quad
container->add_quad(mapboxbounds.x0, mapboxbounds.y0,
mapboxbounds.x1, mapboxbounds.y1,
ARGB_WHITE, state.texture,
rgb_t::white, state.texture,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state.tilemap.rotate));
// handle keyboard input
tilemap_handle_keys(machine, state, mapboxwidth, mapboxheight);
tilemap_handle_keys(mui.machine(), state, mapboxwidth, mapboxheight);
}

View File

@ -26,7 +26,7 @@ void ui_gfx_init(running_machine &machine);
bool ui_gfx_is_relevant(running_machine &machine);
// master handler
UINT32 ui_gfx_ui_handler(running_machine &machine, render_container *container, UINT32 state);
UINT32 ui_gfx_ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state);
#endif /* __UI_VIEWGFX_H__ */

View File

@ -9,6 +9,7 @@
*********************************************************************/
#include "emu.h"
#include "mame.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "rendfont.h"
@ -1310,7 +1311,7 @@ static void render_editor(DView_edit *editor)
class ui_menu_debug : public ui_menu {
public:
ui_menu_debug(running_machine &machine, render_container *container) : ui_menu(machine, container) {}
ui_menu_debug(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) {}
virtual ~ui_menu_debug() {}
virtual void populate() override {}
virtual void handle() override {}
@ -1327,7 +1328,7 @@ static void CreateMainMenu(running_machine &machine)
menu_sel = menu->get_selection();
global_free( menu);
}
menu = global_alloc_clear<ui_menu_debug>(machine, &machine.render().ui_container());
menu = global_alloc_clear<ui_menu_debug>(mame_machine_manager::instance()->ui(), &machine.render().ui_container());
switch (focus_view->type)
{