Esempio n. 1
0
bool cheat_entry::select_next_state()
{
	bool changed = false;

	// if we're a oneshot, there is no next state
	if (is_oneshot())
		;

	// if we're on/off, toggle to running state
	else if (is_onoff())
		changed = set_state(SCRIPT_STATE_RUN);

	// if we have a parameter, set the next state
	else if (m_parameter != NULL)
	{
		// if we're off, switch on to the minimum state
		if (m_state == SCRIPT_STATE_OFF)
		{
			changed = set_state(SCRIPT_STATE_RUN);
			m_parameter->set_minimum_state();
		}

		// otherwise, switch to the next state
		else
			changed = m_parameter->set_next_state();

		// if we changed, signal a state change
		if (changed && !is_oneshot_parameter())
			execute_change_script();
	}
	return changed;
}
Esempio n. 2
0
bool cheat_entry::select_previous_state()
{
	bool changed = false;

	// if we're a oneshot, there is no previous state
	if (is_oneshot())
		;

	// if we're on/off, toggle to off
	else if (is_onoff())
		changed = set_state(SCRIPT_STATE_OFF);

	// if we have a parameter, set the previous state
	else if (m_parameter != NULL)
	{
		// if we're at our minimum, turn off
		if (m_parameter->is_minimum())
			changed = set_state(SCRIPT_STATE_OFF);
		else
		{
			// if we changed, ensure we are in the running state and signal state change
			changed = m_parameter->set_prev_state();
			if (changed)
			{
				set_state(SCRIPT_STATE_RUN);
				if (!is_oneshot_parameter())
					execute_change_script();
			}
		}
	}
	return changed;
}
Esempio n. 3
0
bool cheat_entry::activate()
{
	bool changed = false;

	// if cheats have been toggled off no point in even trying to do anything
	if (!m_manager.enabled())
		return changed;

	// if we're a oneshot cheat, execute the "on" script and indicate change
	if (is_oneshot())
	{
		execute_on_script();
		changed = true;
		popmessage("Activated %s", m_description.cstr());
	}

	// if we're a oneshot parameter cheat and we're active, execute the "state change" script and indicate change
	else if (is_oneshot_parameter() && m_state != SCRIPT_STATE_OFF)
	{
		execute_change_script();
		changed = true;
		popmessage("Activated\n %s = %s", m_description.cstr(), m_parameter->text());
	}

	return changed;
}
Esempio n. 4
0
bool cheat_entry::select_default_state()
{
	bool changed = false;

	// if we're a oneshot cheat, there is no default state
	if (is_oneshot())
		;

	// all other types switch to the "off" state
	else
		changed = set_state(SCRIPT_STATE_OFF);

	return changed;
}
Esempio n. 5
0
void cheat_entry::menu_text(astring &description, astring &state, UINT32 &flags)
{
	// description is standard
	description.cpy(m_description);
	state.reset();
	flags = 0;

	// some cheat entries are just text for display
	if (is_text_only())
	{
		if (description)
		{
			description.trimspace();
			if (!description)
				description.cpy(MENU_SEPARATOR_ITEM);
		}
		flags = MENU_FLAG_DISABLE;
	}

	// if we have no parameter and no run or off script, it's a oneshot cheat
	else if (is_oneshot())
		state.cpy("Set");

	// if we have no parameter, it's just on/off
	else if (is_onoff())
	{
		state.cpy((m_state == SCRIPT_STATE_RUN) ? "On" : "Off");
		flags = (m_state != 0) ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW;
	}

	// if we have a value parameter, compute it
	else if (m_parameter != NULL)
	{
		if (m_state == SCRIPT_STATE_OFF)
		{
			state.cpy(is_oneshot_parameter() ? "Set" : "Off");
			flags = MENU_FLAG_RIGHT_ARROW;
		}
		else
		{
			state.cpy(m_parameter->text());
			flags = MENU_FLAG_LEFT_ARROW;
			if (!m_parameter->is_maximum())
				flags |= MENU_FLAG_RIGHT_ARROW;
		}
	}
}
Esempio n. 6
0
void cheat_entry::menu_text(std::string &description, std::string &state, uint32_t &flags)
{
	// description is standard
	description.assign(m_description);
	state.clear();
	flags = 0;

	// some cheat entries are just text for display
	if (is_text_only())
	{
		if (!description.empty())
		{
			strtrimspace(description);
			if (description.empty())
				description.assign(MENU_SEPARATOR_ITEM);
		}
		flags = ui::menu::FLAG_DISABLE;
	}

	// if we have no parameter and no run or off script, it's a oneshot cheat
	else if (is_oneshot())
		state.assign("Set");

	// if we have no parameter, it's just on/off
	else if (is_onoff())
	{
		state.assign((m_state == SCRIPT_STATE_RUN) ? "On" : "Off");
		flags = (m_state != 0) ? ui::menu::FLAG_LEFT_ARROW : ui::menu::FLAG_RIGHT_ARROW;
	}

	// if we have a value parameter, compute it
	else if (m_parameter != nullptr)
	{
		if (m_state == SCRIPT_STATE_OFF)
		{
			state.assign(is_oneshot_parameter() ? "Set" : "Off");
			flags = ui::menu::FLAG_RIGHT_ARROW;
		}
		else
		{
			state.assign(m_parameter->text());
			flags = ui::menu::FLAG_LEFT_ARROW;
			if (!m_parameter->is_maximum())
				flags |= ui::menu::FLAG_RIGHT_ARROW;
		}
	}
}