Do not read the load/save state filename while sequence is still pressed

Fixes the issue where, if the save state button was bound to something
that was a legal save state input, it would occasionally immediately
save the state onto the same button as "save state" input itself was
bound.
This commit is contained in:
Victor Vasiliev 2016-02-01 10:29:47 -05:00
parent b11f39e7a0
commit c626466050
2 changed files with 20 additions and 0 deletions

View File

@ -1625,6 +1625,7 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co
if (machine.ui_input().pressed(IPT_UI_SAVE_STATE))
{
machine.pause();
machine.ui().m_load_save_hold = true;
return machine.ui().set_handler(handler_load_save, LOADSAVE_SAVE);
}
@ -1632,6 +1633,7 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co
if (machine.ui_input().pressed(IPT_UI_LOAD_STATE))
{
machine.pause();
machine.ui().m_load_save_hold = true;
return machine.ui().set_handler(handler_load_save, LOADSAVE_LOAD);
}
@ -1713,6 +1715,23 @@ UINT32 ui_manager::handler_load_save(running_machine &machine, render_container
else
machine.ui().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 (machine.ui().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);
for (int i = 0; i < load_save_seq.length(); i++)
if (machine.input().code_pressed_once(load_save_seq[i]))
seq_in_progress = true;
if (seq_in_progress)
return state;
else
machine.ui().m_load_save_hold = false;
}
// check for cancel key
if (machine.ui_input().pressed(IPT_UI_CANCEL))
{

View File

@ -182,6 +182,7 @@ private:
std::unique_ptr<UINT8[]> m_non_char_keys_down;
render_texture * m_mouse_arrow_texture;
bool m_mouse_show;
bool m_load_save_hold;
// text generators
std::string &disclaimer_string(std::string &buffer);