示例#1
0
void RegistInit (void) {  
	Winsys.ShowCursor (!param.ice_cursor);    
	init_ui_snow (); 
	Music.Play (param.menu_music, -1);

	scale = param.scale;
	framewidth = (int)(scale * 280);
	frameheight = (int)(scale * 50);
	arrowwidth = 50;
	sumwidth = framewidth * 2 + arrowwidth * 2;
	area = AutoAreaN (30, 80, sumwidth);
	texsize = 128 * scale;

	ResetWidgets ();
	AddArrow (area.left + framewidth + 8, area.top, 0, 0);
	AddArrow (area.left + framewidth + 8, area.top + 18, 1, 0);
	AddArrow (area.left + framewidth * 2 + arrowwidth + 8, area.top, 0, 1);
	AddArrow (area.left + framewidth * 2 + arrowwidth + 8, area.top + 18, 1, 1);
	int siz = FT.AutoSizeN (5);
	AddTextButton ("Enter", CENTER, AutoYPosN (62), 2, siz);
	AddTextButton ("Register a new player", CENTER, AutoYPosN (70), 3, siz);

	curr_focus = 0;
	g_game.loopdelay = 10;
	CharList = Char.CharList;
	last_character = Char.numCharacters - 1;
	last_player = Players.numPlayers - 1;
	if (g_game.prev_mode == NEWPLAYER && old_last != last_player) {
		curr_player = last_player; 
	} else curr_player = g_game.start_player;
}
示例#2
0
void GameConfigInit (void) {
	Winsys.ShowCursor (!param.ice_cursor);    
	Winsys.KeyRepeat (true);
	init_ui_snow (); 

	LangList = Trans.languages;
	lastLang = Trans.numLanguages - 1;

	SDL_Surface *surf = 0;
	surf = SDL_GetVideoSurface ();

	for (int i=0; i<NUM_RESOLUTIONS; i++) res_names[i] = Winsys.GetResName (i);
 
	paramchanged = false;

	// read the start params:
	curr_res = param.res_type;
	prev_res = param.res_type;
	curr_fullscreen = param.fullscreen;
	prev_fullscreen = param.fullscreen;
	curr_mus_vol = param.music_volume;
	curr_sound_vol = param.sound_volume;
	curr_detail_level = param.perf_level;
	curr_language = param.language;
	if (curr_language > lastLang) curr_language = lastLang;

	framewidth = 550 * param.scale;
	frameheight = 50 * param.scale;
	area = AutoAreaN (30, 80, framewidth);
	FT.AutoSizeN (4);
	dd = FT.AutoDistanceN (3);
	if (dd < 36) dd = 36;
	rightpos = area.right -48;

	ResetWidgets ();
	AddCheckbox (area.left, area.top, 0, framewidth-16, Trans.Text(31));
	AddArrow (rightpos, area.top+dd*1, 0, 1);
	AddArrow (rightpos, area.top+dd*1+18, 1, 1);
	AddArrow (rightpos, area.top+dd*2, 0, 2);
	AddArrow (rightpos, area.top+dd*2+18, 1, 2);
	AddArrow (rightpos, area.top+dd*3, 0, 3);
	AddArrow (rightpos, area.top+dd*3+18, 1, 3);
	AddArrow (rightpos, area.top+dd*4, 0, 4);
	AddArrow (rightpos, area.top+dd*4+18, 1, 4);
	AddArrow (rightpos, area.top+dd*5, 0, 5);
	AddArrow (rightpos, area.top+dd*5+18, 1, 5);	

	int siz = FT.AutoSizeN (5);
	AddTextButton (Trans.Text(28), area.left+50, AutoYPosN (80), 6, siz);
	double len = FT.GetTextWidth (Trans.Text(8));
	AddTextButton (Trans.Text(15), area.right-len-50, AutoYPosN (80), 7, siz);

	curr_focus = 0;
	Music.Play (param.config_music, -1);
}
static void GameSelectInit (void) {
	Winsys.ShowCursor (!param.ice_cursor);    
	init_ui_snow (); 
	scope = 0;
	
	ResetWidgets ();
	int top = AutoYPosN (40);
	int siz = FT.AutoSizeN (6);
	int dist = FT.AutoDistanceN (2);
	AddTextButton (Trans.Text(1), CENTER, top, 0, siz);
	AddTextButton (Trans.Text(2), CENTER, top + dist, 1, siz);
	AddTextButton (Trans.Text(3), CENTER, top + dist * 2, 2, siz);
	AddTextButton (Trans.Text(4), CENTER, top + dist * 5, 5, siz);
	AddTextButton (Trans.Text(43), CENTER, top + dist * 4, 4, siz);
	AddTextButton ("Highscore list", CENTER, top + dist * 3, 3, siz);
	AddTextButton (Trans.Text(5), CENTER, top + dist * 6, 6, siz);

	Music.Play (param.menu_music, -1);
	g_game.loopdelay = 10;
}
示例#4
0
void
reset_ui_snow( void ) {
    scalar_t xres, yres;
	int i;
    
    xres = getparam_x_resolution();
    yres = getparam_y_resolution();
    
    /* Kill off & regenerate particles */
    for (i=0; i<num_particles; i++) {
        particle_t *p = &particles[i];
        
                /* Delete the particle */
                *p = particles[num_particles-1];
                num_particles -= 1;
    }
    
    num_particles = orig_num_particles;
    
    init_ui_snow();
}
示例#5
0
int
main(int argc, char *argv[])
{
	try{ // used to catch all unhandled Errors and Assertions		
		// print copyright notice 
    	std::cout << "PlanetPenguin Racer " VERSION " -- http://racer.planetpenguin.de\n"
	    	<< "(c) 2004-2006 PlanetPenguin Racer team\n"
	    	<< "(c) 1999-2001 Jasmin F. Patry\n"
	    	<< "<*****@*****.**>\n"
	    	<< "PlanetPenguin Racer comes with ABSOLUTELY NO WARRANTY.\n"
	    	<< "This is free software,\nand you are welcome to redistribute it under certain conditions.\n"
	    	<< "See http://www.gnu.org/copyleft/gpl.html for details.\n" << std::endl;

		// initialize performance test if activated		
		ppogl::initPerftest();

		// set current directory to be used as base
		ppogl::os::setBaseDir();
				
		// set user directory to "~/.ppracer/"
		ppogl::os::setUserDir(ppogl::os::getHomeDir()+".ppracer/");
		
		// parse comandline options
		getopts(argc,argv);
			
		// set logging to be verbose if possible
		if(verbose){
			init_log();
			ppogl::Log::Instance()->setLevel(ppogl::LogUnknown);
			if(verbose>1){
				// set log system to print long messages
				ppogl::Log::Instance()->setVerbose(true);
				init_log();
			}
		}
				
    	// seed the random number generator
    	srand( time(NULL) );
	
	if(GameMode::exp_multiscreen==GameMode::MULTISCREEN_NONE){
		GameMgr::getInstance().numPlayers = 1;
	}else{
		GameMgr::getInstance().numPlayers = 2;
	}
	
	ppogl::Config::getInstance().init(&script,"ppconfig");
	
	register_cfile_callbacks();	
	
	bool create_cfile=true;
	
	if(cfile.empty()){
		cfile=get_config_file_name();
	}
		
	if( !resetConfig && ppogl::os::isFile(cfile) ){
		script.doFile(cfile);
		// check whether the user set the data directory per commandline option
		if(data_dir.empty()){
			data_dir = PPConfig.getString("data_dir");
		}
		PP_MESSAGE("Load config file");
		create_cfile=false;
	}else if(data_dir.empty()){
		data_dir = DATA_DIR;
	}

	if(ppogl::os::isDirectory(data_dir)==false){
		PP_ERROR("Unable to find data dir: " << data_dir <<"\n\tUse \"ppracer -d YOUR_DATA_DIRECTORY\"");
	}
	
	if(ppogl::os::isFile(data_dir+"/config.nut")==false){
		PP_ERROR("Unable to find needed file config.nut in the data dir: " << data_dir <<"\n\tUse \"ppracer -d YOUR_DATA_DIRECTORY\"");
	}
	
	script.doFile(data_dir+"/config.nut");

	PPConfig.setString("data_dir",data_dir);

	if(create_cfile){
		write_config_file();
	}	
	
    /* 
     * Initialize rendering context, create window
     */
    winsys_init(WINDOW_TITLE, WINDOW_TITLE);
	

    /* 
     * Initial OpenGL settings 
     */
    gl::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// init compiled_vertex extension
	gl::EXTcompiledVertexArrayInit();

	
    // print OpenGL debugging information
    if(verbose)	print_gl_info();

    /* 
     * Load the game data and initialize game state
     */

    register_key_frame_callbacks();
	Course::registerCallbacks();
	FogPlane::registerCallbacks();

	register_course_light_callbacks();
	
    PartSys::registerCallbacks();
    register_course_manager_callbacks();
	register_hier_callbacks();
    register_tux_callbacks();
	
	// init audio
	PP_MESSAGE("Init audio");	
	
	if(PPConfig.getBool("disable_audio")==false){
		bool stereo = PPConfig.getBool("audio_stereo");
		ppogl::AudioMgr::Format format;
		int freq;
		
		switch(PPConfig.getInt("audio_format_mode")){
			case 0:
				format = ppogl::AudioMgr::FORMAT_8;
				break;
			case 1:
				format = ppogl::AudioMgr::FORMAT_16;
				break;
			default:
				format = ppogl::AudioMgr::FORMAT_8;
		}

		switch(PPConfig.getInt("audio_freq_mode")){
			case 0:
				freq = ppogl::AudioMgr::FQ_11;
				break;
			case 1:
				freq = ppogl::AudioMgr::FQ_22;
				break;
			case 2:
				freq = ppogl::AudioMgr::FQ_44;
				break;
			default:
				freq = ppogl::AudioMgr::FQ_11;
		}
			
		ppogl::AudioMgr::getInstance().init(freq,format,stereo);
			
		if(PPConfig.getBool("sound_enabled")==false){
			ppogl::AudioMgr::getInstance().enableSound(false);
		}
		if(PPConfig.getBool("music_enabled")==false){
			ppogl::AudioMgr::getInstance().enableMusic(false);
		}
		
		// set volumes
		ppogl::AudioMgr::getInstance().setMusicVolume(
			PPConfig.getInt("music_volume"));
		ppogl::AudioMgr::getInstance().setSoundVolume(
			PPConfig.getInt("sound_volume"));		
	}
		
	PP_MESSAGE("Load translation: " << PPConfig.getString("ui_language"));
	// Setup translations
	script.doFile(data_dir+"/translations/languages.nut");	
	script.doFile(data_dir+"/translations/"+PPConfig.getString("ui_language")+".nut");		

	script.doFile(data_dir+"/init.nut");	

	// load "cached" configuration values
	GameConfig::update();

	fpsCounter.setMaxFPS(PPConfig.getInt("gui_max_fps"));
	
	PP_MESSAGE("Init joystick");
    GameMode::joystick.init();
		
	init_ui_snow();
  
	for(int i=0; i<GameMgr::getInstance().numPlayers; i++){
		// Placeholder name until we give players way to enter name
		players[i].name = "tux";
		players[i].loadData();
		players[i].num = i;
	}
	
    GameMode::mode = GameMode::NO_MODE;
	
	if(Benchmark::getMode()==Benchmark::NONE){
		GameMode::setMode(GameMode::SPLASH);

	}else{
		GameMode::setMode(GameMode::BENCHMARK);
	}
	
    GameMgr::getInstance().difficulty = CourseData::DIFFICULTY_NORMAL;
	
	SDL_ShowCursor(false);
	
	PP_MESSAGE("Entering event loop");
    winsys_process_events();
	
    return 0;
	
	}catch(ppogl::Error &e){
		/*
		 * It's possible that an exception is thrown outside of main.
		 * In most cases this is a problem with the object 
		 * destruction during program termination.
		 * If we see the abort message (see below) we known
		 * that the exception is thrown within main().
		 */
		std::cerr << "Aborting main function :(" << std::endl;	
		abort();
	}
}
示例#6
0
void SplashInit (void) {  
	Winsys.ShowCursor (!param.ice_cursor);    
	init_ui_snow (); 
	Music.Play (param.menu_music, -1);
	g_game.loopdelay = 10;
}