Пример #1
0
void MainWindow::createActions(){
    // Allows the user to return to menu
    returnAct = new QAction(tr("&Back to Main Menu"), this);
    returnAct->setShortcut(tr("Ctrl+Z"));
    returnAct->setStatusTip(tr("Return to main menu"));
    connect(returnAct, SIGNAL(triggered()), this, SLOT(backToMainMenu()));

    // Allows the user to exit the game through the menu bar
    exitAct = new QAction(tr("&Exit Game"), this);
    exitAct->setShortcut(tr("Ctrl+Q"));
    exitAct->setStatusTip(tr("Exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    // Allows the user to see the About info about the application
    aboutAct = new QAction(tr("&About Game"), this);
    aboutAct->setStatusTip(tr("Show info about game"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutGame()));

    // Brings up a note dialog box
    noteAct = new QAction(tr("&Notes"), this);
    noteAct->setShortcut(tr("Ctrl+N"));
    noteAct->setStatusTip(tr("Create a note text file"));
    connect(noteAct, SIGNAL(triggered()), this, SLOT(takeNotes()));

    // Brings up global scores dialog box
    globalScoresAct = new QAction(tr("&Global Scores"), this);
    globalScoresAct->setShortcut(tr("Ctrl+V"));
    globalScoresAct->setStatusTip(tr("View Brick Breaker global high scores"));
    connect(globalScoresAct, SIGNAL(triggered()), this, SLOT(viewGlobalScores()));
}
Пример #2
0
/*Main menu*/
int mainTerminal()
{
    char opt1[] = "Identify";
    char opt2[] = "About";
    char opt3[] = "Exit";
    int posAct = 1;
    int input = 0;
    const short int posMin = 1;
    const short int posMax = 3;

    clearCommander(0);

    /*Repeating menu loop*/
    while (1 == 1)
    {
        silenceOn();
        /*Let the text be created! Every time!*/
        invardTextLineSlide(20, opt1);
        invardTextLineSlide(21, opt2);
        invardTextLineSlide(22, opt3);
        input = 0;
        /*Text appearance loop*/
        while (1 == 1)
        {
            if (input == KEY_UP)
            {
                posAct--;
            }
            else if (input == KEY_DOWN)
            {
                posAct++;
            }
            /*If ENTER is pressed, exit the loop*/
            else if (input == 10)
            {
                break;
            }
            /*In case if moved outside the min and max boundary*/
            if (posAct > posMax)
            {
                posAct = posMin;
            }
            else if (posAct < posMin)
            {
                posAct = posMax;
            }
            /*Change the text appearance*/
            switch(posAct)
            {
                case 1:
                    attron(A_REVERSE);
                    printCenter(20, opt1, 0);
                    attroff(A_REVERSE);
                    printCenter(21, opt2, 0);
                    printCenter(22, opt3, 0);
                    break;
                case 2:
                    printCenter(20, opt1, 0);
                    attron(A_REVERSE);
                    printCenter(21, opt2, 0);
                    attroff(A_REVERSE);
                    printCenter(22, opt3, 0);
                    break;
                case 3:
                    printCenter(20, opt1, 0);
                    printCenter(21, opt2, 0);
                    attron(A_REVERSE);
                    printCenter(22, opt3, 0);
                    attroff(A_REVERSE);
                    break;
            }
            /*Wait for input*/
            flushinp();
            input = getch();
        }
        switch (posAct)
        {
            case 1:
                /*If the player has successfully logged in*/
                if (identifyMenu() == TRUE)
                {
                    return 0;
                }
                /*If the player has created a new account or left that menu*/
                clearCommander(0);
                break;
            case 2:
                aboutGame();
                clearCommander(0);
                break;
            case 3:
                clearCommander(0);
                return EXIT;
                break;
        }
        /*Run this menu again*/
        continue;
    }
	return 0;
}