コード例 #1
0
ファイル: MainMenu.c プロジェクト: jagt/brogue-chs-translate
void dialogAlert(char *message) {
	brogueButton OKButton;
	initializeButton(&OKButton);
	strcpy(OKButton.text, "     OK     ");
	OKButton.hotkey[0] = RETURN_KEY;
	OKButton.hotkey[1] = ENTER_KEY;
	OKButton.hotkey[2] = ACKNOWLEDGE_KEY;
	printTextBox(message, COLS/3, &white, &interfaceBoxColor, &OKButton, 1);
}
コード例 #2
0
ファイル: MainMenu.c プロジェクト: pdetagyos/Brogue-iPad
void dialogAlert(char *message) {
    cellDisplayBuffer rbuf[COLS][ROWS];
    
	brogueButton OKButton;
	initializeButton(&OKButton);
	strcpy(OKButton.text, "     OK     ");
	OKButton.hotkey[0] = RETURN_KEY;
	OKButton.hotkey[1] = ENTER_KEY;
	OKButton.hotkey[2] = ACKNOWLEDGE_KEY;
	printTextBox(message, COLS/3, ROWS/3, COLS/3, &white, &interfaceBoxColor, rbuf, &OKButton, 1);
    overlayDisplayBuffer(rbuf, NULL);
}
コード例 #3
0
ファイル: main.c プロジェクト: ChrisCooper/SPQR
void printScenarioOptions()
{
    static int firstTime = 1;
    static slider_t moneySlider;

     if (firstTime)
     {
         initializeSlider(&moneySlider, 493, 190, 442, 50, 4, 1, 700);
     }
    static MENUBUTTON forwardArrow;
    initializeButton(&forwardArrow, 920, 677, 57, 50, "Menu_Images/Forward Arrow.bmp");

    BITMAP *newBackground = makeBitmap("Menu_Images/Scenario Menu 01.bmp");

    draw_sprite(menuBuffer, newBackground, 0, 0);
    makeSlider(&moneySlider);

    if (menu_mouseIsOver(&forwardArrow))
           {
                 forwardArrow.picture = makeBitmap("Menu_Images/Forward ArrowH.bmp");
           }
           else if (!menu_mouseIsOver(&forwardArrow))
           {
               forwardArrow.picture = makeBitmap("Menu_Images/Forward Arrow.bmp");
           }

        if (mouse_b)
        {
             if (menu_mouseIsOver(&forwardArrow))
             {
                showAssignment();
               stop_sample(newAmbient);
               loadingPhase = 0;
               inGame = 1;
               initializeAllObjects();
               initializeMapSquares();
                SPQR_Game();
					emptyGame();
             }
        }
        draw_sprite(menuBuffer, forwardArrow.picture, forwardArrow.left, forwardArrow.top);
        firstTime = 0;
}
コード例 #4
0
ファイル: MainMenu.c プロジェクト: pdetagyos/Brogue-iPad
boolean dialogChooseFile(char *path, const char *suffix, const char *prompt) {
	short i, j, count, x, y, width, height, suffixLength, pathLength, maxPathLength, currentPageStart;
	brogueButton buttons[FILES_ON_PAGE_MAX + 2];
	fileEntry *files;
	boolean retval = false, again;
	cellDisplayBuffer dbuf[COLS][ROWS], rbuf[COLS][ROWS];
	color *dialogColor = &interfaceBoxColor;
	char *membuf;
	
	suffixLength = strlen(suffix);
	files = listFiles(&count, &membuf);
	copyDisplayBuffer(rbuf, displayBuffer);
	maxPathLength = strLenWithoutEscapes(prompt);
	
	// First, we want to filter the list by stripping out any filenames that do not end with suffix.
	// i is the entry we're testing, and j is the entry that we move it to if it qualifies.
	for (i=0, j=0; i<count; i++) {
		pathLength = strlen(files[i].path);
		//printf("\nString 1: %s", &(files[i].path[(max(0, pathLength - suffixLength))]));
		if (stringsExactlyMatch(&(files[i].path[(max(0, pathLength - suffixLength))]), suffix)) {
			
			// This file counts!
			if (i > j) {
				files[j] = files[i];
				//printf("\nMatching file: %s\twith date: %s", files[j].path, files[j].date);
			}
			j++;
			
			// Keep track of the longest length.
			if (min(pathLength, MAX_FILENAME_DISPLAY_LENGTH) + 10 > maxPathLength) {
				maxPathLength = min(pathLength, MAX_FILENAME_DISPLAY_LENGTH) + 10;
			}
		}
	}
	count = j;
	
	currentPageStart = 0;
	
	do { // Repeat to permit scrolling.
		again = false;
		
		for (i=0; i<min(count - currentPageStart, FILES_ON_PAGE_MAX); i++) {
			initializeButton(&(buttons[i]));
			buttons[i].flags &= ~(B_WIDE_CLICK_AREA | B_GRADIENT);
			buttons[i].buttonColor = *dialogColor;
            if (KEYBOARD_LABELS) {
                sprintf(buttons[i].text, "%c) ", 'a' + i);
            } else {
                buttons[i].text[0] = '\0';
            }
			strncat(buttons[i].text, files[currentPageStart+i].path, MAX_FILENAME_DISPLAY_LENGTH);
			
			// Clip off the file suffix from the button text.
			buttons[i].text[strlen(buttons[i].text) - suffixLength] = '\0'; // Snip!
			buttons[i].hotkey[0] = 'a' + i;
			buttons[i].hotkey[1] = 'A' + i;
			
			// Clip the filename length if necessary.
			if (strlen(buttons[i].text) > MAX_FILENAME_DISPLAY_LENGTH) {
				strcpy(&(buttons[i].text[MAX_FILENAME_DISPLAY_LENGTH - 3]), "...");
			}
			
			//printf("\nFound file: %s, with date: %s", files[currentPageStart+i].path, files[currentPageStart+i].date);
		}
		
		x = (COLS - maxPathLength) / 2;
		width = maxPathLength;
		height = min(count - currentPageStart, FILES_ON_PAGE_MAX) + 2;
		y = max(4, (ROWS - height) / 2);
		
		for (i=0; i<min(count - currentPageStart, FILES_ON_PAGE_MAX); i++) {
			pathLength = strlen(buttons[i].text);
			for (j=pathLength; j<(width - 8); j++) {
				buttons[i].text[j] = ' ';
			}
			buttons[i].text[j] = '\0';
			strcpy(&(buttons[i].text[j]), files[currentPageStart+i].date);
			buttons[i].x = x;
			buttons[i].y = y + 1 + i;
		}
		
		if (count > FILES_ON_PAGE_MAX) {
			// Create up and down arrows.
			initializeButton(&(buttons[i]));
			strcpy(buttons[i].text, "     *     ");
			buttons[i].symbol[0] = UP_ARROW_CHAR;
			if (currentPageStart <= 0) {
				buttons[i].flags &= ~(B_ENABLED | B_DRAW);
			} else {
				buttons[i].hotkey[0] = UP_ARROW;
				buttons[i].hotkey[1] = NUMPAD_8;
				buttons[i].hotkey[2] = PAGE_UP_KEY;
			}
			buttons[i].x = x + (width - 11)/2;
			buttons[i].y = y;
			
			i++;
			initializeButton(&(buttons[i]));
			strcpy(buttons[i].text, "     *     ");
			buttons[i].symbol[0] = DOWN_ARROW_CHAR;
			if (currentPageStart + FILES_ON_PAGE_MAX >= count) {
				buttons[i].flags &= ~(B_ENABLED | B_DRAW);
			} else {
				buttons[i].hotkey[0] = DOWN_ARROW;
				buttons[i].hotkey[1] = NUMPAD_2;
				buttons[i].hotkey[2] = PAGE_DOWN_KEY;
			}
			buttons[i].x = x + (width - 11)/2;
			buttons[i].y = y + i;
		}
		
		if (count) {
			clearDisplayBuffer(dbuf);
			printString(prompt, x, y - 1, &itemMessageColor, dialogColor, dbuf);
			rectangularShading(x - 1, y - 1, width + 1, height + 1, dialogColor, INTERFACE_OPACITY, dbuf);
			overlayDisplayBuffer(dbuf, NULL);
			
            //			for (j=0; j<min(count - currentPageStart, FILES_ON_PAGE_MAX); j++) {
            //				printf("\nSanity check BEFORE: %s, with date: %s", files[currentPageStart+j].path, files[currentPageStart+j].date);
            //				printf("\n   (button name)Sanity check BEFORE: %s", buttons[j].text);
            //			}
			
			i = buttonInputLoop(buttons,
								min(count - currentPageStart, FILES_ON_PAGE_MAX) + (count > FILES_ON_PAGE_MAX ? 2 : 0),
								x,
								y,
								width,
								height,
								NULL);
			
            //			for (j=0; j<min(count - currentPageStart, FILES_ON_PAGE_MAX); j++) {
            //				printf("\nSanity check AFTER: %s, with date: %s", files[currentPageStart+j].path, files[currentPageStart+j].date);
            //				printf("\n   (button name)Sanity check AFTER: %s", buttons[j].text);
            //			}
			
			overlayDisplayBuffer(rbuf, NULL);
			
			if (i < min(count - currentPageStart, FILES_ON_PAGE_MAX)) {
				if (i >= 0) {
					retval = true;
					strcpy(path, files[currentPageStart+i].path);
				} else { // i is -1
					retval = false;
				}
			} else if (i == min(count - currentPageStart, FILES_ON_PAGE_MAX)) { // Up arrow
				again = true;
				currentPageStart -= FILES_ON_PAGE_MAX;
			} else if (i == min(count - currentPageStart, FILES_ON_PAGE_MAX) + 1) { // Down arrow
				again = true;
				currentPageStart += FILES_ON_PAGE_MAX;
			}
		}
		
	} while (again);
	
	free(files);
	free(membuf);
	
	if (count == 0) {
		dialogAlert("No applicable files found.");
		return false;
	} else {
		return retval;
	}
}
コード例 #5
0
ファイル: MainMenu.c プロジェクト: pdetagyos/Brogue-iPad
void titleMenu() {
	signed short flames[COLS][(ROWS + MENU_FLAME_ROW_PADDING)][3]; // red, green and blue
	signed short colorSources[MENU_FLAME_COLOR_SOURCE_COUNT][4]; // red, green, blue, and rand, one for each color source (no more than MENU_FLAME_COLOR_SOURCE_COUNT).
	color *colors[COLS][(ROWS + MENU_FLAME_ROW_PADDING)];
	unsigned char mask[COLS][ROWS];
	boolean controlKeyWasDown = false;
	
	short i, b, x, y, button;
	buttonState state;
	brogueButton buttons[6];
	char whiteColorEscape[10] = "";
	char goldColorEscape[10] = "";
	char newGameText[100] = "", customNewGameText[100] = "";
	rogueEvent theEvent;
	enum NGCommands buttonCommands[6] = {NG_NEW_GAME, NG_OPEN_GAME, NG_VIEW_RECORDING, NG_HIGH_SCORES, NG_QUIT};
	
	cellDisplayBuffer shadowBuf[COLS][ROWS];
	
	// Initialize the RNG so the flames aren't always the same.
	
	seedRandomGenerator(0);
	
	// Empty nextGamePath and nextGameSeed so that the buttons don't try to load an old game path or seed.
	rogue.nextGamePath[0] = '\0';
	rogue.nextGameSeed = 0;
	
	// Initialize the title menu buttons.
	encodeMessageColor(whiteColorEscape, 0, &white);
    encodeMessageColor(goldColorEscape, 0, KEYBOARD_LABELS ? &itemMessageColor : &white);
	sprintf(newGameText, "      %sN%sew Game      ", goldColorEscape, whiteColorEscape);
	sprintf(customNewGameText, " %sN%sew Game (custom) ", goldColorEscape, whiteColorEscape);
	b = 0;
	button = -1;
	
	initializeButton(&(buttons[b]));
	strcpy(buttons[b].text, newGameText);
	buttons[b].hotkey[0] = 'n';
	buttons[b].hotkey[1] = 'N';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, "     %sO%spen Game      ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'o';
	buttons[b].hotkey[1] = 'O';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, "   %sV%siew Recording   ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'v';
	buttons[b].hotkey[1] = 'V';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, "    %sH%sigh Scores     ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'h';
	buttons[b].hotkey[1] = 'H';
	b++;
	
    // Seth:
/*	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, "        %sQ%suit        ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'q';
	buttons[b].hotkey[1] = 'Q';
	b++;*/
	
	x = COLS - 1 - 20 - 2;
	y = ROWS - 1;
	for (i = b-1; i >= 0; i--) {
		y -= 2;
		buttons[i].x = x;
		buttons[i].y = y;
		buttons[i].buttonColor = titleButtonColor;
		buttons[i].flags |= B_WIDE_CLICK_AREA;
	}
	
	blackOutScreen();
	clearDisplayBuffer(shadowBuf);
	initializeButtonState(&state, buttons, b, x, y, 20, b*2-1);
	rectangularShading(x, y, 20, b*2-1, &black, INTERFACE_OPACITY, shadowBuf);
	drawButtonsInState(&state);
    
	initializeMenuFlames(true, colors, colorSources, flames, mask);
    rogue.creaturesWillFlashThisTurn = false; // total unconscionable hack
	
	do {
		if (!controlKeyWasDown && controlKeyIsDown()) {
			strcpy(state.buttons[0].text, customNewGameText);
			drawButtonsInState(&state);
			buttonCommands[0] = NG_NEW_GAME_WITH_SEED;
			controlKeyWasDown = true;
		} else if (controlKeyWasDown && !controlKeyIsDown()) {
			strcpy(state.buttons[0].text, newGameText);
			drawButtonsInState(&state);
			buttonCommands[0] = NG_NEW_GAME;
			controlKeyWasDown = false;
		}
		
		// Update the display.
		updateMenuFlames(colors, colorSources, flames);
		drawMenuFlames(flames, mask);
		overlayDisplayBuffer(shadowBuf, NULL);
		overlayDisplayBuffer(state.dbuf, NULL);
		
		// Pause briefly.
		if (pauseBrogue(MENU_FLAME_UPDATE_DELAY)) {
			// There was input during the pause! Get the input.
			nextBrogueEvent(&theEvent, true, false, true);
			
			// Process the input.
			button = processButtonInput(&state, NULL, &theEvent);
		}
		
		// Revert the display.
		overlayDisplayBuffer(state.rbuf, NULL);
		
	} while (button == -1 && rogue.nextGame == NG_NOTHING);
	drawMenuFlames(flames, mask);
	if (button != -1) {
		rogue.nextGame = buttonCommands[button];
	}
}
コード例 #6
0
ファイル: MainMenu.c プロジェクト: jagt/brogue-chs-translate
boolean dialogChooseFile(char *path, const char *suffix, const char *prompt) {
	short i, j, count, x, y, width, height, suffixLength, pathLength, maxPathLength, currentPageStart;
	brogueButton buttons[FILES_ON_PAGE_MAX + 2];
	fileEntry *files;
	boolean retval = false, again;
	color *dialogColor = &interfaceBoxColor;
	char *membuf;
	
	suffixLength = strlen(suffix);
	files = listFiles(&count, &membuf);
//	copyDisplayBuffer(rbuf, displayBuffer);
	maxPathLength = strLenWithoutEscapes(prompt);
	
	// First, we want to filter the list by stripping out any filenames that do not end with suffix.
	// i is the entry we're testing, and j is the entry that we move it to if it qualifies.
	for (i=0, j=0; i<count; i++) {
		pathLength = strlen(files[i].path);
		//printf("\nString 1: %s", &(files[i].path[(max(0, pathLength - suffixLength))]));
		if (stringsExactlyMatch(&(files[i].path[(max(0, pathLength - suffixLength))]), suffix)) {
			
			// This file counts!
			if (i > j) {
				files[j] = files[i];
				//printf("\nMatching file: %s\twith date: %s", files[j].path, files[j].date);
			}
			j++;
			
			// Keep track of the longest length.
			if (min(pathLength, MAX_FILENAME_DISPLAY_LENGTH) + 10 > maxPathLength) {
				maxPathLength = min(pathLength, MAX_FILENAME_DISPLAY_LENGTH) + 10;
			}
		}
	}
	count = j;
	
	currentPageStart = 0;
	
	do { // Repeat to permit scrolling.
		again = false;
		
		for (i=0; i<min(count - currentPageStart, FILES_ON_PAGE_MAX); i++) {
			initializeButton(&(buttons[i]));
			buttons[i].flags &= ~(B_WIDE_CLICK_AREA | B_GRADIENT);
			buttons[i].buttonColor = *dialogColor;
			sprintf(buttons[i].text, "%c)\t", 'a' + i);
			strncat(buttons[i].text, files[currentPageStart+i].path, MAX_FILENAME_DISPLAY_LENGTH);
			
			// Clip off the file suffix from the button text.
			buttons[i].text[strlen(buttons[i].text) - suffixLength] = '\0'; // Snip!
			buttons[i].hotkey[0] = 'a' + i;
			buttons[i].hotkey[1] = 'A' + i;
			
			// Clip the filename length if necessary.
			if (strlen(buttons[i].text) > MAX_FILENAME_DISPLAY_LENGTH) {
				strcpy(&(buttons[i].text[MAX_FILENAME_DISPLAY_LENGTH - 3]), "...");
			}
			
			//printf("\nFound file: %s, with date: %s", files[currentPageStart+i].path, files[currentPageStart+i].date);
		}
		
		x = (COLS - maxPathLength) / 2;
		width = maxPathLength;
		height = min(count - currentPageStart, FILES_ON_PAGE_MAX) + 5;
		y = max(4, (ROWS - height) / 2);
		
		for (i=0; i<min(count - currentPageStart, FILES_ON_PAGE_MAX); i++) {
			strcat(buttons[i].text, "\t");
			strcat(buttons[i].text, files[currentPageStart+i].date);
			buttons[i].x = 1;
			buttons[i].y = 3 + i;
			buttons[i].width = width;
		}
		
		if (count > FILES_ON_PAGE_MAX) {

			// Create up and down arrows.
			initializeButton(&(buttons[i]));
			strcpy(buttons[i].text, "     *     ");
			buttons[i].symbol[0] = UP_ARROW_CHAR;
			if (currentPageStart <= 0) {
				buttons[i].flags &= ~(B_ENABLED | B_DRAW);
			} else {
				buttons[i].hotkey[0] = UP_ARROW;
				buttons[i].hotkey[1] = NUMPAD_8;
				buttons[i].hotkey[2] = PAGE_UP_KEY;
			}
			buttons[i].x = (width - 11)/2;
			buttons[i].y = 2;
			
			i++;
			initializeButton(&(buttons[i]));
			strcpy(buttons[i].text, "     *     ");
			buttons[i].symbol[0] = DOWN_ARROW_CHAR;
			if (currentPageStart + FILES_ON_PAGE_MAX >= count) {
				buttons[i].flags &= ~(B_ENABLED | B_DRAW);
			} else {
				buttons[i].hotkey[0] = DOWN_ARROW;
				buttons[i].hotkey[1] = NUMPAD_2;
				buttons[i].hotkey[2] = PAGE_DOWN_KEY;
			}
			buttons[i].x = (width - 11)/2;
			buttons[i].y = 2 + i;
		}
		
		if (count) {
			BROGUE_WINDOW *root, *window;
			BROGUE_DRAW_CONTEXT *context;
			BROGUE_EFFECT *effect;
			int tabStops[2] = { 3, width - 8 }; 

			root = ioGetRoot();
			window = BrogueWindow_open(
				root, (COLS - width) / 2, (ROWS - height) / 2, 
				width, height);
			context = BrogueDrawContext_open(window);
			effect = BrogueEffect_open(context, BUTTON_EFFECT_NAME);

			BrogueWindow_setColor(window, windowColor);
			BrogueDrawContext_enableProportionalFont(context, 1);
			BrogueDrawContext_setTabStops(context, 2, tabStops);

			BrogueDrawContext_drawAsciiString(context, 1, 1, prompt);

//			for (j=0; j<min(count - currentPageStart, FILES_ON_PAGE_MAX); j++) {
//				printf("\nSanity check BEFORE: %s, with date: %s", files[currentPageStart+j].path, files[currentPageStart+j].date);
//				printf("\n   (button name)Sanity check BEFORE: %s", buttons[j].text);
//			}
			
			i = buttonInputLoop(buttons,
								min(count - currentPageStart, FILES_ON_PAGE_MAX) + (count > FILES_ON_PAGE_MAX ? 2 : 0),
								context, 
								effect, 
								x,
								y,
								width,
								height,
								NULL); 

			BrogueWindow_close(window);
			
//			for (j=0; j<min(count - currentPageStart, FILES_ON_PAGE_MAX); j++) {
//				printf("\nSanity check AFTER: %s, with date: %s", files[currentPageStart+j].path, files[currentPageStart+j].date);
//				printf("\n   (button name)Sanity check AFTER: %s", buttons[j].text);
//			}

			if (i < min(count - currentPageStart, FILES_ON_PAGE_MAX)) {
				if (i >= 0) {
					retval = true;
					strcpy(path, files[currentPageStart+i].path);
				} else { // i is -1
					retval = false;
				}
			} else if (i == min(count - currentPageStart, FILES_ON_PAGE_MAX)) { // Up arrow
				again = true;
				currentPageStart -= FILES_ON_PAGE_MAX;
			} else if (i == min(count - currentPageStart, FILES_ON_PAGE_MAX) + 1) { // Down arrow
				again = true;
				currentPageStart += FILES_ON_PAGE_MAX;
			}
		}
		
	} while (again);
	
	free(files);
	free(membuf);
	
	if (count == 0) {
		dialogAlert("找不到合适的文件。");
		return false;
	} else {
		return retval;
	}
}
コード例 #7
0
ファイル: MainMenu.c プロジェクト: jagt/brogue-chs-translate
void titleMenu() {
	signed short flames[COLS][(ROWS + MENU_FLAME_ROW_PADDING)][3]; // red, green and blue
	signed short colorSources[MENU_FLAME_COLOR_SOURCE_COUNT][4]; // red, green, blue, and rand, one for each color source (no more than MENU_FLAME_COLOR_SOURCE_COUNT).
	color *colors[COLS][(ROWS + MENU_FLAME_ROW_PADDING)];
	unsigned char mask[COLS][ROWS];
	boolean controlKeyWasDown = false;
	
	short i, b, x, y, button;
	buttonState state;
	brogueButton buttons[6];
	char whiteColorEscape[10] = "";
	char goldColorEscape[10] = "";
	char newGameText[100] = "", customNewGameText[100] = "";
	rogueEvent theEvent;
	enum NGCommands buttonCommands[6] = {NG_NEW_GAME, NG_OPEN_GAME, NG_VIEW_RECORDING, NG_HIGH_SCORES, NG_QUIT};
	BROGUE_WINDOW *root, *window, *title_window, *button_window;
	BROGUE_DRAW_CONTEXT *context, *title_context, *button_context;
	BROGUE_EFFECT *button_effect;
	BROGUE_GRAPHIC *title_graphic;
	
	// Initialize the RNG so the flames aren't always the same.
	
	seedRandomGenerator(0);
	
	// Empty nextGamePath and nextGameSeed so that the buttons don't try to load an old game path or seed.
	rogue.nextGamePath[0] = '\0';
	rogue.nextGameSeed = 0;
	
	// Initialize the title menu buttons.
	encodeMessageColor(whiteColorEscape, 0, &white);
	encodeMessageColor(goldColorEscape, 0, &itemMessageColor);
	sprintf(newGameText, " %s(N)%s 开始新游戏", goldColorEscape, whiteColorEscape);
	sprintf(customNewGameText, " %s(N)%s 生成新游戏", goldColorEscape, whiteColorEscape);
	b = 0;
	button = -1;
	
	initializeButton(&(buttons[b]));
	strcpy(buttons[b].text, newGameText);
	buttons[b].hotkey[0] = 'n';
	buttons[b].hotkey[1] = 'N';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, " %s(O)%s 读取存档   ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'o';
	buttons[b].hotkey[1] = 'O';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, " %s(V)%s 观看录像   ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'v';
	buttons[b].hotkey[1] = 'V';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, " %s(H)%s 最高分      ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'h';
	buttons[b].hotkey[1] = 'H';
	b++;
	
	initializeButton(&(buttons[b]));
	sprintf(buttons[b].text, " %s(Q)%s 退出游戏   ", goldColorEscape, whiteColorEscape);
	buttons[b].hotkey[0] = 'q';
	buttons[b].hotkey[1] = 'Q';
	b++;
	
	x = COLS - 1 - 20 - 2;
	y = ROWS - 3;
	for (i = b-1; i >= 0; i--) {
		y -= 2;

		buttons[i].x = 1;
		buttons[i].y = 1 + 2 * i;
		buttons[i].buttonColor = interfaceButtonColor;
		buttons[i].flags |= B_WIDE_CLICK_AREA;
	}

	title_graphic = BrogueGraphic_open("svg/title.svg");

	root = ioGetRoot();
	window = BrogueWindow_open(root, 0, 0, COLS, ROWS);
	context = BrogueDrawContext_open(window);

	title_window = BrogueWindow_open(window, 0, 0, COLS, ROWS);
	title_context = BrogueDrawContext_open(title_window);
	if (title_graphic != NULL)
	{
		BrogueDrawContext_drawGraphic(title_context, 0, 0, COLS, ROWS, 
									  title_graphic);
	}

	button_window = BrogueWindow_open(window, x, y, 22, b * 2 + 1);
	BrogueWindow_setColor(button_window, windowColor);
	button_context = BrogueDrawContext_open(button_window);
	button_effect = BrogueEffect_open(button_context, BUTTON_EFFECT_NAME);
	
	blackOutScreen();
	initializeButtonState(&state, buttons, b, button_context, button_effect, 
						  x, y, 20, b*2-1);
	drawButtonsInState(button_context, button_effect, &state);

	initializeMenuFlames(true, colors, colorSources, flames, mask);
    rogue.creaturesWillFlashThisTurn = false; // total unconscionable hack
	
	do {
		if (!controlKeyWasDown && controlKeyIsDown()) {
			strcpy(state.buttons[0].text, customNewGameText);
			drawButtonsInState(button_context, button_effect, &state);
			buttonCommands[0] = NG_NEW_GAME_WITH_SEED;
			controlKeyWasDown = true;
		} else if (controlKeyWasDown && !controlKeyIsDown()) {
			strcpy(state.buttons[0].text, newGameText);
			drawButtonsInState(button_context, button_effect, &state);
			buttonCommands[0] = NG_NEW_GAME;
			controlKeyWasDown = false;
		}
		
		// Update the display.
		updateMenuFlames(colors, colorSources, flames);
		drawMenuFlames(context, flames);
		
		// Pause briefly.
		if (pauseBrogue(MENU_FLAME_UPDATE_DELAY)) {
			// There was input during the pause! Get the input.
			nextBrogueEvent(&theEvent, true, false, true);
			
			// Process the input.
			button = processButtonInput(button_context, button_effect, 
										&state, NULL, &theEvent);
		}
	} while (button == -1 && rogue.nextGame == NG_NOTHING);
	drawMenuFlames(context, flames);
	if (button != -1) {
		rogue.nextGame = buttonCommands[button];
	}

	BrogueWindow_close(window);
	BrogueGraphic_close(title_graphic);
}
コード例 #8
0
ファイル: main.c プロジェクト: ChrisCooper/SPQR
int main(int argc, char *argv[])
{
	allegInitializations();
	loadEssentials();

    int i = 0;

    MENUBUTTON aButton[5];
    initializeButton(&aButton[0], 359, 356, 305, 55, "Menu_Images/Check Box.bmp");
    initializeButton(&aButton[1], 359, 432, 305, 55, "Menu_Images/Check Box.bmp");
    initializeButton(&aButton[2], 359, 507, 305, 55, "Menu_Images/Check Box.bmp");
    initializeButton(&aButton[3], 359, 583, 305, 55, "Menu_Images/Check Box.bmp");
    initializeButton(&aButton[4], 359, 659, 305, 55, "Menu_Images/Check Box.bmp");

    int buttonClicked = 0;
    menuBuffer = create_bitmap(1024,768);
    BITMAP *menuBackground[7];
    menuBackground[0] = makeBitmap("Menu_Images/Menu Background 04.bmp");
    menuBackground[1] = makeBitmap("Menu_Images/Menu Background 05.bmp");
    menuBackground[2] = makeBitmap("Menu_Images/Menu Background 06.bmp");
    menuBackground[3] = makeBitmap("Menu_Images/Menu Background 07.bmp");
    menuBackground[4] = makeBitmap("Menu_Images/Menu Background 08.bmp");
    menuBackground[5] = makeBitmap("Menu_Images/Menu Background 09.bmp");
    menuBackground[6] = makeBitmap("Menu_Images/Menu Background 10.bmp");
    BITMAP *highlighter = makeBitmap("Menu_Images/Menu Selector.bmp"); // Load our picture
    BITMAP *mouse = makeBitmap("Menu_Images/Mouse.bmp"); // Load our picture
    BITMAP *mouseH = makeBitmap("Menu_Images/MouseH.bmp"); // Load our picture
    SAMPLE *menuClick[5];
    menuClick[0] = makeSample("Menu_Sounds/Menu Select 1.wav");
    menuClick[1] = makeSample("Menu_Sounds/Menu Select 2.wav");
    menuClick[2] = makeSample("Menu_Sounds/Menu Select 3.wav");
    menuClick[3] = makeSample("Menu_Sounds/Menu Select 4.wav");
    menuClick[4] = makeSample("Menu_Sounds/Menu Select 5.wav");
    double startTime = 0;
    SAMPLE *menuButtonClick[5];
    menuButtonClick[0] = makeSample("Menu_Sounds/New Game.wav");
    menuButtonClick[1] = makeSample("Menu_Sounds/Load Game.wav");
    menuButtonClick[2] = makeSample("Menu_Sounds/Options.wav");
    menuButtonClick[3] = makeSample("Menu_Sounds/Credits.wav");
    menuButtonClick[4] = makeSample("Menu_Sounds/Quit Game.wav");

    SAMPLE *menuAmbient = makeSample("Menu_Sounds/Menu Ambient.wav");

    int randomizer = 0;

    srand(time(0));

    showIntro();

    draw_sprite(menuBuffer, menuBackground[0], 0, 0);
    draw_sprite(menuBuffer, highlighter, 6, 186);
    blit(menuBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen
    play_sample(menuAmbient, 255, 0, 1000, 1);

    while (true)
    {
        if (fireCounter != fireCheck)
        {
           randomizer = rand() % 7;
				fireCheck = fireCounter;

        }
        draw_sprite(menuBuffer, menuBackground[randomizer], 0, 0);
        draw_sprite(menuBuffer, mouse, mouse_x, mouse_y);

        if (mouse_b)
        {
           draw_sprite(menuBuffer, mouseH, mouse_x, mouse_y);
           for (i = 0; i <= 4; i++)
               {
                  if (menu_mouseIsOver(&aButton[i]))
                  {
                     buttonClicked = i;
                  }
               }
          switch (buttonClicked)
          {
                 case 0:
                      play_sample(menuButtonClick[0], 200, 0, 1000, 0);
                      stop_sample(menuClick[randomizer]);
                      stop_sample(menuAmbient);
                      goToNewGameMenu();
                      play_sample(menuAmbient, 255, 0, 1000, 1);
                      buttonClicked = -1;
                 break;
                 case 1:
                      play_sample(menuButtonClick[1], 200, 0, 1000, 0);
                      //loadGame();
                 break;
                 case 2:
                      play_sample(menuButtonClick[2], 200, 0, 1000, 0);
                 break;
                 case 3:
                      play_sample(menuButtonClick[3], 50, 0, 1000, 0);
                 break;
                 case 4:
                      stop_sample(menuAmbient);
                      play_sample(menuButtonClick[4], 255, 0, 1000, 0);
                      startTime = time(0);
                      while (startTime + 4 > time(0))
                      {
                      }
                      return 0;
                 break;
                 default:
                         stop_sample(menuClick[randomizer]);
                         randomizer = rand() % 5;
                         play_sample(menuClick[randomizer], 255, 0, 500, 0);
                 break;
          }
        }
        else
        {
            buttonClicked = -1;
        }
        blit(menuBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen
        clear_bitmap(menuBuffer); // Clear the contents of the buffer bitmap

     }

}END_OF_MAIN()
コード例 #9
0
ファイル: main.c プロジェクト: ChrisCooper/SPQR
void printBattleOptions()
{

     static slider_t aBattleSlider[3];

     static int firstTime = 1;
     static int characterClicked = 0;
    static BITMAP *godNames[3];

     if (firstTime)
     {
         initializeSlider(&aBattleSlider[0], 493, 190, 442, 50, 4, 1, 700);
         initializeSlider(&aBattleSlider[1], 493, 315, 442, 50, 4, 1, 700);
         initializeSlider(&aBattleSlider[2], 493, 600, 442, 50, 4, 1, 700);
         firstTime = 0;

    godNames[0] = makeBitmap("Menu_Images/Jupiter Name.bmp");
    godNames[1] = makeBitmap("Menu_Images/Mars Name.bmp");
    godNames[2] = makeBitmap("Menu_Images/Neptune Name.bmp");
     }

    BITMAP *newBackground = makeBitmap("Menu_Images/Single Battle Menu 01.bmp");
    int i = 0;
    int j = 0;
    static MENUBUTTON forwardArrow;
    initializeButton(&forwardArrow, 920, 677, 57, 50, "Menu_Images/Forward Arrow.bmp");

    static MENUBUTTON aGod[3];
    initializeButton(&aGod[0], 475, 434, 129, 66, "Menu_Images/Zeus.bmp");
    initializeButton(&aGod[1], 649, 434, 129, 66, "Menu_Images/Mars.bmp");
    initializeButton(&aGod[2], 825, 434, 129, 66, "Menu_Images/Neptune.bmp");

    static SAMPLE *aGodSound[3];
    aGodSound[0] = makeSample("Menu_Sounds/Jupiter.wav");
    aGodSound[1] = makeSample("Menu_Sounds/Mars.wav");
    aGodSound[2] = makeSample("Menu_Sounds/Neptune.wav");

    draw_sprite(menuBuffer, newBackground, 0, 0);

     for(i = 0; i <= 2; i++)
     {
     makeSlider(&aBattleSlider[i]);
     }

     if (menu_mouseIsOver(&forwardArrow))
           {
                 forwardArrow.picture = makeBitmap("Menu_Images/Forward ArrowH.bmp");
           }
           else
           {
               forwardArrow.picture = makeBitmap("Menu_Images/Forward Arrow.bmp");
           }

        if (mouse_b)
        {
           for (i=0; i<=2; i++)
           {
                 if (menu_mouseIsOver(&aGod[i]))
                 {
                       characterClicked = i;
                       for (j=0; j<=2; j++)
                       {
                            stop_sample(aGodSound[i]);
                       }
                       play_sample(aGodSound[i], 155, 0, 1000, 0);
                 }
           }
             if (menu_mouseIsOver(&forwardArrow))
             {
                return;
             }
        }
        aGod[0].picture = makeBitmap("Menu_Images/Zeus.bmp");
        aGod[1].picture = makeBitmap("Menu_Images/Mars.bmp");
        aGod[2].picture = makeBitmap("Menu_Images/Neptune.bmp");
        switch(characterClicked)
        {
            case 0:
                 aGod[0].picture = makeBitmap("Menu_Images/ZeusH.bmp");
            break;
            case 1:
                 aGod[1].picture = makeBitmap("Menu_Images/MarsH.bmp");
            break;
            case 2:
                 aGod[2].picture = makeBitmap("Menu_Images/NeptuneH.bmp");
            break;
        }
        for (i=0; i<=2; i++)
        {
                 draw_sprite(menuBuffer, aGod[i].picture, aGod[i].left, aGod[i].top);
        }
        draw_sprite(menuBuffer, godNames[characterClicked], 616, 515);
        draw_sprite(menuBuffer, forwardArrow.picture, forwardArrow.left, forwardArrow.top);
}
コード例 #10
0
ファイル: main.c プロジェクト: ChrisCooper/SPQR
void printCampaignOptions()
{
     int i = 0;

    static int firstTime = 1;
    static int timeClicked = 0;
    static int sliderClicked = 1;

    BITMAP *check =  makeBitmap("Menu_Images/Checked Box.bmp");
    BITMAP *empty =  makeBitmap("Menu_Images/Check Box.bmp");

    static MENUBUTTON aSlider[3];


    static MENUBUTTON forwardArrow;


    static MENUBUTTON tutorial;

    BITMAP *newBackground = makeBitmap("Menu_Images/Campaign Menu 01.bmp");


   BITMAP *slider =  makeBitmap("Menu_Images/Slider.bmp");
   static BITMAP *difficulties[3];

   SAMPLE *slideNoise = makeSample("Menu_Sounds/SliderNoise.wav");

    if (firstTime)
    {
       initializeButton(&aSlider[0], 490, 180, 150, 50, "Menu_Images/Slider.bmp");
       initializeButton(&aSlider[1], 625, 180, 150, 50, "Menu_Images/Slider.bmp");
       initializeButton(&aSlider[2], 810, 180, 150, 50, "Menu_Images/Slider.bmp");
       initializeButton(&forwardArrow, 920, 677, 57, 50, "Menu_Images/Forward Arrow.bmp");
       initializeButton(&tutorial, 530, 340, 290, 46, "Menu_Images/Checked Box.bmp");
       difficulties[0] = makeBitmap("Menu_Images/Senator.bmp");
       difficulties[1] = makeBitmap("Menu_Images/Consul.bmp");
       difficulties[2] = makeBitmap("Menu_Images/Emperor.bmp");
    }

    draw_sprite(menuBuffer, newBackground, 0, 0);

    if (menu_mouseIsOver(&forwardArrow))
    {
                 forwardArrow.picture = makeBitmap("Menu_Images/Forward ArrowH.bmp");
    }
    else if (!menu_mouseIsOver(&forwardArrow))
    {
               forwardArrow.picture = makeBitmap("Menu_Images/Forward Arrow.bmp");
    }

    switch(sliderClicked)
    {
        case 0:
             draw_sprite(menuBuffer, slider, 498, 197);
             draw_sprite(menuBuffer, difficulties[0], 617, 255);
        break;
        case 1:
             draw_sprite(menuBuffer, slider, 700, 197);
             draw_sprite(menuBuffer, difficulties[1], 617, 255);
        break;
        case 2:
             draw_sprite(menuBuffer, slider, 913, 197);
             draw_sprite(menuBuffer, difficulties[2], 617, 255);
        break;
    }

        if (mouse_b)
        {
            for (i = 0; i <= 2; i++)
            {
                      if (menu_mouseIsOver(&aSlider[i]))
                      {
                         sliderClicked = i;
                         stop_sample(slideNoise);
                         play_sample(slideNoise, 155, 0, 1000, 0);
                         break;
                      }
             }
             if (menu_mouseIsOver(&forwardArrow))
             {
                return;
             }
             if (menu_mouseIsOver(&tutorial) && timeClicked < time(0))
             {
                timeClicked = time(0);
                if (tutorial.picture == empty)
                {
                   tutorial.picture = check;
                }
                else
                {
                    tutorial.picture = empty;
                }
             }
        }
        draw_sprite(menuBuffer, tutorial.picture, tutorial.left, tutorial.top);
        draw_sprite(menuBuffer, forwardArrow.picture, forwardArrow.left, forwardArrow.top);
        firstTime = 0;
}
コード例 #11
0
ファイル: main.c プロジェクト: ChrisCooper/SPQR
void goToNewGameMenu()
{
     int i = 0;
     int finishedSelecting = 0;

    BITMAP *check =  makeBitmap("Menu_Images/Checked Box.bmp");
    BITMAP *empty =  makeBitmap("Menu_Images/Check Box.bmp");

    MENUBUTTON aToggle[3];
           initializeButton(&aToggle[0], 65, 38, 314, 46, "Menu_Images/Check Box.bmp");
           initializeButton(&aToggle[1], 65, 111, 314, 46, "Menu_Images/Check Box.bmp");
           initializeButton(&aToggle[2], 65, 186, 314, 46, "Menu_Images/Check Box.bmp");

   MENUBUTTON backArrow;
       initializeButton(&backArrow, 10, 715, 50, 50, "Menu_Images/Back Arrow.bmp");


     int toggleClicked = -1;


     BITMAP *newBackground = makeBitmap("Menu_Images/New Game Initial.bmp");

     BITMAP *mouse =  makeBitmap("Menu_Images/Mouse.bmp");
     newAmbient = makeSample("Menu_Sounds/Battle Drums.wav");
     SAMPLE *toggleNoise = makeSample("Menu_Sounds/ToggleNoise.wav");

     play_sample(newAmbient, 100, 0, 1000, 1);

     while (1)
     {
           if (mouse_b)
           {
                for (i = 0; i <= 2; i++)
                {
                          if (menu_mouseIsOver(&aToggle[i]))
                          {
                             toggleClicked = i;
                             aToggle[i].picture = check;
                             stop_sample(toggleNoise);
                             play_sample(toggleNoise, 255, 0, 1000, 0);
                             finishedSelecting = 1;
                             //newBackground = load_bitmap("New Game Background 01.bmp", NULL);
                          }


                 }

                 if (menu_mouseIsOver(&backArrow))
                 {
                    stop_sample(newAmbient);
                    return;
                 }
           }
           for (i = 0; i <= 2; i++)
           {
               if (toggleClicked != i)
               {
                    aToggle[i].picture = empty;
               }
           }

           draw_sprite(menuBuffer, newBackground, 0, 0);

           if (finishedSelecting)
           {
               if (toggleClicked == 0)
               {
                  textprintf_centre_ex(menuBuffer, font, 500, 300, makecol(255, 255, 255), -1, "Not availible in the demo version!");
                  //printCampaignOptions();
               }
               if (toggleClicked == 1)
               {
                  printScenarioOptions();
               }
               if (toggleClicked == 2)
               {
                  textprintf_centre_ex(menuBuffer, font, 500, 300, makecol(255, 255, 255), -1, "Not availible in the demo version!");
                  //printBattleOptions();
               }
           }
           if (menu_mouseIsOver(&backArrow))
           {
                 backArrow.picture = makeBitmap("Menu_Images/Back ArrowH.bmp");
           }
           else
           {
               backArrow.picture = makeBitmap("Menu_Images/Back Arrow.bmp");
           }
           draw_sprite(menuBuffer, backArrow.picture, backArrow.left, backArrow.top);
           for (i = 0; i <= 2; i++)
           {
                draw_sprite(menuBuffer, aToggle[i].picture, aToggle[i].left, aToggle[i].top);
           }
           draw_sprite(menuBuffer, mouse, mouse_x, mouse_y);
           blit(menuBuffer, screen, 0,0,0,0,1024,768);
           clear_bitmap(menuBuffer);
     }
     stop_sample(newAmbient);
}