Exemplo n.º 1
0
menu_t *MenuProcessCmd(menu_t *menu, int cmd)
{
	menu_t *menuToChange = NULL;
	if (cmd == CMD_ESC)
	{
		menuToChange = MenuProcessEscCmd(menu);
		if (menuToChange != NULL)
		{
			SoundPlay(&gSoundDevice, SND_PICKUP);
			return menuToChange;
		}
	}
	menuToChange = MenuProcessButtonCmd(menu, cmd);
	if (menuToChange != NULL)
	{
		debug(D_VERBOSE, "change to menu type %d\n", menuToChange->type);
		// TODO: refactor menu change sound
		if (menuToChange->type == MENU_TYPE_CAMPAIGN_ITEM)
		{
			SoundPlay(&gSoundDevice, SND_HAHAHA);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_MACHINEGUN);
		}
		return menuToChange;
	}
	MenuChangeIndex(menu, cmd);
	return menu;
}
Exemplo n.º 2
0
void MenuProcessCmd(MenuSystem *ms, int cmd)
{
	menu_t *menu = ms->current;
	menu_t *menuToChange = NULL;
	if (cmd == CMD_ESC || (cmd & CMD_BUTTON2) ||
		((cmd & CMD_LEFT) && menu->u.normal.isSubmenusAlt))
	{
		menuToChange = MenuProcessEscCmd(menu);
		if (menuToChange != NULL)
		{
			MenuPlaySound(MENU_SOUND_BACK);
			ms->current = menuToChange;
			goto bail;
		}
	}
	if (menu->type == MENU_TYPE_CUSTOM)
	{
		if (menu->u.customData.inputFunc(cmd, menu->u.customData.data))
		{
			ms->current = menu->parentMenu;
			goto bail;
		}
	}
	else
	{
		menuToChange = MenuProcessButtonCmd(ms, menu, cmd);
		if (menuToChange != NULL)
		{
			debug(D_VERBOSE, "change to menu type %d\n", menuToChange->type);
			if (menuToChange->type == MENU_TYPE_CAMPAIGN_ITEM)
			{
				MenuPlaySound(MENU_SOUND_START);
			}
			else
			{
				MenuPlaySound(MENU_SOUND_ENTER);
			}
			ms->current = menuToChange;
			goto bail;
		}
		MenuChangeIndex(menu, cmd);
	}

bail:
	if (menu->customPostInputFunc)
	{
		menu->customPostInputFunc(menu, cmd, menu->customPostInputData);
	}
	if (menuToChange && menuToChange->customPostEnterFunc)
	{
		menuToChange->customPostEnterFunc(
			menuToChange, menuToChange->customPostEnterData);
	}
}