Exemple #1
0
void RegistLoop (double timestep ){
	int ww = param.x_resolution;
	int hh = param.y_resolution;
	Music.Update ();    
	check_gl_error();
    ClearRenderContext ();
    set_gl_options (GUI);
    SetupGuiDisplay ();
	TColor col;
		
	update_ui_snow (timestep);
	draw_ui_snow();

	Tex.Draw (BOTTOM_LEFT, 0, hh - 256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);
	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), scale);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top, 
//			0, colMBackgr, col, 0.2);

	FT.AutoSizeN (3);
	FT.SetColor (colWhite);
	int top = AutoYPosN (24);
	FT.DrawString (area.left, top, "Select your player name:");
	FT.DrawString (area.left + framewidth + arrowwidth, top, "Select a character:");

	FT.AutoSizeN (4);
	if (curr_focus == 0) col = colDYell; else col = colWhite;
	DrawFrameX (area.left, area.top, framewidth, frameheight, 3, colMBackgr, col, 1.0);
	FT.SetColor (col);
	FT.DrawString (area.left + 20, area.top, Players.GetName (curr_player));
	Tex.DrawDirectFrame (Players.GetAvatarID (curr_player), 
		area.left + 60, AutoYPosN (40), texsize, texsize, 3, colWhite);

	if (curr_focus == 1) col = colDYell; else col = colWhite;
	DrawFrameX (area.left + framewidth + arrowwidth, area.top, 
		framewidth, frameheight, 3, colMBackgr, col, 1.0);
	FT.SetColor (col);
	FT.DrawString (area.left + framewidth + arrowwidth + 20, 
		area.top, CharList[curr_character].name);
	Tex.DrawDirectFrame (CharList[curr_character].preview, 
		area.right - texsize - 60 - arrowwidth, 
		AutoYPosN (40), texsize, texsize, 3, colWhite);


	FT.SetColor (colWhite);
	PrintArrow (0, (curr_player > 0));	

	PrintArrow (1, (curr_player < last_player));
	PrintArrow (2, (curr_character > 0));	
	PrintArrow (3, (curr_character < last_character));

	PrintTextButton (0, curr_focus);
	PrintTextButton (1, curr_focus);

	if (param.ice_cursor) DrawCursor ();
    Winsys.SwapBuffers();
} 
void EventSelectLoop (double timestep) {
	int ww = param.x_resolution;
	int hh = param.y_resolution;
	TColor col;
		
	check_gl_error();
   	set_gl_options (GUI );
	Music.Update ();    
    ClearRenderContext ();
	SetupGuiDisplay ();

	if (param.ui_snow) {
		update_ui_snow (timestep);
		draw_ui_snow ();
	}

	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), param.scale);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);
	
//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top, 
//			0, colMBackgr, colBlack, 0.2);

	FT.AutoSizeN (3);
	FT.SetColor (colWhite);
	FT.DrawString (area.left, AutoYPosN (30), Trans.Text (6));
	FT.DrawString (area.left,AutoYPosN (45), Trans.Text (7));
	if (Events.IsUnlocked (curr_event, curr_cup) == false) {
		FT.SetColor (colLGrey);
 		FT.DrawString (CENTER, AutoYPosN (58), Trans.Text (10));
	}

	FT.AutoSizeN (4);

	if (curr_focus == 0) col = colDYell; else col = colWhite;
	DrawFrameX (area.left, frametop1, framewidth, frameheight, 3, colMBackgr, col, 1.0);
	FT.SetColor (colDYell);
	FT.DrawString (area.left + 20, frametop1, EventList[curr_event].name);

	if (curr_focus == 1) col = colDYell; else col = colWhite;
	DrawFrameX (area.left, frametop2, framewidth, frameheight, 3, colMBackgr, col, 1.0);
	if (Events.IsUnlocked (curr_event, curr_cup)) FT.SetColor (colDYell); 
		else FT.SetColor (colLGrey);
	FT.DrawString (area.left + 20, frametop2, Events.GetCupTrivialName (curr_event, curr_cup));

	PrintArrow (0, (curr_event > 0));	
	PrintArrow (1, (curr_event < last_event));
	PrintArrow (2, (curr_cup > 0));	
	PrintArrow (3, (curr_cup < last_cup));

	if (Events.IsUnlocked (curr_event, curr_cup)) PrintTextButton (0, curr_focus);
	PrintTextButton (1, curr_focus);

	if (param.ice_cursor) DrawCursor ();
    SDL_GL_SwapBuffers ();
}
void GameConfigLoop (double time_step) {
	int ww = param.x_resolution;
	int hh = param.y_resolution;

	Music.Update ();    
			
	check_gl_error();
	Music.Update ();    
    set_gl_options (GUI);
    ClearRenderContext ();
    SetupGuiDisplay ();
    
	if (param.ui_snow) {
		update_ui_snow (time_step);
		draw_ui_snow();
    }

	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), 1.0);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top, 
