コード例 #1
0
ファイル: CommandPanel.cpp プロジェクト: joaoamaral/k3chess
bool CommandPanel::processKey(Qt::Key key)
{
   switch(key)
   {
      case Qt::Key_Left:
         moveToPrevItem();
         break;
      case Qt::Key_Right:
         moveToNextItem();
         break;
      case Qt::Key_Select:
         selectOption(options_.idFromIndex(highlightedIndex_));
         break;
      default:
         if(useHotkeys_)
         {
            const CommandOption *option = options_.findItemByKey(key);
            if(option && option->isSelectable())
            {
               selectOption(option->id);
               break;
            }
         }
         return false;
   }
   //
   return true;
}
コード例 #2
0
ファイル: select.cpp プロジェクト: JickLee/Core
UIOptionLabel* UISelect::addOption(const std::string& name, UIAction* action, bool select_option) {
    UIOptionLabel* option = new UIOptionLabel(this, name, action);

    options_layout->addElement(option);

    if(select_option) selectOption(option);

    // if we have no selected option select option but dont submit
    if(!selected_option) selectOption(option, false);

    return option;
}
コード例 #3
0
ファイル: dialogplayer.cpp プロジェクト: Botje/residualvm
void DialogPlayer::buildOptions() {
	Resources::Dialog::TopicArray availableTopics = _currentDialog->listAvailableTopics();

	for (uint i = 0; i < availableTopics.size(); i++) {
		Option option;

		option._type = kOptionTypeAsk;
		option._topic = availableTopics[i];
		option._caption = availableTopics[i]->getCaption();
		option._replyIndex = availableTopics[i]->getNextReplyIndex();

		Resources::Dialog::Reply *reply = availableTopics[i]->getReply(option._replyIndex);
		if (reply->checkCondition()) {
			_options.push_back(option);
		}
	}

	if (_options.size() > 1) {
		removeLastOnlyOption();
	}

	if (_options.size() == 1) {
		// Only one option, just run it
		selectOption(0);
	} else {
		_optionsAvailable = true;
	}
}
コード例 #4
0
ファイル: CommandPanel.cpp プロジェクト: joaoamaral/k3chess
void CommandPanel::mouseReleaseEvent(QMouseEvent*)
{
   if(pressedIndex_<0) return;
   //
   QRect repaintRect = rects_[pressedIndex_];
   int id = options_.idFromIndex(pressedIndex_);
   if(id>0)
   {
      selectOption(id);
   }
   pressedIndex_ = -1;
   repaint(repaintRect);
}
コード例 #5
0
ファイル: MenuEndGame.cpp プロジェクト: TioMinho/CarMayhem
//Método principal para ativar a seleção do menu
void MenuEndRace::ativarSelecao(){
	selecaoMenu();

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return))
		selectOption();

	switch (numSelecao){
	case 1:
		optionPlay.setColor(sf::Color::White);
		optionQuit.setColor(sf::Color::Transparent);
		break;
	case 2:
		optionPlay.setColor(sf::Color::Transparent);
		optionQuit.setColor(sf::Color::White);
		break;
	}
}
コード例 #6
0
//Método principal para ativar a seleção com o menu aberto
void MenuPersonagens::ativarSelecao(){
	selecaoMenu();

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return))
		selectOption();

	switch (numSelecao){
	case 1:
		nomeCarro.setString("The Illuminatian");
		acelleration.setSize(sf::Vector2f(250, 30));
		topSpeed.setSize(sf::Vector2f(300, 30));
		ammonition.setSize(sf::Vector2f(50, 30));
		health.setSize(sf::Vector2f(100, 30));
		musicas.setString("Iron Maiden - The Trooper\n\nMetallica - Creeping Death\n\nJudas Priest - Electric Eye\n\nBlack Sabbath - Iron Man\n\nMotorhead - Ace of Spades\n\n");
		mostruario.setTexture("Resources/Sprites/theIlluminatian.png");
		mostruario.setTextureRect(4 * 47, 0, 47, 38);
		break;
	case 2:
		nomeCarro.setString("  Little Jack   ");
		acelleration.setSize(sf::Vector2f(200, 30));
		topSpeed.setSize(sf::Vector2f(200, 30));
		ammonition.setSize(sf::Vector2f(150, 30));
		health.setSize(sf::Vector2f(300, 30));
		musicas.setString("AC/DC - Highway to Hell\n\nVan Halen - Ain't Talking 'Bout Love\n\nKiss - Detroit Rock City\n\nBon Jovi - Living On a Prayer\n\nGuns'n Roses - Welcome To The Jungle\n\n");
		mostruario.setTexture("Resources/Sprites/littleJack.png");
		mostruario.setTextureRect(4 * 46, 0, 46, 31);
		break;
	case 3:
		nomeCarro.setString("  Liese Vicious ");
		acelleration.setSize(sf::Vector2f(50, 30));
		topSpeed.setSize(sf::Vector2f(100, 30));
		ammonition.setSize(sf::Vector2f(300, 30));
		health.setSize(sf::Vector2f(300, 30));
		musicas.setString("Misfits - Dig Up Her Bones\n\nRamones - Blitzkrieg Bop\n\nDead Kennedys - Holiday in Cambodia\n\nNirvana - Smells Like Teen Spirit\n\nJoan Jett - Bad Reputation\n\n");
		mostruario.setTexture("Resources/Sprites/lieseVicious.png");
		mostruario.setTextureRect(4 * 47, 0, 47, 27);
		break;
	}
}
コード例 #7
0
ファイル: Menu.cpp プロジェクト: LaughingCabbage/Asteroid
void Menu::parseMenuInput(){
    sf::Event evt;
    //Loop through all window events
    while(menuWindow->pollEvent(evt)){
        //request closing window
        if(evt.type == sf::Event::Closed){
            menuWindow->close();
        }
    }
    //restrict key selections to 0.5 per second
    if((sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) && (inputClock.getElapsedTime().asSeconds() > inputRate)){
        selectUp();
        inputClock.restart();
    }
    if((sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) && (inputClock.getElapsedTime().asSeconds() > inputRate)){
        selectDown();
        inputClock.restart();
    }

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::Return)){
        selectOption();
    }

}
コード例 #8
0
ファイル: MenuOptions.cpp プロジェクト: almacha/miceamaze
void MenuOptions::run() {
	buttons.push_back(Button(-0.8, -0.9, 1.6, 0.15, "OK"));
	const float textSizeFactor = 0.5;
	int i = 0;
	buttons.push_back(Button(-0.4, 0.4-0.2*i, 0.3, 0.10, "Fullscreen", textSizeFactor));
	buttons.push_back(Button(-0.0, 0.4-0.2*i, 0.3, 0.10, "Window", textSizeFactor));

	i=1;
	buttons.push_back(Button(-0.4, 0.4-0.2*i, 0.3, 0.10, "60 (low)", textSizeFactor));
	buttons.push_back(Button(-0.0, 0.4-0.2*i, 0.3, 0.10, "120 (normal)", textSizeFactor));
	buttons.push_back(Button(+0.4, 0.4-0.2*i, 0.3, 0.10, "MAX", textSizeFactor));

	i=2;
	buttons.push_back(Button(-0.4, 0.4-0.2*i, 0.3, 0.10, "Yes", textSizeFactor));
	buttons.push_back(Button(-0.0, 0.4-0.2*i, 0.3, 0.10, "No", textSizeFactor));

	i=3;
	buttons.push_back(Button(-0.4, 0.4-0.2*i, 0.3, 0.10, "Yes", textSizeFactor));
	buttons.push_back(Button(-0.0, 0.4-0.2*i, 0.3, 0.10, "No", textSizeFactor));

	//i=4;
	//buttons.push_back(Button(-0.4, 0.4-0.2*i, 0.3, 0.10, "Yes", textSizeFactor));
	//buttons.push_back(Button(-0.0, 0.4-0.2*i, 0.3, 0.10, "No", textSizeFactor));

	int pressedButton = -1;

	// place cursor at correct position
	cursor.setFromMouse();

	// Prepare rendering
	prepareRender();

	while (true) {
		if (initVideoCounter != Program::getInstance()->initVideoCounter) {
			// Video was reinitialized, so we need to resend display lists
			prepareRender();
		}

		// Rendering
		glClear(GL_COLOR_BUFFER_BIT);

		// Render fixed parts of the maze
		glCallList(fixedObjectsDisplayList);

		// show FPS counter
		Program::getInstance()->fps->renderInMenu();

		// which buttons are selected
		buttons[1].select(Program::getInstance()->fullscreen);
		buttons[2].select(!Program::getInstance()->fullscreen);
		buttons[3].select(Program::getInstance()->config.fpsBehaviour == -1);
		buttons[4].select(Program::getInstance()->config.fpsBehaviour == 0);
		buttons[5].select(Program::getInstance()->config.fpsBehaviour == 1);
		buttons[6].select(Program::getInstance()->config.showFPS);
		buttons[7].select(!Program::getInstance()->config.showFPS);
		buttons[8].select(Program::getInstance()->config.music);
		buttons[9].select(!Program::getInstance()->config.music);
		//buttons[10].select(Program::getInstance()->config.sound);
		//buttons[11].select(!Program::getInstance()->config.sound);

		// render buttons
		for (int b=0; b<(int) buttons.size(); b++) {
			glLoadIdentity();
			if (pressedButton == b) {
				buttons[b].render(2);
			} else {
				buttons[b].render(buttons[b].over(cursor.x, cursor.y));
			}
		}

		// render cursor
		cursor.render();

		SDL_GL_SwapBuffers();


		// Event handling
		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			Program::getInstance()->generalEventHandler(&event);
			switch (event.type) {
				case SDL_MOUSEMOTION:
					cursor.setFromWindowXY(event.motion.x, event.motion.y);
					break;
				case SDL_MOUSEBUTTONDOWN:
					if (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT) {
						for (int b=0; b<(int) buttons.size(); b++) {
							if (buttons[b].over(cursor.x, cursor.y)) {
								pressedButton = b;
							}
						}
					}
					break;
				case SDL_MOUSEBUTTONUP:
					if (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT) {
						if (pressedButton >= 0) {
							if (buttons[pressedButton].over(cursor.x, cursor.y)) {
								if (pressedButton == 0) {
									Program::getInstance()->scene = 0;
									return;
								} else {
									selectOption(pressedButton);
								}
							}
							pressedButton = -1;
						}
					}
					break;
				case SDL_KEYUP:
					if (event.key.keysym.sym == SDLK_ESCAPE) {
						Program::getInstance()->scene = 0;
						return;
					}
					break;
			}

		}

		// Count FPS and wait some time before rendering next frame
		Program::getInstance()->fps->waitInMenu();

	}
}
コード例 #9
0
ファイル: sceneMenu.cpp プロジェクト: bvk76/demos
void CSceneMenu::inputKey(char Key)
{
#ifdef _KINECT_
    if(iCurrentMenu == MENU_KINECT_INFO)
        sceneChange(SCENE_MATCH);
#endif

    switch(Key)
    {
    case KEY_ESC:

        switch(iCurrentMenu)
        {
        case MENU_MAIN:
            sceneChange(0);
            break;

        case MENU_PLAY:
            enterMenu(MENU_MAIN);
            break;

        case MENU_SETTINGS:
            enterMenu(MENU_MAIN);
            iSelectedOption = 1;
            break;

        case MENU_MULTIPLAYER:
            enterMenu(MENU_PLAY);
            iSelectedOption = 1;
            break;

        case MENU_MULTIPLAYER_SERVER:
            enterMenu(MENU_MULTIPLAYER);
            break;

        case MENU_MULTIPLAYER_CLIENT:
            enterMenu(MENU_MULTIPLAYER);
            iSelectedOption = 1;
            break;

        case MENU_SETTINGS_DIFFICULTY:
            enterMenu(MENU_SETTINGS);
            iSelectedOption = 5;
            break;

        case MENU_SETTINGS_KINECT:
            enterMenu(MENU_SETTINGS);
            iSelectedOption = 6;
            break;
        }

        break;
        
    case KEY_ENTER:

        selectOption(iSelectedOption);        

        break;

    case KEY_BACKSPACE:

        // port
        if((iCurrentMenu == MENU_MULTIPLAYER_SERVER && iSelectedOption == 0) ||
           (iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 1))
        {
            if(strlen(sPort) > 0)
                sPort[strlen(sPort) - 1] = '\0';

            sGlobal->iPort = (strlen(sPort) > 0)? atoi(sPort): 0;

            refreshSettings();        
        }

        // server IP
        else if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) > 0)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) - 1] = '\0';
                refreshSettings();
            }
        }

        break;

    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':

        // port
        if((iCurrentMenu == MENU_MULTIPLAYER_SERVER && iSelectedOption == 0) ||
           (iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 1))
        {
            if(strlen(sPort) < 5)
            {
                sPort[strlen(sPort) + 1] = '\0';
                sPort[strlen(sPort)] = Key;
                sGlobal->iPort = atoi(sPort);
                refreshSettings();
            }
        }

        // server IP
        else if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) < 15)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) + 1] = '\0';
                sGlobal->sIPServer[strlen(sGlobal->sIPServer)] = Key;
                refreshSettings();
            }
        }

        break;

    case -66:   // '.'
        
        // server IP
        if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) < 14)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) + 1] = '\0';
                sGlobal->sIPServer[strlen(sGlobal->sIPServer)] = '.';
                refreshSettings();
            }
        }
        
        break;
        
    case KEY_UP:

        iSelectedOption--;

        if(iSelectedOption < 0)
            iSelectedOption = iNumOptions - 1;

        break;
        
    case KEY_DOWN:

        iSelectedOption++;

        if(iSelectedOption == iNumOptions)
            iSelectedOption = 0;

        break;

    case KEY_LEFT:

        switch(iCurrentMenu)
        {
        // settings
        case MENU_SETTINGS:

            switch(iSelectedOption)
            {
            // goals to win
            case 0:
                if(sGlobal->iGameMaxGoals > 1)
                    sGlobal->iGameMaxGoals--;
                break;

            // maximum time
            case 1:
                if(sGlobal->iGameMaxMinutes > 1)
                    sGlobal->iGameMaxMinutes--;
                break;

            // table air
            case 2:
                sGlobal->bTableAir = !sGlobal->bTableAir;
                break;

            // automatic replay
            case 3:
                sGlobal->bAutomaticReplay = !sGlobal->bAutomaticReplay;
                break;

            // split screen
            case 4:
                sGlobal->bSplit = !sGlobal->bSplit;
                break;
            }

            break;

        // multiplayer
        case MENU_MULTIPLAYER:

            // play with kinect
            if(iSelectedOption == 2)
                sGlobal->bKinect = !sGlobal->bKinect;

            break;

        // AI difficulty settings
        case MENU_SETTINGS_DIFFICULTY:

            switch(iSelectedOption)
            {
            // speed for shooting
            case 0:
                if(iPercentShooting > 0)
                    iPercentShooting--;
                break;

            // speed for defending
            case 1:
                if(iPercentDefending > 0)
                    iPercentDefending--;
                break;

            // speed for clearing
            case 2:
                if(iPercentClearing > 0)
                    iPercentClearing--;
                break;

            // attack/defense balance
            case 3:
                if(iPercentAttack > 0)
                    iPercentAttack--;
                break;
            }

            calculateDifficultyValues();

            break;

        // kinect settings
        case MENU_SETTINGS_KINECT:

            switch(iSelectedOption)
            {
            // table width
            case 0:
                if(sGlobal->fKinectWidth > (KINECT_WIDTH_MIN / 2))
                    sGlobal->fKinectWidth -= 5.0f;
                break;

            // minimum distance
            case 1:
                if(sGlobal->fKinectMinimumDistance > KINECT_MINDIST_MIN)
                    sGlobal->fKinectMinimumDistance -= 10.0f;
                break;

            // maximum distance
            case 2:
                if(sGlobal->fKinectMaximumDistance > KINECT_MAXDIST_MIN)
                {
                    sGlobal->fKinectMaximumDistance -= 10.0f;

                    if(sGlobal->fKinectMaximumDistance < sGlobal->fKinectMinimumDistance)
                        sGlobal->fKinectMinimumDistance = sGlobal->fKinectMaximumDistance;
                }
                break;

            // player 1 hand
            case 3:
                sGlobal->bPlayer1RightHanded = !sGlobal->bPlayer1RightHanded;
                break;

            // player 2 hand
            case 4:
                sGlobal->bPlayer2RightHanded = !sGlobal->bPlayer2RightHanded;
                break;
            }

            break;
        }

        refreshSettings();

        break;

    case KEY_RIGHT:

        switch(iCurrentMenu)
        {
        // settings
        case MENU_SETTINGS:

            switch(iSelectedOption)
            {
            // goals to win
            case 0:
                if(sGlobal->iGameMaxGoals < GAME_MAX_GOALS)
                    sGlobal->iGameMaxGoals++;
                break;

            // maximum time
            case 1:
                if(sGlobal->iGameMaxMinutes < GAME_MAX_MINUTES)
                    sGlobal->iGameMaxMinutes++;
                break;

            // table air
            case 2:
                sGlobal->bTableAir = !sGlobal->bTableAir;
                break;

            // automatic replay
            case 3:
                sGlobal->bAutomaticReplay = !sGlobal->bAutomaticReplay;
                break;

            // split screen
            case 4:
                sGlobal->bSplit = !sGlobal->bSplit;
                break;
            }

            break;

        // multiplayer
        case MENU_MULTIPLAYER:

            // play with kinect
            if(iSelectedOption == 2)
                sGlobal->bKinect = !sGlobal->bKinect;

            break;

        // AI difficulty settings
        case MENU_SETTINGS_DIFFICULTY:

            switch(iSelectedOption)
            {
            // speed for shooting
            case 0:
                if(iPercentShooting < 100)
                    iPercentShooting++;
                break;

            // speed for defending
            case 1:
                if(iPercentDefending < 100)
                    iPercentDefending++;
                break;

            // speed for clearing
            case 2:
                if(iPercentClearing < 100)
                    iPercentClearing++;
                break;

            // attack/defense balance
            case 3:
                if(iPercentAttack < 100)
                    iPercentAttack++;
                break;
            }

            calculateDifficultyValues();

            break;

        // kinect settings
        case MENU_SETTINGS_KINECT:

            switch(iSelectedOption)
            {
            // table width
            case 0:
                if(sGlobal->fKinectWidth < (KINECT_WIDTH_MAX / 2))
                    sGlobal->fKinectWidth += 5.0f;
                break;

            // minimum distance
            case 1:
                if(sGlobal->fKinectMinimumDistance < KINECT_MINDIST_MAX)
                {
                    sGlobal->fKinectMinimumDistance += 10.0f;

                    if(sGlobal->fKinectMinimumDistance > sGlobal->fKinectMaximumDistance)
                        sGlobal->fKinectMaximumDistance = sGlobal->fKinectMinimumDistance;
                }
                break;

            // maximum distance
            case 2:
                if(sGlobal->fKinectMaximumDistance < KINECT_MAXDIST_MAX)
                    sGlobal->fKinectMaximumDistance += 10.0f;
                break;

            // player 1 hand
            case 3:
                sGlobal->bPlayer1RightHanded = !sGlobal->bPlayer1RightHanded;
                break;

            // player 2 hand
            case 4:
                sGlobal->bPlayer2RightHanded = !sGlobal->bPlayer2RightHanded;
                break;
            }

            break;
        }

        refreshSettings();

        break;
    }
}
コード例 #10
0
int main(){
	int piecePosition[2];
	int option;
	char piece;
	char lastPieceAdded;
	int lastPiecePosition[2];

	voidBoard();
	do{
		printBoard();
		option = selectOption();
		switch(option){
		case 1:
			printBoard();
			printf("Selecciona una ficha: Q (reina), K (rey), T (torre), B (alfil), H (caballo): ");
			while(getchar() != '\n');
			scanf("%c", &piece);

			//Change lowercase into uppercase (error control)
			if(piece > 'T'){
				piece -= ('a'-'A');
			}

			if(piece == 'Q' || piece == 'K' || piece == 'T' || piece == 'B' || piece == 'H'){
				printf("\nPosición para la ficha:\n");
				piecePosition[0] = intrPos("fila");
				piecePosition[1] = intrPos("columna");

				//Add piece and movements
				deleteMovs();
				addPieceAndMov(piece, piecePosition);
				lastPieceAdded = piece;
				lastPiecePosition[0] = piecePosition[0];
				lastPiecePosition[1] = piecePosition[1];

			}
			else{
				printf("\nNo has introducido una ficha válida.\n\n");
			}
			break;

		case 2:
			printf("\nPoner impedimento\n");
			deleteMovs();
			piecePosition[0] = intrPos("fila");
			piecePosition[1] = intrPos("columna");
			if(board[piecePosition[0]-1][piecePosition[1]-1] == EMPTY){
				board[piecePosition[0]-1][piecePosition[1]-1] = IMPEDIMENT;
				addPieceAndMov(lastPieceAdded, lastPiecePosition);
			}
			else{
				printf("Ya hay una ficha en esa posición\n\n");
			}
			break;
		case 3:
			voidBoard();
			break;
		case 4: printf("\nPrograma cerrado\n");break;
		default: printf("Opción no válida\n");
		}

	}while(option != 4);
}