void task_play_deal_msg(void) { u8 msg = get_msg(); switch(msg) { case T_KEY_PLAY | T_KEY_SHORT_UP: #if 0 if(!fs_api.file_mode)//jpg file break; #endif if((filename[14] =='J')&&(filename[15] =='P')&&(filename[16] =='G')) { } else { task_play_pause_control(); t_play.play_sta = PLAY_VIDEO; } break; case T_KEY_MENU | T_KEY_SHORT_UP: if(task_ctl.work_sta == TASK_PLAY) { if(task_ctl.on_playing) task_play_pause_control(); #if(MENU_DISPLAY_USE == MENU_DISPLAY_ENABLE) MenuDisplay(MENU_BROWSE); #endif if(t_play.pause_flag) task_play_pause_control(); } else #if(MENU_DISPLAY_USE == MENU_DISPLAY_ENABLE) MenuDisplay(MENU_BROWSE); #endif break; case T_KEY_DOWN | T_KEY_SHORT_UP: task_paly_get_file_num(PLAY_NEXT_FILE); t_play.play_sta = PLAY_VIDEO; t_play.pause_flag = 0; break; case T_KEY_UP | T_KEY_SHORT_UP: task_paly_get_file_num(PLAY_PRVE_FILE); t_play.play_sta = PLAY_VIDEO; t_play.pause_flag = 0; break; default: deal_msg(msg); break; } }
static void MenuDraw(void *data) { const MenuSystem *ms = data; GraphicsBlitBkg(ms->graphics); ShowControls(); MenuDisplay(ms); }
void MenuLoop(MenuSystem *menu) { assert(menu->numExitTypes > 0); for (;; SDL_Delay(10)) { MusicSetPlaying(&gSoundDevice, SDL_GetAppState() & SDL_APPINPUTFOCUS); // Input InputPoll(menu->inputDevices, SDL_GetTicks()); // Update if (menu->current->type == MENU_TYPE_KEYS && menu->current->u.normal.changeKeyMenu != NULL) { MenuProcessChangeKey(menu->current); } else { int cmd = GetMenuCmd(gPlayerDatas); MenuProcessCmd(menu, cmd); } if (MenuIsExit(menu)) { break; } // Draw GraphicsBlitBkg(menu->graphics); ShowControls(); MenuDisplay(menu); BlitFlip(menu->graphics, &gConfig.Graphics); } }
void MenuLoop(MenuSystem *menu) { assert(menu->numExitTypes > 0); for (;; SDL_Delay(10)) { // Input InputPoll(menu->joysticks, menu->keyboard); // Update if (menu->current->type == MENU_TYPE_KEYS && menu->current->u.normal.changeKeyMenu != NULL) { MenuProcessChangeKey(menu->current); } else { int cmd = GetMenuCmd(); menu->current = MenuProcessCmd(menu->current, cmd); } if (MenuHasExitType(menu, menu->current->type)) { break; } // Draw if (menu->bkg != NULL) { memcpy( GetDstScreen(), menu->bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig)); } ShowControls(); MenuDisplay(menu); CopyToScreen(); } }
int NumPlayersSelection( int *numPlayers, campaign_mode_e mode, GraphicsDevice *graphics, InputDevices *input) { MenuSystem ms; int i; int res = 0; MenuSystemInit( &ms, input, graphics, Vec2iZero(), Vec2iNew( graphics->cachedConfig.ResolutionWidth, graphics->cachedConfig.ResolutionHeight)); ms.root = ms.current = MenuCreateNormal( "", "Select number of players", MENU_TYPE_NORMAL, 0); for (i = 0; i < MAX_PLAYERS; i++) { if (mode == CAMPAIGN_MODE_DOGFIGHT && i == 0) { // At least two players for dogfights continue; } char buf[2]; sprintf(buf, "%d", i + 1); MenuAddSubmenu(ms.current, MenuCreateReturn(buf, i + 1)); } MenuAddExitType(&ms, MENU_TYPE_RETURN); for (;;) { int cmd; InputPoll(&gInputDevices, SDL_GetTicks()); if (KeyIsPressed(&gInputDevices.keyboard, SDLK_ESCAPE)) { res = 0; break; // hack to allow exit } cmd = GetMenuCmd(gPlayerDatas); MenuProcessCmd(&ms, cmd); if (MenuIsExit(&ms)) { *numPlayers = ms.current->u.returnCode; res = 1; break; } GraphicsBlitBkg(graphics); MenuDisplay(&ms); BlitFlip(graphics, &gConfig.Graphics); SDL_Delay(10); } MenuSystemTerminate(&ms); return res; }
static void PlayerEquipDraw(void *data) { const PlayerEquipData *pData = data; GraphicsBlitBkg(&gGraphicsDevice); for (int i = 0; i < GetNumPlayers(false, false, true); i++) { MenuDisplay(&pData->menus[i].ms); } }
avltest<T>::avltest(AVLtree<T> & bst) { int flag = 0; do { clrscr; menu_choice entree=MenuDisplay(); MainMenu(bst,entree); flag = (entree == quit); } while (!flag); ShowAll(bst); }
static void PlayerSelectionDraw(void *data) { const PlayerSelectionData *pData = data; GraphicsBlitBkg(&gGraphicsDevice); const int w = gGraphicsDevice.cachedConfig.Res.x; const int h = gGraphicsDevice.cachedConfig.Res.y; int idx = 0; for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++) { const PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } if (p->inputDevice != INPUT_DEVICE_UNSET) { MenuDisplay(&pData->menus[idx].ms); } else { Vec2i center = Vec2iZero(); const char *prompt = "Press Fire to join..."; const Vec2i offset = Vec2iScaleDiv(FontStrSize(prompt), -2); switch (GetNumPlayers(false, false, true)) { case 1: // Center of screen center = Vec2iNew(w / 2, h / 2); break; case 2: // Side by side center = Vec2iNew(idx * w / 2 + w / 4, h / 2); break; case 3: case 4: // Four corners center = Vec2iNew( (idx & 1) * w / 2 + w / 4, (idx / 2) * h / 2 + h / 4); break; default: CASSERT(false, "not implemented"); break; } FontStr(prompt, Vec2iAdd(center, offset)); } } }
int PlayerEquip(int numPlayers, GraphicsDevice *graphics) { int i; WeaponMenu menus[MAX_PLAYERS]; for (i = 0; i < numPlayers; i++) { WeaponMenuCreate( &menus[i], numPlayers, i, &gCampaign.Setting.characters.players[i], &gPlayerDatas[i], &gInputDevices, graphics, &gConfig.Input); } debug(D_NORMAL, "\n"); for (;;) { int cmds[MAX_PLAYERS]; int isDone = 1; InputPoll(&gInputDevices, SDL_GetTicks()); if (KeyIsPressed(&gInputDevices.keyboard, SDLK_ESCAPE)) { return 0; // hack to exit from menu } GetPlayerCmds(&cmds, gPlayerDatas); for (i = 0; i < numPlayers; i++) { if (!MenuIsExit(&menus[i].ms)) { MenuProcessCmd(&menus[i].ms, cmds[i]); } else if (gPlayerDatas[i].weaponCount == 0) { // Check exit condition; must have selected at least one weapon // Otherwise reset the current menu menus[i].ms.current = menus[i].ms.root; } } for (i = 0; i < numPlayers; i++) { if (!MenuIsExit(&menus[i].ms)) { isDone = 0; } } if (isDone) { break; } GraphicsBlitBkg(graphics); for (i = 0; i < numPlayers; i++) { MenuDisplay(&menus[i].ms); } BlitFlip(graphics, &gConfig.Graphics); SDL_Delay(10); } for (i = 0; i < numPlayers; i++) { MenuSystemTerminate(&menus[i].ms); } return 1; }
int PlayerSelection(int numPlayers, GraphicsDevice *graphics) { int i; int hasInputDevice[MAX_PLAYERS]; PlayerSelectMenu menus[MAX_PLAYERS]; for (i = 0; i < numPlayers; i++) { PlayerSelectMenusCreate( &menus[i], numPlayers, i, &gCampaign.Setting.characters.players[i], &gPlayerDatas[i], &gInputDevices, graphics, &gConfig.Input); hasInputDevice[i] = 0; } KeyInit(&gInputDevices.keyboard); for (;;) { int cmds[MAX_PLAYERS]; int isDone = 1; InputPoll(&gInputDevices, SDL_GetTicks()); if (KeyIsPressed(&gInputDevices.keyboard, SDLK_ESCAPE)) { // TODO: destroy menus return 0; // hack to allow exit } GetPlayerCmds(&cmds, gPlayerDatas); for (i = 0; i < numPlayers; i++) { if (hasInputDevice[i] && !MenuIsExit(&menus[i].ms)) { MenuProcessCmd(&menus[i].ms, cmds[i]); } } for (i = 0; i < numPlayers; i++) { if (!MenuIsExit(&menus[i].ms)) { isDone = 0; } } if (isDone) { break; } AssignPlayerInputDevices( hasInputDevice, numPlayers, gPlayerDatas, &gInputDevices, &gConfig.Input); GraphicsBlitBkg(graphics); for (i = 0; i < numPlayers; i++) { if (hasInputDevice[i]) { MenuDisplay(&menus[i].ms); } else { Vec2i center; const char *prompt = "Press Fire to join..."; Vec2i offset = Vec2iScaleDiv(TextGetSize(prompt), -2); int w = graphics->cachedConfig.ResolutionWidth; int h = graphics->cachedConfig.ResolutionHeight; switch (numPlayers) { case 1: // Center of screen center = Vec2iNew(w / 2, h / 2); break; case 2: // Side by side center = Vec2iNew(i * w / 2 + w / 4, h / 2); break; case 3: case 4: // Four corners center = Vec2iNew( (i & 1) * w / 2 + w / 4, (i / 2) * h / 2 + h / 4); break; default: assert(0 && "not implemented"); break; } DrawTextString(prompt, graphics, Vec2iAdd(center, offset)); } } BlitFlip(graphics, &gConfig.Graphics); SDL_Delay(10); } for (i = 0; i < numPlayers; i++) { MenuSystemTerminate(&menus[i].ms); } return 1; }
//***************************************************************************** // // Performs all necessary menu and control processing based on new button // states. // // \param ucButtons contains the current state of each of the front panel // buttons. A 1 in a bit position indicates that the corresponding button // is released while a 0 indicates that the button is pressed. // \param ucChanged contains bit flags showing which button states changed // since the last call to this function. A 1 indicates that the corresponding // button state changed while a 0 indicates that it remains unchanged. // \param ucRepeat contains bit flags indicating whether a key autorepeat // event is being signalled for each key. A 1 indicates that an autorepeat is // being signalled while a 0 indicates that it is not. // // This is the top level function called when any key changes state. This // updates the relevant control or controls on the screen and processes // the key appropriately for the control that currently has focus. // // \return Returns \b true if the menu was dismissed as a result of this // call (in which case the caller should refresh the main waveform // display area) or any control reported that a display update is required. // Returns \b false if the menu is still being displayed or if it // was not being displayed when the function was called and no control // reported needing a display update. // //***************************************************************************** tBoolean MenuProcess(unsigned char ucButtons, unsigned char ucChanged, unsigned char ucRepeat) { tGroup *pFocusGroup; tBoolean bRetcode; tBoolean bRedrawNeeded; // // Assume we won't be dismissing the menu until we find out otherwise. // bRedrawNeeded = false; // // Which group has focus? // pFocusGroup = g_sMenu.ppcGroups[g_sMenu.ucFocusGroup]; // // Is the menu currently visible? // if(!g_bMenuShown) { // // The menu is not currently shown. First check to see if we need to // show it and, if so, do this. We look for a release of the select // button to trigger the display of the menu. Note that we // deliberately ignore all other key notifications that may be present // at the same time. // if(BUTTON_RELEASED(SELECT_BUTTON, ucButtons, ucChanged)) { // // Draw the menu. // g_bMenuShown = MenuDisplay(&g_sMenu); // // Get rid of any alert message that may currently be displayed. // RendererClearAlert(); } else { // // We were not being asked to show the menu so we pass the // various events on to the group for it to decide what to do // with them. For the group, we pass on any button press or auto- // repeat indication. We ignore button releases in this case. // // // Left button press or repeat. // if(BUTTON_PRESSED(LEFT_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(LEFT_BUTTON, ucRepeat)) { bRetcode = pFocusGroup->pfnGroupEventProc(pFocusGroup, MENU_EVENT_LEFT); if(bRetcode) { bRedrawNeeded = true; } } // // Right button press or repeat. // if(BUTTON_PRESSED(RIGHT_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(RIGHT_BUTTON, ucRepeat)) { bRetcode = pFocusGroup->pfnGroupEventProc(pFocusGroup, MENU_EVENT_RIGHT); if(bRetcode) { bRedrawNeeded = true; } } // // Left button released. // if(BUTTON_RELEASED(LEFT_BUTTON, ucButtons, ucChanged)) { bRetcode = pFocusGroup->pfnGroupEventProc(pFocusGroup, MENU_EVENT_LEFT_RELEASE); if(bRetcode) { bRedrawNeeded = true; } } // // Right button released. // if(BUTTON_RELEASED(RIGHT_BUTTON, ucButtons, ucChanged)) { bRetcode = pFocusGroup->pfnGroupEventProc(pFocusGroup, MENU_EVENT_RIGHT_RELEASE); if(bRetcode) { bRedrawNeeded = true; } } // // Up button press. // if(BUTTON_PRESSED(UP_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(UP_BUTTON, ucRepeat)) { bRetcode = pFocusGroup->pfnGroupEventProc(pFocusGroup, MENU_EVENT_UP); if(bRetcode) { bRedrawNeeded = true; } } // // Down button press. // if(BUTTON_PRESSED(DOWN_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(DOWN_BUTTON, ucRepeat)) { bRetcode = pFocusGroup->pfnGroupEventProc(pFocusGroup, MENU_EVENT_DOWN); if(bRetcode) { bRedrawNeeded = true; } } } } else { // // The menu is already visible so we ignore left and right keys and // use up/down/select only to change the focus group. // // // If this button press will result in a group focus change we need to // redraw the current group in its non-focused colors, update the // focus to the new group then send an activate event to the group. // if(BUTTON_PRESSED(DOWN_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(DOWN_BUTTON, ucRepeat) || BUTTON_PRESSED(UP_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(UP_BUTTON, ucRepeat)) { // // Redraw the current focus button in its original colors // MenuDrawGroupButton(&g_sMenu, g_sMenu.ucFocusGroup, &g_psBtnColors); // // Update the group with the focus // if(BUTTON_PRESSED(DOWN_BUTTON, ucButtons, ucChanged) || BUTTON_REPEAT(DOWN_BUTTON, ucRepeat)) { if(g_sMenu.ucFocusGroup < (g_sMenu.ucNumGroups - 1)) { g_sMenu.ucFocusGroup++; } } else { if(g_sMenu.ucFocusGroup > 0) { g_sMenu.ucFocusGroup--; } } // // Redraw the new focus button with the focus colors. // MenuDrawGroupButton(&g_sMenu, g_sMenu.ucFocusGroup, &g_psFocusColors); // // Tell the new group that it has been activated. // pFocusGroup = g_sMenu.ppcGroups[g_sMenu.ucFocusGroup]; bRetcode = (pFocusGroup->pfnGroupEventProc)(pFocusGroup, MENU_EVENT_ACTIVATE); if(bRetcode) { bRedrawNeeded = true; } } // // Now look for a release of the SELECT key. This indicates that we // must dismiss the menu. // if(BUTTON_RELEASED(SELECT_BUTTON, ucButtons, ucChanged)) { // // We did receive a release message for the SELECT button so // tell the caller that the menu has been dismissed. // g_bMenuShown = false; bRedrawNeeded = true; } } // // Play the button click sound if any button was just pressed. // if((~ucButtons & ucChanged) && g_bClicksEnabled) { ClassDPlayADPCM(g_pucADPCMClick, sizeof(g_pucADPCMClick)); } return(bRedrawNeeded); }