Пример #1
0
void menuDraw()
{
	int i;
	int drawPos = curMenu->menuDrawPos;

	if(curMenu == &mainMenu)
	{
		applySurface(screenWidth/2 - 56 , 5, gameLogoIMG, screen, NULL);
	}

	if(menuState == MENU_STATE_NORMAL)
	{
		for(i = 0; i < curMenu->count; i++)
		{
			int multipleChoiceIndex = curMenu->menuItems[i]->curMultipleChoiceIndex;
			dTextCentered(curMenu->menuItems[i]->text[multipleChoiceIndex], 0, 9 * i + drawPos);
		}
		dText(">", screenWidth / 2 - ((strlen(curMenu->menuItems[curMenu->selectedIndex]->text[0]) + 2) * 7) / 2, curMenu->selectedIndex * 9 + drawPos);
		dText("<", screenWidth / 2 + ((strlen(curMenu->menuItems[curMenu->selectedIndex]->text[0]) + 2) * 7) / 2 - 7, curMenu->selectedIndex * 9 + drawPos);
		//dText("*", 40, curMenu->selectedIndex * 9 + drawPos); // this is a quick hack and should be changed later
	}
	else if(menuState == MENU_STATE_REDEFINE_KEYS)
	{
		char *keyName[] = {"UP", "DOWN", "LEFT", "RIGHT", "ACTION", "JUMP", "OK", "BACK", "MENU"};
		char dialog[30];

		sprintf(dialog, "Press key for *%s*", keyName[remapCurKey]);
		dTextCentered(dialog, 0, screenHeight/2);
	}
}
Пример #2
0
void gameGuiDraw()
{
    char txtTime[50];

    snprintf(txtTime, 10, "%lu:%02lu:%02lu", gameTime/FPS/3600 > 99 ? 99 : gameTime/FPS/3600, gameTime/FPS/60%60, gameTime/FPS%60);

    if (gameOver && !stonesLeft)
    {
        if (enteringHiscore)
        {
            int i;
            int txtPositionY = SCREEN_H/2 - (gameFontRegular.h + gameFontRegular.leading)/2 * 8;
            int place;
            char txtHiscore[SCORE_NAME_LEN];
            char txtMessage[50];
            char txtMessage2[50];

            place = hiscoreCheckScore(&hiscoreEntry, &currentGameMode, &currentAlgorithm) + 1;

            strcpy(txtHiscore, hiscoreEntry.name);
            sprintf(txtMessage, "Your time of %s", txtTime);
            sprintf(txtMessage2, "gives you the %d%s place.", place, place == 1 ? "st" : (place == 2 ? "nd" : (place == 3 ? "rd" : "th")));

            dTextCentered(&gameFontRegular, "Congratulations!", txtPositionY, SHADOW_OUTLINE);
            dTextCentered(&gameFontRegular, txtMessage, txtPositionY + (gameFontRegular.h + gameFontRegular.leading) * 2, SHADOW_OUTLINE);
            dTextCentered(&gameFontRegular, txtMessage2, txtPositionY + (gameFontRegular.h + gameFontRegular.leading) * 3, SHADOW_OUTLINE);
            dTextCentered(&gameFontRegular, "Enter your initials:", txtPositionY + (gameFontRegular.h + gameFontRegular.leading) * 5, SHADOW_OUTLINE);

            dTextCentered(&gameFontRegular, txtHiscore, txtPositionY + (gameFontRegular.h + gameFontRegular.leading) * 7, SHADOW_OUTLINE);

            for (i = 0; i < SCORE_NAME_LEN - 1; ++i)
            {
                txtHiscore[i] = (i == scoreCursorPos) ? (hiscoreEntry.name[scoreCursorPos] == ' ' ? '_' : hiscoreEntry.name[scoreCursorPos]) : ' ';
            }
            txtHiscore[SCORE_NAME_LEN-1] = '\0';

            dTextCentered(&gameFontSelected, txtHiscore, txtPositionY + (gameFontSelected.h + gameFontSelected.leading) * 7, SHADOW_OUTLINE);
        }
        else
        {
            int txtPositionY = SCREEN_H/2 - (gameFontRegular.h + gameFontRegular.leading)/2 - (gameFontRegular.h + gameFontRegular.leading);
            char txtMessage[50];

            sprintf(txtMessage, "Your time: %s\n", txtTime);

            dTextCentered(&gameFontRegular, "Well done!", txtPositionY, SHADOW_OUTLINE);
            dTextCentered(&gameFontRegular, txtMessage, txtPositionY + (gameFontRegular.h + gameFontRegular.leading) * 2, SHADOW_OUTLINE);

            if (practice)
            {
                dTextCentered(&gameFontSelected, "Games in practice mode", txtPositionY + (gameFontSelected.h + gameFontSelected.leading) * 4, SHADOW_OUTLINE);
                dTextCentered(&gameFontSelected, "are excluded from score table!", txtPositionY + (gameFontSelected.h + gameFontSelected.leading) * 5, SHADOW_OUTLINE);
            }
        }
    }
    else
    {
        char txtStones[50];
        char txtGameOver[50];
        char txtBottomBar[100];

        sprintf(txtStones, "Stones Left: %d", stonesLeft);
        sprintf(txtBottomBar, "Time: %s  Stones Left: %d", txtTime, stonesLeft);

        strcpy(txtGameOver, "No moves left!");
        dTextCentered(&gameFontShadow, (gameOver && stonesLeft) ? txtGameOver : txtBottomBar, SCREEN_H - (gameFontShadow.h + gameFontShadow.leading), SHADOW_NONE);
    }
}