//			0, colMBackgr, colBlack, 0.2);

	FT.AutoSizeN (4);
	PrintCheckbox (0, curr_focus, curr_fullscreen);

	if (curr_focus == 1) FT.SetColor (colDYell); else FT.SetColor (colWhite);
	FT.DrawString (area.left, area.top + dd, Trans.Text(32));
	if (curr_focus == 2) FT.SetColor (colDYell); else FT.SetColor (colWhite);
	FT.DrawString (area.left, area.top + dd*2, Trans.Text(33));
	if (curr_focus == 3) FT.SetColor (colDYell); else FT.SetColor (colWhite);
	FT.DrawString (area.left, area.top + dd*3, Trans.Text(34));
	if (curr_focus == 4) FT.SetColor (colDYell); else FT.SetColor (colWhite);
	FT.DrawString (area.left, area.top + dd*4, Trans.Text(36));
	if (curr_focus == 5) FT.SetColor (colDYell); else FT.SetColor (colWhite);
	FT.DrawString (area.left, area.top + dd*5, Trans.Text(35));

	FT.SetColor (colWhite);
	FT.DrawString (area.left+240, area.top + dd, res_names[curr_res]);
	FT.DrawString (area.left+240, area.top + dd*2, Int_StrN (curr_mus_vol));
	FT.DrawString (area.left+240, area.top + dd*3, Int_StrN (curr_sound_vol));
	FT.DrawString (area.left+240, area.top + dd*4, Int_StrN (curr_detail_level));
	FT.DrawString (area.left+240, area.top + dd*5, LangList[curr_language].language);

	PrintArrow (0, (curr_res < (NUM_RESOLUTIONS-1)));
	PrintArrow (1, (curr_res > 0));	
	PrintArrow (2, (curr_mus_vol < 120));
	PrintArrow (3, (curr_mus_vol > 0));	
	PrintArrow (4, (curr_sound_vol < 120));
	PrintArrow (5, (curr_sound_vol > 0));	
	PrintArrow (6, (curr_detail_level < 3));
	PrintArrow (7, (curr_detail_level > 1));	
	PrintArrow (8, (curr_language > 0));	
 	PrintArrow (9, (curr_language < lastLang));
	
	PrintTextButton (0, curr_focus);
	PrintTextButton (1, curr_focus);

	#if defined (OS_WIN32_MINGW)
		if ((curr_res != prev_res || curr_fullscreen != prev_fullscreen) &&
		param.restart_on_res_change) {
			FT.SetColor (colDYell);
			FT.AutoSizeN (4);
			FT.DrawString (CENTER, AutoYPosN (68), "The video adjustments have changed,");
			FT.DrawString (CENTER, AutoYPosN (72), "You need to restart the game");
		} else {
			FT.SetColor (colLGrey);
			FT.AutoSizeN (3);
			FT.DrawString (CENTER, AutoYPosN (68), Trans.Text(41));
			FT.DrawString (CENTER, AutoYPosN (72), Trans.Text(42));
		}
	#else 
		FT.SetColor (colWhite);
		FT.AutoSizeN (3);
		FT.DrawString (CENTER, AutoYPosN (68), Trans.Text(41));
		FT.DrawString (CENTER, AutoYPosN (72), Trans.Text(42));
	#endif

	if (param.ice_cursor) DrawCursor ();
	Reshape (ww, hh);
	Winsys.SwapBuffers ();
}
Exemple #4
0
void main(int argc, char *argv[]){
	char keypress = START;
	int ch=0;
	int moves=0;
	char mc[10];

	set_graphics(VGA_320X200X256);

	PrintArrow(80, 105);

	do{	//Game loop
		PrintBorder();
		PrintMenu();
		keypress = (char)getch();

		if(keypress == QUIT){
			keypress = START;					//special condition so that it will not exit on Q press at menu
		}else if(keypress == UP || keypress == UP2){
			Erase(80, 120, 15, 15);
			PrintArrow(80, 105);
			ch = 0;
		}else if(keypress == DOWN || keypress == DOWN2){
			Erase(80, 100, 15, 15);
			PrintArrow(80, 125);
			ch = 1;
		}else if(keypress == ENTER || keypress == SPACE){
			switch(ch){
				case 0:
						EraseAll();
						NewGame(board);
						do{	//Inside-the-game loop
							PrintInstructions(180, 30);
							PrintBoard(30, 30);										//* Always prints update version of board at coordinates
							PrintBorder();														//* Always prints border
							sprintf(mc, "%d", moves);
							Erase(55, 175, 150, 15);
							write_text("Moves: ", 55, 175, WHITE, 0);
							write_text(mc, 120, 175, WHITE, 0);
							ShowHint();

							keypress=(char)getch();

							if(keypress == UP || keypress == UP2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == LEFT || keypress == LEFT2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == RIGHT || keypress == RIGHT2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == DOWN || keypress == DOWN2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == QUIT){
								Erase(55, 175, 150, 15);
								write_text("Really exit? Y/N", 55, 175, WHITE, 0);
								do{
									keypress=(char)getch();
									if(keypress == YES){
										moves = 0;
										keypress = QUIT;
										break;
									}else if(keypress == NO){
										keypress = YES;
										Erase(55, 175, 150, 15);
										break;
									}
								}while(1);
							}else{
								Erase(55, 175, 150, 15);
								write_text("Invalid button!", 55, 175, WHITE, 0);
							}
							if(CheckWin(board)){
								EraseAll();
								write_text("You win!", 125, 85, WHITE, 0);
								moves = 0;
								keypress = QUIT;
							}
						}while(keypress != QUIT);
						EraseAll();
						PrintArrow(80, 105);
						keypress = START;
						break;
				case 1: keypress = QUIT;
						break;
				default: break;
			}
		}
		
	}while(keypress != QUIT);
	
	set_graphics(VGA_TEXT80X25X16);
	clrscr();
}
Exemple #5
0
/* FIXME: Add a structured comment for the man page generate to
 * create the basic documentation on this routine, particularly 
 * since this routine only prints a subset of information by default */
