void menu() { int choice; playerMenu(); printf("Press Enter to continue\n"); _getch(); system("cls"); initialize_game_board(); printf("\n--------TIC-TAC-TOE MENU--------"); printf("\n1 : Play with X"); printf("\n2 : Play with O"); printf("\n3 : View all players"); printf("\n4 : View top ten players"); printf("\n0 : Exit"); printf("\nEnter your choice:>"); scanf_s("%d", &choice); turn = 1; switch (choice) { case 1: player = 1; comp = 0; player_turn(); break; case 2: player = 0; comp = 1; start_game(); break; case 3: viewAllPlayers(); menu(); break; case 4: viewTopTenPlayers(); menu(); break; case 0: printPlayerList(); playerMenu(); break; default: menu(); } }
virtual void Enter() { tOutput title; title.SetTemplateParameter( 1, player->GetName() ); title << "$team_menu_player_title"; uMenu playerMenu( title ); tArray<uMenuItem*> items; if ( !player->IsSpectating() ) { items[ items.Len() ] = tNEW( gMenuItemSpectate ) ( &playerMenu, player ); } if ( player->NextTeam()!=NULL) { items[items.Len()] = tNEW(gMenuItemSpectate) (&playerMenu, player); } // first pass add teams who probably can't be joined for ( int i = 0; i<eTeam::teams.Len(); i++ ) { eTeam *team = eTeam::teams(i); if ( team && team != player->NextTeam() && !team->PlayerMayJoin( player ) ) { items[ items.Len() ] = tNEW( gMenuItemPlayerTeam ) ( &playerMenu, player, team ); } } // second pass add teams who probably can be joined // Note: these will appear above the unjoinable ones. for ( int i = 0; i<eTeam::teams.Len(); i++ ) { eTeam *team = eTeam::teams(i); if ( team && team != player->NextTeam() && team->PlayerMayJoin( player )) items[ items.Len() ] = tNEW( gMenuItemPlayerTeam ) ( &playerMenu, player, team ); } if ( player->IsSpectating() || !( player->NextTeam() && player->NextTeam()->NumHumanPlayers() == 1 && player->CurrentTeam() && player->CurrentTeam()->NumHumanPlayers() == 1 ) ) { items[ items.Len() ] = tNEW( gMenuItemNewTeam ) ( &playerMenu, player ); } items[items.Len()] = tNEW ( gMenuItemSpacer ) ( &playerMenu ); items[items.Len()] = tNEW ( gMenuItemStatus ) ( &playerMenu, player, false); items[items.Len()] = tNEW ( gMenuItemStatus ) ( &playerMenu, player, true); playerMenu.Enter(); for ( int i = items.Len()-1; i>=0; --i ) { delete items(i); } }
int CruiseEngine::processInput() { int16 mouseX = 0; int16 mouseY = 0; int16 button = 0; /*if (inputSub1keyboad()) * { * return 1; * } */ button = 0; if (sysKey != -1) { button = sysKey; mouseX = sysX; mouseY = sysY; sysKey = -1; } else if (automaticMode == 0) { getMouseStatus(&main10, &mouseX, &button, &mouseY); } if (!button) { buttonDown = 0; } // Check for Exit 'X' key if (keyboardCode == Common::KEYCODE_x) return 1; // Check for Pause 'P' key if (keyboardCode == Common::KEYCODE_p) { keyboardCode = Common::KEYCODE_INVALID; _vm->pauseEngine(true); mouseOff(); bool pausedButtonDown = false; while (!_vm->shouldQuit()) { manageEvents(); getMouseStatus(&main10, &mouseX, &button, &mouseY); if (button) pausedButtonDown = true; else if (pausedButtonDown) // Button released, so exit pause break; else if (keyboardCode != Common::KEYCODE_INVALID) break; g_system->delayMillis(10); } if (keyboardCode == Common::KEYCODE_x) // Exit the game return 1; keyboardCode = Common::KEYCODE_INVALID; _vm->pauseEngine(false); mouseOn(); return 0; } // Player Menu - test for both buttons or the F10 key if (((button & CRS_MB_BOTH) == CRS_MB_BOTH) || (keyboardCode == Common::KEYCODE_F10)) { changeCursor(CURSOR_NORMAL); keyboardCode = Common::KEYCODE_INVALID; return (playerMenu(mouseX, mouseY)); } if (userWait) { // Check for left mouse button click or Space to end user waiting if ((keyboardCode == Common::KEYCODE_SPACE) || (button == CRS_MB_LEFT)) userWait = 0; keyboardCode = Common::KEYCODE_INVALID; return 0; } // Handle any changes in game speed if (_speedFlag) { if ((keyboardCode == Common::KEYCODE_KP_PLUS) && (_gameSpeed >= 30)) { _gameSpeed -= 10; keyboardCode = Common::KEYCODE_INVALID; } if ((keyboardCode == Common::KEYCODE_KP_MINUS) && (_gameSpeed <= 200)) { _gameSpeed += 10; keyboardCode = Common::KEYCODE_INVALID; } } if (!userEnabled) { return 0; } if ((currentActiveMenu != -1) && menuTable[currentActiveMenu]) { updateMenuMouse(mouseX, mouseY, menuTable[currentActiveMenu]); } if (dialogueEnabled) { if (menuDown || selectDown || linkedRelation) { closeAllMenu(); menuDown = 0; selectDown = 0; currentActiveMenu = -1; changeCursor(CURSOR_NORMAL); } if ((menuTable[0] == NULL) && (!buttonDown)) { int dialogFound = createDialog(dialogueOvl, dialogueObj, xdial, 0); if (menuTable[0]) { if (dialogFound) { currentActiveMenu = 0; } else { freeMenu(menuTable[0]); menuTable[0] = NULL; currentActiveMenu = -1; } } else { menuDown = 0; } } else { if ((button & CRS_MB_LEFT) && (buttonDown == 0)) { if (menuTable[0]) { callRelation(getSelectedEntryInMenu(menuTable[0]), dialogueObj); freeMenu(menuTable[0]); menuTable[0] = NULL; if (linkedMsgList) { ASSERT(0); // freeMsgList(linkedMsgList); } linkedMsgList = NULL; linkedRelation = NULL; changeCursor(CURSOR_NORMAL); currentActiveMenu = -1; } buttonDown = 1; } } } else if ((button & CRS_MB_LEFT) && (buttonDown == 0)) { // left click buttonDown = 1; // is there a relation if (linkedRelation) { // call sub relation when clicking on an object if (menuDown == 0) { if (menuTable[0]) { int objOvl; int objIdx; int objType; objType = findObject(mouseX, mouseY, &objOvl, &objIdx); if (objType != -1) { callSubRelation(linkedRelation, objOvl, objIdx); } freeMenu(menuTable[0]); menuTable[0] = NULL; } if (linkedMsgList) { // freeMsgList(linkedMsgList); } linkedMsgList = NULL; linkedRelation = NULL; changeCursor(CURSOR_NORMAL); } else { // call sub relation when clicking in inventory if (menuTable[0] && menuTable[1]) { menuElementSubStruct * p0 = getSelectedEntryInMenu(menuTable[1]); if (p0) callSubRelation(linkedRelation, p0->ovlIdx, p0->header); closeAllMenu(); changeCursor(CURSOR_NORMAL); } } selectDown = 0; menuDown = 0; } else { // manage click on object menu if (menuDown == 0) { // Handle left click on an object if (menuTable[0] == 0) { int objOvl; int objIdx; int objType; objType = findObject(mouseX, mouseY, &objOvl, &objIdx); if (objType != -1) { int relation = findRelation(objOvl, objIdx, mouseX, mouseY); if (menuTable[0]) { if (relation) { currentActiveMenu = 0; selectDown = 1; } else { // object has a name but no relation, just move the character freeMenu(menuTable[0]); menuTable[0] = NULL; aniX = mouseX; aniY = mouseY; animationStart = true; } } else { aniX = mouseX; aniY = mouseY; animationStart = true; } } else { // No object found, we move the character to the cursor aniX = mouseX; aniY = mouseY; animationStart = true; } } else { // handle click in menu if (menuTable[0]) { menuElementSubStruct *pMenuElementSub = getSelectedEntryInMenu(menuTable[0]); callRelation(pMenuElementSub, -1); // if there is a linked relation, close menu if (!linkedRelation) { freeMenu(menuTable[0]); menuTable[0] = NULL; changeCursor(CURSOR_NORMAL); } else { // else create the message for the linked relation char text[80]; strcpy(text, menuTable[0]->stringPtr); strcat(text, ":"); strcat(text, currentMenuElement->string); linkedMsgList = renderText(320, (const char *)text); changeCursor(CURSOR_CROSS); } } currentActiveMenu = -1; selectDown = 0; } } else { // Handle left click in inventory if (processInventory()) { currentActiveMenu = 0; selectDown = 1; menuDown = 0; } else { currentActiveMenu = -1; menuDown = 0; } } } } else if ((button & CRS_MB_RIGHT) || (keyboardCode == Common::KEYCODE_F9)) { if (buttonDown == 0) { keyboardCode = Common::KEYCODE_INVALID; // close object menu if there is no linked relation if ((linkedRelation == 0) && (menuTable[0])) { freeMenu(menuTable[0]); menuTable[0] = NULL; selectDown = 0; menuDown = 0; currentActiveMenu = -1; } if ((!selectDown) && (!menuDown) && (menuTable[1] == NULL)) { buildInventory(mouseX, mouseY); if (menuTable[1]) { currentActiveMenu = 1; menuDown = 1; } else { menuDown = 1; } } buttonDown = 1; } } return 0; }