Esempio n. 1
0
//---------- Begin of function Game::single_player_menu ----------//
//
void Game::single_player_menu()
{
	char optionFlag[5] = { 1, 1, 1, 1, 1, };

	mouse_cursor.set_icon(CURSOR_NORMAL);

	optionFlag[4] = select_run_scenario(1) > 0;		// 1 - count number of scenario

	{
		VgaFrontLock vgaLock;

		while(1)
		{
			if (!process_messages()) return;

			VgaFrontReLock vgaReLock;

			// -------- display ----------//

			vga.disp_image_file("M_main");

			// ------ display button ------//

			if( optionFlag[0] )
				font_thin_black.center_put_paragraph(
					BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2, 
					text_game_menu.str_training(), 0 );
			if( optionFlag[1] )
				font_thin_black.center_put_paragraph(
					BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, 
					text_game_menu.str_new_campaign(), 0 );
			if( optionFlag[2] )
				font_thin_black.center_put_paragraph(
					BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2, 
					text_game_menu.str_new_single_game(), 0 );
			if( optionFlag[3] )
				font_thin_black.center_put_paragraph(
					BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, 
					text_game_menu.str_load_game(), 0 );
			if( optionFlag[4] )
				font_thin_black.center_put_paragraph(
					BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2, 
					text_game_menu.str_load_scenario(), 0 );
			font_thin_black.center_put_paragraph(
				BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, 
				text_game_menu.str_cancel(), 0 );

                        vga.flip();

			sys.yield();
			mouse.get_event();
			if( config.music_flag )
			{
				if( !music.is_playing(3) )
					music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
			}
			else
			{
				music.stop();
			}
			// --------- detect -------//

			// detect training
			if( optionFlag[0] && mouse.single_click(BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.sav" );	// necessary to set the path and extension

				tutor.select_run_tutor(0);
				break;
			}

			// detect new campaign
			else if( optionFlag[1] && mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.sav" );	// necessary to set the path and extension

				run_campaign();
				break;
			}

			// detect new single game
			else if( optionFlag[2] && mouse.single_click( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.sav" );	// necessary to set the path and extension

				single_player_game(0);
				break;
			}

			// detect load game
			else if( optionFlag[3] && mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.sav" );	// necessary to set the path and extension

				// ##### begin Gilbert 20/1 #######//
				// if( game_file_array.menu(2) == 1)
				if( game_file_array.menu(3) == 1)
				// ##### begin Gilbert 20/1 #######//
				{
					battle.run_loaded();
					deinit_all();
				}
				{
					char signalExitFlagBackup = sys.signal_exit_flag;
					sys.signal_exit_flag = 2;
					game.deinit();   // game.deinit() is needed if game_file_array.menu fails
					sys.signal_exit_flag = signalExitFlagBackup;
				}
				break;
			}

			// run scenario
			else if( optionFlag[4] && mouse.single_click(BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.sav" );	// necessary to set the path and extension

				select_run_scenario();
				break;
			}

			// cancel
			else if( mouse.single_click(BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) )
			{
				break;
			}

		}	// end while
	}	// end scope of vgaLock
}
Esempio n. 2
0
//---------- Begin of function Game::single_player_menu ----------//
//
void Game::single_player_menu()
{
	int refreshFlag = SPOPTION_ALL;

#ifdef DEMO
	char optionFlag[5] = { 1, 0, 0, 1, 1, };
#else
	char optionFlag[5] = { 1, 1, 1, 1, 1, };
#endif

	mouse_cursor.set_icon(CURSOR_NORMAL);

#ifdef DISABLE_SINGLE_PLAYER_NEW_GAME
	optionFlag[1] = 0;		// disable new campaign
	optionFlag[2] = 0;		// disable new single game
#endif
	optionFlag[4] = select_run_scenario(1) > 0;		// 1 - count number of scenario

	{
		VgaFrontLock vgaLock;

		while(1)
		{
#if 0  // FIXME
			MSG msg;
			if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE))
			{
				if (!GetMessage( &msg, NULL, 0, 0))
				{
					sys.signal_exit_flag = 1;
					// BUGHERE : vga_front is unlocked
					return;
				}
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				continue;
			}
			else if( sys.paused_flag || !sys.active_flag )
			{
				WaitMessage();
				continue;
			}
#endif
			if( sys.need_redraw_flag )
			{
				refreshFlag = SPOPTION_ALL;
				sys.need_redraw_flag = 0;
			}

			VgaFrontReLock vgaReLock;

			// -------- display ----------//

			if( refreshFlag )
			{
				if( refreshFlag & SPOPTION_PAGE )
				{
					vga.use_back();
					vga_util.disp_image_file("M_MAIN");

					// ------ display button ------//

					if( optionFlag[0] )
						font_thin_black.center_put_paragraph(
							BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2, 
							text_game_menu.str_training(), 0 );
					if( optionFlag[1] )
						font_thin_black.center_put_paragraph(
							BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, 
							text_game_menu.str_new_campaign(), 0 );
					if( optionFlag[2] )
						font_thin_black.center_put_paragraph(
							BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2, 
							text_game_menu.str_new_single_game(), 0 );
					if( optionFlag[3] )
						font_thin_black.center_put_paragraph(
							BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, 
							text_game_menu.str_load_game(), 0 );
					if( optionFlag[4] )
						font_thin_black.center_put_paragraph(
							BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2, 
							text_game_menu.str_load_scenario(), 0 );
					font_thin_black.center_put_paragraph(
						BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, 
						text_game_menu.str_cancel(), 0 );

					vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 );
					vga.use_front();
				}

				refreshFlag = 0;
			}

			sys.blt_virtual_buf();		// blt the virtual front buffer to the screen
			sys.yield();
			mouse.get_event();
			if( config.music_flag )
			{
				if( !music.is_playing(3) )
					music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
			}
			else
			{
				music.stop();
			}
			// --------- detect -------//

			// detect training
			if( optionFlag[0] && mouse.single_click(BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" );	// necessary to set the path and extension

				tutor.select_run_tutor(0);
				break;
			}

			// detect new campaign
			else if( optionFlag[1] && mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" );	// necessary to set the path and extension

				run_campaign();
				break;
			}

			// detect new single game
			else if( optionFlag[2] && mouse.single_click( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" );	// necessary to set the path and extension

				single_player_game(0);
				break;
			}

			// detect load game
			else if( optionFlag[3] && mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" );	// necessary to set the path and extension

				// ##### begin Gilbert 20/1 #######//
				// if( game_file_array.menu(2) == 1)
				if( game_file_array.menu(3) == 1)
				// ##### begin Gilbert 20/1 #######//
				{
					battle.run_loaded();
					deinit_all();
				}
				{
					char signalExitFlagBackup = sys.signal_exit_flag;
					sys.signal_exit_flag = 2;
					game.deinit();   // game.deinit() is needed if game_file_array.menu fails
					sys.signal_exit_flag = signalExitFlagBackup;
				}
				break;
			}

			// run scenario
			else if( optionFlag[4] && mouse.single_click(BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2) )
			{
				game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" );	// necessary to set the path and extension

				select_run_scenario();
				break;
			}

			// cancel
			else if( mouse.single_click(BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) )
			{
				break;
			}

		}	// end while
	}	// end scope of vgaLock
}