Esempio n. 1
0
menu_t *MenuProcessButtonCmd(menu_t *menu, int cmd)
{
	if (AnyButton(cmd) ||
		(!MenuTypeLeftRightMoves(menu->type) && (Left(cmd) || Right(cmd))))
	{
		menu_t *subMenu = &menu->u.normal.subMenus[menu->u.normal.index];
		switch (subMenu->type)
		{
		case MENU_TYPE_NORMAL:
		case MENU_TYPE_OPTIONS:
		case MENU_TYPE_CAMPAIGNS:
		case MENU_TYPE_KEYS:
			return subMenu;
		case MENU_TYPE_CAMPAIGN_ITEM:
			MenuLoadCampaign(&subMenu->u.campaign);
			return subMenu;	// caller will check if subMenu type is CAMPAIGN_ITEM
		case MENU_TYPE_BACK:
			return menu->parentMenu;
		case MENU_TYPE_QUIT:
			return subMenu;	// caller will check if subMenu type is QUIT
		case MENU_TYPE_RETURN:
			return subMenu;
		default:
			MenuActivate(subMenu, cmd);
			break;
		}
	}
	return NULL;
}
Esempio n. 2
0
menu_t *MenuProcessButtonCmd(MenuSystem *ms, menu_t *menu, int cmd)
{
	if (AnyButton(cmd) ||
		(!MenuTypeLeftRightMoves(menu->type) && (Left(cmd) || Right(cmd))))
	{
		menu_t *subMenu = &menu->u.normal.subMenus[menu->u.normal.index];

		// Only allow menu switching on button 1

		switch (subMenu->type)
		{
		case MENU_TYPE_NORMAL:
		case MENU_TYPE_OPTIONS:
		case MENU_TYPE_CAMPAIGNS:
		case MENU_TYPE_KEYS:
		case MENU_TYPE_CUSTOM:
			if (cmd & CMD_BUTTON1)
			{
				return subMenu;
			}
			break;
		case MENU_TYPE_CAMPAIGN_ITEM:
			if (cmd & CMD_BUTTON1)
			{
				MenuLoadCampaign(&subMenu->u.campaign);
				return subMenu;	// caller will check if subMenu type is CAMPAIGN_ITEM
			}
			break;
		case MENU_TYPE_BACK:
			if (cmd & CMD_BUTTON1)
			{
				return menu->parentMenu;
			}
			break;
		case MENU_TYPE_QUIT:
			if (cmd & CMD_BUTTON1)
			{
				return subMenu;	// caller will check if subMenu type is QUIT
			}
			break;
		case MENU_TYPE_RETURN:
			if (cmd & CMD_BUTTON1)
			{
				return subMenu;
			}
			break;
		default:
			MenuActivate(ms, subMenu, cmd);
			break;
		}
	}
	return NULL;
}
Esempio n. 3
0
void MenuChangeIndex(menu_t *menu, int cmd)
{
	int leftRightMoves = MenuTypeLeftRightMoves(menu->type);
	if (Up(cmd) || (leftRightMoves && Left(cmd)))
	{
		do
		{
			menu->u.normal.index--;
			if (menu->u.normal.index < 0)
			{
				menu->u.normal.index = menu->u.normal.numSubMenus - 1;
			}
		} while (menu->u.normal.subMenus[menu->u.normal.index].type ==
			MENU_TYPE_SEPARATOR);
		SoundPlay(&gSoundDevice, SND_DOOR);
	}
	else if (Down(cmd) || (leftRightMoves && Right(cmd)))
	{
		do
		{
			menu->u.normal.index++;
			if (menu->u.normal.index >= menu->u.normal.numSubMenus)
			{
				menu->u.normal.index = 0;
			}
		} while (menu->u.normal.subMenus[menu->u.normal.index].type ==
			MENU_TYPE_SEPARATOR);
		SoundPlay(&gSoundDevice, SND_DOOR);
	}
	menu->u.normal.scroll =
		CLAMP(menu->u.normal.scroll,
			MAX(0, menu->u.normal.index - 11),
			MIN(menu->u.normal.numSubMenus - 1, menu->u.normal.index + 11));
	if (menu->u.normal.index < menu->u.normal.scroll)
	{
		menu->u.normal.scroll = menu->u.normal.index;
	}
}
Esempio n. 4
0
void MenuChangeIndex(menu_t *menu, int cmd)
{
	int leftRightMoves = MenuTypeLeftRightMoves(menu->type);
	if (Up(cmd) || (leftRightMoves && Left(cmd)))
	{
		do
		{
			menu->u.normal.index--;
			if (menu->u.normal.index < 0)
			{
				menu->u.normal.index = menu->u.normal.numSubMenus - 1;
			}
		} while (menu->u.normal.subMenus[menu->u.normal.index].isDisabled);
		MenuPlaySound(MENU_SOUND_SWITCH);
	}
	else if (Down(cmd) || (leftRightMoves && Right(cmd)))
	{
		do
		{
			menu->u.normal.index++;
			if (menu->u.normal.index >= menu->u.normal.numSubMenus)
			{
				menu->u.normal.index = 0;
			}
		} while (menu->u.normal.subMenus[menu->u.normal.index].isDisabled);
		MenuPlaySound(MENU_SOUND_SWITCH);
	}
	menu->u.normal.scroll =
		CLAMP(menu->u.normal.scroll,
			MAX(0, menu->u.normal.index - 11),
			MIN(menu->u.normal.numSubMenus - 1, menu->u.normal.index + 11));
	if (menu->u.normal.index < menu->u.normal.scroll)
	{
		menu->u.normal.scroll = menu->u.normal.index;
	}
}