mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Unglamorous changes from my UI rewrite
This commit is contained in:
parent
b39c1b7745
commit
571f51c7ab
@ -467,7 +467,7 @@ static void dview_draw_title(DView *dv)
|
||||
}
|
||||
}
|
||||
|
||||
static int dview_on_mouse(DView *dv, int mx, int my, int button)
|
||||
static int dview_on_mouse(DView *dv, int mx, int my, bool button)
|
||||
{
|
||||
int clicked = (button && !dview_is_state(dv, VIEW_STATE_BUTTON));
|
||||
int handled = TRUE;
|
||||
@ -1233,7 +1233,7 @@ static void handle_mouse(running_machine &machine)
|
||||
{
|
||||
render_target * mouse_target;
|
||||
INT32 x,y;
|
||||
int button;
|
||||
bool button;
|
||||
|
||||
if (menu != NULL)
|
||||
return;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual void machine_start()
|
||||
{
|
||||
// force the UI to show the game select screen
|
||||
ui_menu_force_game_select(machine(), &machine().render().ui_container());
|
||||
ui_menu_select_game::force_game_select(machine(), &machine().render().ui_container());
|
||||
}
|
||||
|
||||
UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
|
@ -841,6 +841,18 @@ void input_type_entry::configure_osd(const char *token, const char *name)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// restore_default_seq - restores the sequence
|
||||
// from the default
|
||||
//-------------------------------------------------
|
||||
|
||||
void input_type_entry::restore_default_seq()
|
||||
{
|
||||
for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
|
||||
m_seq[seqtype] = defseq(seqtype);
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DIGITAL JOYSTICKS
|
||||
//**************************************************************************
|
||||
@ -2655,6 +2667,32 @@ time_t ioport_manager::initialize()
|
||||
// register callbacks for when we load configurations
|
||||
config_register(machine(), "input", config_saveload_delegate(FUNC(ioport_manager::load_config), this), config_saveload_delegate(FUNC(ioport_manager::save_config), this));
|
||||
|
||||
// calculate "has..." values
|
||||
{
|
||||
m_has_configs = false;
|
||||
m_has_analog = false;
|
||||
m_has_dips = false;
|
||||
m_has_bioses = false;
|
||||
|
||||
// scan the input port array to see what options we need to enable
|
||||
for (ioport_port *port = first_port(); port != NULL; port = port->next())
|
||||
for (ioport_field *field = port->first_field(); field != NULL; field = field->next())
|
||||
{
|
||||
if (field->type() == IPT_DIPSWITCH)
|
||||
m_has_dips = true;
|
||||
if (field->type() == IPT_CONFIG)
|
||||
m_has_configs = true;
|
||||
if (field->is_analog())
|
||||
m_has_analog = true;
|
||||
}
|
||||
device_iterator deviter(machine().root_device());
|
||||
for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
|
||||
if (device->rom_region())
|
||||
for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom)) { m_has_bioses= true; break; }
|
||||
}
|
||||
|
||||
|
||||
// open playback and record files if specified
|
||||
time_t basetime = playback_init();
|
||||
record_init();
|
||||
@ -2680,7 +2718,7 @@ void ioport_manager::init_port_types()
|
||||
{
|
||||
// first copy all the OSD-updated sequences into our current state
|
||||
for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
|
||||
curtype->m_seq[seqtype] = curtype->defseq(seqtype);
|
||||
curtype->restore_default_seq();
|
||||
|
||||
// also make a lookup table mapping type/player to the appropriate type list entry
|
||||
m_type_to_entry[curtype->type()][curtype->player()] = curtype;
|
||||
@ -2993,7 +3031,7 @@ g_profiler.start(PROFILER_INPUT);
|
||||
|
||||
// perform mouse hit testing
|
||||
INT32 mouse_target_x, mouse_target_y;
|
||||
int mouse_button;
|
||||
bool mouse_button;
|
||||
render_target *mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button);
|
||||
|
||||
// if the button is pressed, map the point and determine what was hit
|
||||
|
@ -721,6 +721,7 @@ public:
|
||||
const char *name() const { return m_name; }
|
||||
input_seq &defseq(input_seq_type seqtype = SEQ_TYPE_STANDARD) { return m_defseq[seqtype]; }
|
||||
const input_seq &seq(input_seq_type seqtype = SEQ_TYPE_STANDARD) const { return m_seq[seqtype]; }
|
||||
void restore_default_seq();
|
||||
|
||||
// setters
|
||||
void configure_osd(const char *token, const char *name);
|
||||
@ -1217,6 +1218,12 @@ public:
|
||||
ioport_port *first_port() const { return m_portlist.first(); }
|
||||
bool safe_to_read() const { return m_safe_to_read; }
|
||||
natural_keyboard &natkeyboard() { return m_natkeyboard; }
|
||||
|
||||
// has... getters
|
||||
bool has_configs() const { return m_has_configs; }
|
||||
bool has_analog() const { return m_has_analog; }
|
||||
bool has_dips() const { return m_has_dips; }
|
||||
bool has_bioses() const { return m_has_bioses; }
|
||||
|
||||
// type helpers
|
||||
input_type_entry *first_type() const { return m_typelist.first(); }
|
||||
@ -1296,6 +1303,12 @@ private:
|
||||
emu_file m_playback_file; // playback file (NULL if not recording)
|
||||
UINT64 m_playback_accumulated_speed; // accumulated speed during playback
|
||||
UINT32 m_playback_accumulated_frames; // accumulated frames during playback
|
||||
|
||||
// has...
|
||||
bool m_has_configs;
|
||||
bool m_has_analog;
|
||||
bool m_has_dips;
|
||||
bool m_has_bioses;
|
||||
};
|
||||
|
||||
|
||||
|
@ -483,7 +483,7 @@ void running_machine::schedule_exit()
|
||||
if (m_exit_to_game_select && options().system_name()[0] != 0)
|
||||
{
|
||||
options().set_system_name("");
|
||||
ui_menu_force_game_select(*this, &render().ui_container());
|
||||
ui_menu_select_game::force_game_select(*this, &render().ui_container());
|
||||
}
|
||||
|
||||
// otherwise, exit for real
|
||||
@ -770,6 +770,19 @@ void running_machine::resume()
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// toggle_pause - toggles the pause state
|
||||
//-------------------------------------------------
|
||||
|
||||
void running_machine::toggle_pause()
|
||||
{
|
||||
if (paused())
|
||||
resume();
|
||||
else
|
||||
pause();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// add_notifier - add a notifier of the
|
||||
// given type
|
||||
|
@ -230,6 +230,7 @@ public:
|
||||
int run(bool firstrun);
|
||||
void pause();
|
||||
void resume();
|
||||
void toggle_pause();
|
||||
void add_notifier(machine_notification event, machine_notify_delegate callback);
|
||||
void call_notifiers(machine_notification which);
|
||||
void add_logerror_callback(logerror_callback callback);
|
||||
|
22
src/emu/ui.c
22
src/emu/ui.c
@ -95,14 +95,14 @@ static UINT32 (*ui_handler_callback)(running_machine &, render_container *, UINT
|
||||
static UINT32 ui_handler_param;
|
||||
|
||||
/* flag to track single stepping */
|
||||
static int single_step;
|
||||
static bool single_step;
|
||||
|
||||
/* FPS counter display */
|
||||
static int showfps;
|
||||
static osd_ticks_t showfps_end;
|
||||
|
||||
/* profiler display */
|
||||
static int show_profiler;
|
||||
static bool show_profiler;
|
||||
|
||||
/* popup text display */
|
||||
static osd_ticks_t popup_text_end;
|
||||
@ -116,7 +116,7 @@ static slider_state *slider_list;
|
||||
static slider_state *slider_current;
|
||||
|
||||
/* natural keyboard info */
|
||||
static int ui_use_natural_keyboard;
|
||||
static bool ui_use_natural_keyboard;
|
||||
static UINT8 non_char_keys_down[(ARRAY_LENGTH(non_char_keys) + 7) / 8];
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ int ui_init(running_machine &machine)
|
||||
ui_gfx_init(machine);
|
||||
|
||||
/* reset globals */
|
||||
single_step = FALSE;
|
||||
single_step = false;
|
||||
ui_set_handler(handler_messagebox, 0);
|
||||
/* retrieve options */
|
||||
ui_use_natural_keyboard = machine.options().natural_keyboard();
|
||||
@ -447,7 +447,7 @@ void ui_update_and_render(running_machine &machine, render_container *container)
|
||||
if (ui_mouse_show || (ui_is_menu_active() && machine.options().ui_mouse()))
|
||||
{
|
||||
INT32 mouse_target_x, mouse_target_y;
|
||||
int mouse_button;
|
||||
bool mouse_button;
|
||||
render_target *mouse_target = ui_input_find_mouse(machine, &mouse_target_x, &mouse_target_y, &mouse_button);
|
||||
|
||||
if (mouse_target != NULL)
|
||||
@ -1392,7 +1392,7 @@ static UINT32 handler_ingame(running_machine &machine, render_container *contain
|
||||
if (single_step)
|
||||
{
|
||||
machine.pause();
|
||||
single_step = FALSE;
|
||||
single_step = false;
|
||||
}
|
||||
|
||||
/* determine if we should disable the rest of the UI */
|
||||
@ -1500,13 +1500,11 @@ static UINT32 handler_ingame(running_machine &machine, render_container *contain
|
||||
/* with a shift key, it is single step */
|
||||
if (is_paused && (machine.input().code_pressed(KEYCODE_LSHIFT) || machine.input().code_pressed(KEYCODE_RSHIFT)))
|
||||
{
|
||||
single_step = TRUE;
|
||||
single_step = true;
|
||||
machine.resume();
|
||||
}
|
||||
else if (machine.paused())
|
||||
machine.resume();
|
||||
else
|
||||
machine.pause();
|
||||
machine.toggle_pause();
|
||||
}
|
||||
|
||||
/* handle a toggle cheats request */
|
||||
@ -2300,7 +2298,7 @@ static INT32 slider_crossoffset(running_machine &machine, void *arg, astring *st
|
||||
whether the natural keyboard is active
|
||||
-------------------------------------------------*/
|
||||
|
||||
int ui_get_use_natural_keyboard(running_machine &machine)
|
||||
bool ui_get_use_natural_keyboard(running_machine &machine)
|
||||
{
|
||||
return ui_use_natural_keyboard;
|
||||
}
|
||||
@ -2312,7 +2310,7 @@ int ui_get_use_natural_keyboard(running_machine &machine)
|
||||
whether the natural keyboard is active
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_set_use_natural_keyboard(running_machine &machine, int use_natural_keyboard)
|
||||
void ui_set_use_natural_keyboard(running_machine &machine, bool use_natural_keyboard)
|
||||
{
|
||||
ui_use_natural_keyboard = use_natural_keyboard;
|
||||
astring error;
|
||||
|
@ -187,9 +187,9 @@ const slider_state *ui_get_slider_list(void);
|
||||
void ui_paste(running_machine &machine);
|
||||
|
||||
/* returns whether the natural keyboard is active */
|
||||
int ui_get_use_natural_keyboard(running_machine &machine);
|
||||
bool ui_get_use_natural_keyboard(running_machine &machine);
|
||||
|
||||
/* specifies whether the natural keyboard is active */
|
||||
void ui_set_use_natural_keyboard(running_machine &machine, int use_natural_keyboard);
|
||||
void ui_set_use_natural_keyboard(running_machine &machine, bool use_natural_keyboard);
|
||||
|
||||
#endif /* __USRINTRF_H__ */
|
||||
|
@ -44,7 +44,7 @@ struct ui_input_private
|
||||
render_target * current_mouse_target;
|
||||
INT32 current_mouse_x;
|
||||
INT32 current_mouse_y;
|
||||
int current_mouse_down;
|
||||
bool current_mouse_down;
|
||||
|
||||
/* popped states; ring buffer of ui_events */
|
||||
ui_event events[EVENT_QUEUE_SIZE];
|
||||
@ -113,7 +113,7 @@ void ui_input_frame_update(running_machine &machine)
|
||||
onto the queue
|
||||
-------------------------------------------------*/
|
||||
|
||||
int ui_input_push_event(running_machine &machine, ui_event evt)
|
||||
bool ui_input_push_event(running_machine &machine, ui_event evt)
|
||||
{
|
||||
ui_input_private *uidata = machine.ui_input_data;
|
||||
|
||||
@ -140,11 +140,11 @@ int ui_input_push_event(running_machine &machine, ui_event evt)
|
||||
break;
|
||||
|
||||
case UI_EVENT_MOUSE_DOWN:
|
||||
uidata->current_mouse_down = TRUE;
|
||||
uidata->current_mouse_down = true;
|
||||
break;
|
||||
|
||||
case UI_EVENT_MOUSE_UP:
|
||||
uidata->current_mouse_down = FALSE;
|
||||
uidata->current_mouse_down = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -154,11 +154,11 @@ int ui_input_push_event(running_machine &machine, ui_event evt)
|
||||
|
||||
/* is the queue filled up? */
|
||||
if ((uidata->events_end + 1) % ARRAY_LENGTH(uidata->events) == uidata->events_start)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
uidata->events[uidata->events_end++] = evt;
|
||||
uidata->events_end %= ARRAY_LENGTH(uidata->events);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -166,21 +166,21 @@ int ui_input_push_event(running_machine &machine, ui_event evt)
|
||||
ui_input_pop_event - pops an event off of the queue
|
||||
-------------------------------------------------*/
|
||||
|
||||
int ui_input_pop_event(running_machine &machine, ui_event *evt)
|
||||
bool ui_input_pop_event(running_machine &machine, ui_event *evt)
|
||||
{
|
||||
ui_input_private *uidata = machine.ui_input_data;
|
||||
int result;
|
||||
bool result;
|
||||
|
||||
if (uidata->events_start != uidata->events_end)
|
||||
{
|
||||
*evt = uidata->events[uidata->events_start++];
|
||||
uidata->events_start %= ARRAY_LENGTH(uidata->events);
|
||||
result = TRUE;
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(evt, 0, sizeof(*evt));
|
||||
result = FALSE;
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -211,7 +211,7 @@ void ui_input_reset(running_machine &machine)
|
||||
location of the mouse
|
||||
-------------------------------------------------*/
|
||||
|
||||
render_target *ui_input_find_mouse(running_machine &machine, INT32 *x, INT32 *y, int *button)
|
||||
render_target *ui_input_find_mouse(running_machine &machine, INT32 *x, INT32 *y, bool *button)
|
||||
{
|
||||
ui_input_private *uidata = machine.ui_input_data;
|
||||
if (x != NULL)
|
||||
|
@ -62,16 +62,16 @@ void ui_input_init(running_machine &machine);
|
||||
void ui_input_frame_update(running_machine &machine);
|
||||
|
||||
/* pushes a single event onto the queue */
|
||||
int ui_input_push_event(running_machine &machine, ui_event event);
|
||||
bool ui_input_push_event(running_machine &machine, ui_event event);
|
||||
|
||||
/* pops an event off of the queue */
|
||||
int ui_input_pop_event(running_machine &machine, ui_event *event);
|
||||
bool ui_input_pop_event(running_machine &machine, ui_event *event);
|
||||
|
||||
/* clears all outstanding events */
|
||||
void ui_input_reset(running_machine &machine);
|
||||
|
||||
/* retrieves the current location of the mouse */
|
||||
render_target *ui_input_find_mouse(running_machine &machine, INT32 *x, INT32 *y, int *button);
|
||||
render_target *ui_input_find_mouse(running_machine &machine, INT32 *x, INT32 *y, bool *button);
|
||||
|
||||
|
||||
|
||||
|
@ -70,11 +70,11 @@ UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *c
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
ui_menu_force_game_select - force the game
|
||||
force_game_select - force the game
|
||||
select menu to be visible and inescapable
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_force_game_select(running_machine &machine, render_container *container)
|
||||
void ui_menu_select_game::force_game_select(running_machine &machine, render_container *container)
|
||||
{
|
||||
char *gamename = (char *)machine.options().system_name();
|
||||
|
||||
@ -109,29 +109,7 @@ ui_menu_main::ui_menu_main(running_machine &machine, render_container *container
|
||||
|
||||
void ui_menu_main::populate()
|
||||
{
|
||||
ioport_field *field;
|
||||
ioport_port *port;
|
||||
int has_configs = false;
|
||||
int has_analog = false;
|
||||
int has_dips = false;
|
||||
int has_bioses = false;
|
||||
astring menu_text;
|
||||
/* scan the input port array to see what options we need to enable */
|
||||
for (port = machine().ioport().first_port(); port != NULL; port = port->next())
|
||||
for (field = port->first_field(); field != NULL; field = field->next())
|
||||
{
|
||||
if (field->type() == IPT_DIPSWITCH)
|
||||
has_dips = true;
|
||||
if (field->type() == IPT_CONFIG)
|
||||
has_configs = true;
|
||||
if (field->is_analog())
|
||||
has_analog = true;
|
||||
}
|
||||
device_iterator deviter(machine().root_device());
|
||||
for (device_t *device = deviter.first(); device != NULL; device = deviter.next())
|
||||
if (device->rom_region())
|
||||
for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
|
||||
if (ROMENTRY_ISSYSTEM_BIOS(rom)) { has_bioses= true; break; }
|
||||
|
||||
/* add input menu items */
|
||||
item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS);
|
||||
@ -140,11 +118,11 @@ void ui_menu_main::populate()
|
||||
item_append(menu_text.cstr(), NULL, 0, (void *)INPUT_SPECIFIC);
|
||||
|
||||
/* add optional input-related menus */
|
||||
if (has_analog)
|
||||
if (machine().ioport().has_analog())
|
||||
item_append("Analog Controls", NULL, 0, (void *)ANALOG);
|
||||
if (has_dips)
|
||||
if (machine().ioport().has_dips())
|
||||
item_append("Dip Switches", NULL, 0, (void *)SETTINGS_DIP_SWITCHES);
|
||||
if (has_configs)
|
||||
if (machine().ioport().has_configs())
|
||||
{
|
||||
menu_text.printf("%s Configuration",emulator_info::get_capstartgamenoun());
|
||||
item_append(menu_text.cstr(), NULL, 0, (void *)SETTINGS_DRIVER_CONFIG);
|
||||
@ -177,7 +155,7 @@ void ui_menu_main::populate()
|
||||
item_append("Bitbanger Control", NULL, 0, (void *)MESS_MENU_BITBANGER_CONTROL);
|
||||
}
|
||||
|
||||
if (has_bioses)
|
||||
if (machine().ioport().has_bioses())
|
||||
item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION);
|
||||
|
||||
slot_interface_iterator slotiter(machine().root_device());
|
||||
|
@ -352,6 +352,9 @@ public:
|
||||
virtual void handle();
|
||||
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
|
||||
|
||||
// force game select menu
|
||||
static void force_game_select(running_machine &machine, render_container *container);
|
||||
|
||||
private:
|
||||
enum { VISIBLE_GAMES_IN_LIST = 15 };
|
||||
UINT8 error;
|
||||
@ -374,7 +377,5 @@ public:
|
||||
|
||||
private:
|
||||
};
|
||||
/* force game select menu */
|
||||
void ui_menu_force_game_select(running_machine &machine, render_container *container);
|
||||
|
||||
#endif /* __UIMAIN_H__ */
|
||||
|
@ -414,7 +414,7 @@ void ui_menu::draw(bool customonly)
|
||||
int visible_lines;
|
||||
int top_line;
|
||||
int itemnum, linenum;
|
||||
int mouse_hit, mouse_button;
|
||||
bool mouse_hit, mouse_button;
|
||||
render_target *mouse_target;
|
||||
INT32 mouse_target_x, mouse_target_y;
|
||||
float mouse_x = -1, mouse_y = -1;
|
||||
@ -487,14 +487,14 @@ void ui_menu::draw(bool customonly)
|
||||
effective_left = visible_left + gutter_width;
|
||||
|
||||
/* locate mouse */
|
||||
mouse_hit = FALSE;
|
||||
mouse_button = FALSE;
|
||||
mouse_hit = false;
|
||||
mouse_button = false;
|
||||
if (!customonly)
|
||||
{
|
||||
mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button);
|
||||
if (mouse_target != NULL)
|
||||
if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y))
|
||||
mouse_hit = TRUE;
|
||||
mouse_hit = true;
|
||||
}
|
||||
|
||||
/* loop over visible lines */
|
||||
|
Loading…
Reference in New Issue
Block a user