int main(int argc, char *argv[])
{
    RLOG_IOStruct *pInput;
    RLOG_FILE_HEADER header;
    int num_levels;
    int num_states;
    int num_arrows;
    int num_events;
    int total_num_events = 0;
    int i, j, k;
    unsigned int nMask = 0;
    int bSummary = 1;
    RLOG_STATE state;
    RLOG_EVENT event, lastevent;
    RLOG_ARROW arrow, lastarrow;
    int bFindEvent = 0;
    double dFindTime = 0.0;
    int bValidate = 0;
    int bValidateArrows = 0;
    int bOrder = 0;
    int bJumpCheck = 0;
    double dJump = 0.0;

    /* FIXME: This should also check for the GNU-standard --help, --usage,
     * and -h options.  */
    if (argc < 2)
    {
	/* FIXME: What is the default behavior with just an rlogfile? */
	printf("printrlog rlogfile [EVENTS | STATES | ARROWS | HEADER | COMM | ALL | SUMMARY ]\n");
	printf("printrlog rlogfile find endtime\n");
	printf("printrlog rlogfile validate\n");
	printf("printrlog rlogfile order\n");
	printf("printrlog rlogfile arroworder\n");
	return -1;
    }

    if (argc > 2)
    {
	nMask = 0;
	bSummary = 0;
	for (i=2; i<argc; i++)
	{
	    if (strcmp(argv[i], "EVENTS") == 0)
		nMask |= EVENT_BIT;
	    if (strcmp(argv[i], "STATES") == 0)
		nMask |= STATE_BIT;
	    if (strcmp(argv[i], "ARROWS") == 0)
		nMask |= ARROW_BIT;
	    if (strcmp(argv[i], "HEADER") == 0)
		nMask |= HEADER_BIT;
	    if (strcmp(argv[i], "COMM") == 0)
		nMask |= COMM_BIT;
	    if (strcmp(argv[i], "ALL") == 0)
		nMask = HEADER_BIT | STATE_BIT | COMM_BIT | ARROW_BIT | EVENT_BIT;
	    if (strcmp(argv[i], "SUMMARY") == 0)
	    {
		bSummary = 1;
		nMask = 0;
	    }
	    if (strcmp(argv[i], "find") == 0)
	    {
		bFindEvent = 1;
		dFindTime = atof(argv[i+1]);
	    }
	    if (strcmp(argv[i], "validate") == 0)
	    {
		bValidate = 1;
	    }
	    if (strcmp(argv[i], "order") == 0)
	    {
		bOrder = 1;
	    }
	    if (strcmp(argv[i], "arroworder") == 0)
	    {
		bValidateArrows = 1;
	    }
	    if (strcmp(argv[i], "jump") == 0)
	    {
		bJumpCheck = 1;
		if (argv[i+1])
		    dJump = atof(argv[i+1]);
	    }
	}
    }

    pInput = RLOG_CreateInputStruct(argv[1]);
    if (pInput == NULL)
    {
	printf("Error opening '%s'\n", argv[1]);
	return -1;
    }

    if (bValidateArrows)
    {
	num_arrows = RLOG_GetNumArrows(pInput);
	if (num_arrows)
	{
	    printf("num arrows: %d\n", num_arrows);
	    RLOG_GetNextArrow(pInput, &lastarrow);
	    if (lastarrow.start_time > lastarrow.end_time)
		printf("start > end: %g > %g\n", lastarrow.start_time, lastarrow.end_time);
	    while (RLOG_GetNextArrow(pInput, &arrow) == 0)
	    {
		if (arrow.start_time > arrow.end_time)
		    printf("start > end: %g > %g\n", arrow.start_time, arrow.end_time);
		if (arrow.end_time < lastarrow.end_time)
		    printf("arrows out of order: %d < %d\n", arrow.end_time, lastarrow.end_time);
		lastarrow = arrow;
	    }
	}
	RLOG_CloseInputStruct(&pInput);
	return 0;
    }

    if (bValidate)
    {
	num_arrows = RLOG_GetNumArrows(pInput);
	if (num_arrows)
	{
	    printf("num arrows: %d\n", num_arrows);
	    RLOG_GetNextArrow(pInput, &lastarrow);
	    if (lastarrow.start_time > lastarrow.end_time)
	    {
		printf("Error, arrows endtime before starttime: %g < %g\n", lastarrow.end_time, lastarrow.start_time);
		PrintArrow(&arrow);
	    }
	    while (RLOG_GetNextArrow(pInput, &arrow) == 0)
	    {
		if (lastarrow.end_time > arrow.end_time)
		{
		    printf("Error, arrows out of order: %g > %g\n", lastarrow.end_time, arrow.end_time);
		    PrintArrow(&lastarrow);
		    PrintArrow(&arrow);
		}
		if (arrow.start_time > arrow.end_time)
		{
		    printf("Error, arrows endtime before starttime: %g < %g\n", arrow.end_time, arrow.start_time);
		    PrintArrow(&arrow);
		}
		lastarrow = arrow;
	    }
	}
	for (j=pInput->header.nMinRank; j<=pInput->header.nMaxRank; j++)
	{
	    num_levels = RLOG_GetNumEventRecursions(pInput, j);
	    for (i=0; i<num_levels; i++)
	    {
		printf("Validating events in level %d:%d\n", j, i);
		if (RLOG_GetNextEvent(pInput, j, i, &event) == 0)
		{
		    if (event.end_time < event.start_time)
		    {
			printf("Error, event endtime before starttime: %g < %g\n", event.end_time, event.start_time);
		    }
		    lastevent = event;
		    while (RLOG_GetNextEvent(pInput, j, i, &event) == 0)
		    {
			if (lastevent.start_time > event.start_time)
			{
			    printf("Error, events out of order: %g > %g\n", lastevent.start_time, event.start_time);
			    PrintEvent(&lastevent);
			    PrintEvent(&event);
			}
			else if (lastevent.end_time > event.start_time)
			{
			    printf("Error, starttime before previous endtime: %g > %g\n", lastevent.end_time, event.start_time);
			    PrintEvent(&lastevent);
			    PrintEvent(&event);
			}
			if (event.end_time < event.start_time)
			{
			    printf("Error, event endtime before starttime: %g < %g\n", event.end_time, event.start_time);
			    PrintEvent(&event);
			}
			lastevent = event;
		    }
		}
	    }
	}
	RLOG_CloseInputStruct(&pInput);
	return 0;
    }

    if (bOrder)
    {
	int count = 0;
	if (RLOG_GetNextGlobalEvent(pInput, &event) != 0)
	{
	    RLOG_CloseInputStruct(&pInput);
	    return 0;
	}
	count++;
	lastevent = event;
	PrintEvent(&event);
	while (RLOG_GetNextGlobalEvent(pInput, &event) == 0)
	{
	    if (lastevent.start_time > event.start_time)
	    {
		printf("Error, events out of order: %g > %g\n", lastevent.start_time, event.start_time);
		PrintEvent(&lastevent);
		PrintEvent(&event);
	    }
	    if (event.end_time < event.start_time)
	    {
		printf("Error, event endtime before starttime: %g < %g\n", event.end_time, event.start_time);
		PrintEvent(&event);
	    }
	    lastevent = event;
	    PrintEvent(&event);
	    count++;
	}
	RLOG_CloseInputStruct(&pInput);
	printf("%d events traversed\n", count);
	return 0;
    }

    if (bFindEvent)
    {
	for (j=pInput->header.nMinRank; j<=pInput->header.nMaxRank; j++)
	{
	    printf("rank %d\n", j);
	    num_levels = RLOG_GetNumEventRecursions(pInput, j);
	    for (i=0; i<num_levels; i++)
	    {
		RLOG_FindEventBeforeTimestamp(pInput, j, i, dFindTime, &event, &k);
		PrintEventAndIndex(&event, k);
	    }
	}
	RLOG_CloseInputStruct(&pInput);
	return 0;
    }

    if (bJumpCheck)
    {
	printf("Start:\n");
	RLOG_FindGlobalEventBeforeTimestamp(pInput, dJump, &event);
	PrintEvent(&event);
	/*RLOG_PrintGlobalState(pInput);*/
	printf("Previous 10:\n");
	for (i=0; i<10; i++)
	{
	    RLOG_GetPreviousGlobalEvent(pInput, &event);
	    PrintEvent(&event);
	}
	printf("Start:\n");
	RLOG_FindGlobalEventBeforeTimestamp(pInput, dJump, &event);
	PrintEvent(&event);
	printf("Next 10:\n");
	for (i=0; i<10; i++)
	{
	    RLOG_GetNextGlobalEvent(pInput, &event);
	    PrintEvent(&event);
	}
	return 0;
    }

    if (RLOG_GetFileHeader(pInput, &header))
    {
	printf("unable to read the file header\n");
	RLOG_CloseInputStruct(&pInput);
	return -1;
    }
    if (nMask & HEADER_BIT || bSummary)
    {
	printf("min rank: %d\n", header.nMinRank);
	printf("max rank: %d\n", header.nMaxRank);
    }

    if (nMask & STATE_BIT || bSummary)
    {
	num_states = RLOG_GetNumStates(pInput);
	if (num_states)
	{
	    printf("num states: %d\n", num_states);
	    if (nMask & STATE_BIT)
	    {
		for (i=0; i<num_states; i++)
		{
		    RLOG_GetNextState(pInput, &state);
		    PrintState(&state);
		}
	    }
	}
    }

    if (nMask & ARROW_BIT || bSummary)
    {
	num_arrows = RLOG_GetNumArrows(pInput);
	if (num_arrows)
	{
	    printf("num arrows: %d\n", num_arrows);
	    if (nMask & ARROW_BIT)
	    {
		for (i=0; i<num_arrows; i++)
		{
		    RLOG_GetNextArrow(pInput, &arrow);
		    PrintArrow(&arrow);
		}
	    }
	}
    }

    if (nMask & EVENT_BIT || bSummary)
    {
	for (k=pInput->header.nMinRank; k<=pInput->header.nMaxRank; k++)
	{
	    total_num_events = 0;
	    num_levels = RLOG_GetNumEventRecursions(pInput, k);
	    if (num_levels > 0)
	    {
		printf("rank %d\n", k);
		printf("num event recursions: %d\n", num_levels);
		for (i=0; i<num_levels; i++)
		{
		    num_events = RLOG_GetNumEvents(pInput, k, i);
		    total_num_events += num_events;
		    printf(" level %d, num events: %d\n", i, num_events);
		    if (nMask & EVENT_BIT)
		    {
			for (j=0; j<num_events; j++)
			{
			    RLOG_GetNextEvent(pInput, k, i, &event);
			    PrintEvent(&event);
			}
		    }
		}
		printf("num events total: %d\n", total_num_events);
	    }
	}
    }

    RLOG_CloseInputStruct(&pInput);

    return 0;
}