コード例 #1
0
ファイル: animator.cpp プロジェクト: jchristi/ta3d
    bool Animator::doInitialize()
    {
        loadAreaFromTDF("Animator", "gui/animator.area");
        gfx->set_2D_mode();

        anim_data.load(nb_obj());

            // Initialize renderer
        getTexture();

        cam.pos.z = 10.0f;
        cam.pos.x = cam.pos.y = 0.0f;
        cam.dir.z = -1.0f;
        cam.dir.x = cam.dir.y = 0.0f;
        cam.setMatrix(Scale(1.0f));

        r1 = 0.0f, r2 = 0.0f, r3 = 0.0f;
        zoom = 0.1f;
        amx = mouse_x;
        amy = mouse_y;
        amz = mouse_z;
        sel_idx = -1;
        cursor_idx = -1;
        pointing_mode = ANIMATOR_MODE_SELECTION;

        renderModel();
        return true;
    }
コード例 #2
0
	bool Config::doInitialize()
	{
		LOG_DEBUG(LOG_PREFIX_MENU_MULTIMENU << "Entering...");

		// Loading the area
		loadAreaFromTDF("config", "gui/config.area");

		if (lp_CONFIG->restorestart)
		{
			lp_CONFIG->restorestart = false;
			lp_CONFIG->quickstart = false;
		}

		*saved_config = *lp_CONFIG;

		if (pArea->get_object("*.fps_limit") )
		{
			fps_limits = pArea->get_object("*.fps_limit")->Text;
			fps_limits.erase( fps_limits.begin());
		}
		else
		{
			fps_limits.push_back("50");
			fps_limits.push_back("60");
			fps_limits.push_back("70");
			fps_limits.push_back("80");
			fps_limits.push_back("90");
			fps_limits.push_back("100");
			fps_limits.push_back("no limit");
		}
		I18N::Translate(fps_limits);

		nb_res = 0;

		SDL_Rect **mode_list = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL);

		if (mode_list == (SDL_Rect**)0)         // No resolution available (normally this shouldn't be possible if we get here)
			nb_res = 0;
		else if (mode_list == (SDL_Rect**)-1)   // Ok, everything is possible so let's use standard sizes
		{
#define ADD_RES(w,h)  \
			res_bpp[nb_res++] = 16;\
			res_width[nb_res++] = w;\
			res_height[nb_res++] = h;\
			res_bpp[nb_res++] = 32;\
			res_width[nb_res++] = w;\
			res_height[nb_res++] = h;

			ADD_RES(640,480)
				ADD_RES(800,480)
				ADD_RES(800,600)
				ADD_RES(1024,768)
				ADD_RES(1024,600)
				ADD_RES(1280,960)
				ADD_RES(1280,1024)
				ADD_RES(1440,900)
				ADD_RES(1680,1050)
				ADD_RES(1600,1200)
				ADD_RES(1920,1200)
				ADD_RES(2560,1600)
		}
		else
		{
			for (unsigned int i = 0; mode_list[i] != NULL; ++i)
			{
				// Reference to the current SDL Rect
				const SDL_Rect& rect = *(mode_list[i]);

				if (rect.w >= 640 && rect.h >= 480)
				{
					# ifndef YUNI_OS_MAC
					if(SDL_VideoModeOK(rect.w, rect.h, 16, SDL_FULLSCREEN | SDL_OPENGL) == 16)
					{
						res_bpp[nb_res]    = 16;
						res_width[nb_res ] = rect.w;
						res_height[nb_res] = rect.h;
						++nb_res;
					}
					# endif
					if (SDL_VideoModeOK(rect.w, rect.h, 32, SDL_FULLSCREEN | SDL_OPENGL) == 32)
					{
						res_bpp[nb_res]    = 32;
						res_width[ nb_res] = rect.w;
						res_height[nb_res] = rect.h;
						++nb_res;
					}
				}
			}
		}

		pArea->set_state("*.showfps", lp_CONFIG->showfps);
		pArea->caption("*.fps_limit", fps_limits[fps_limits.size()-1]);
		for (String::Vector::const_iterator i = fps_limits.begin(); i != fps_limits.end(); ++i)
		{
			if ( (String() << (int)lp_CONFIG->fps_limit) == *i )
				pArea->caption("*.fps_limit", *i);
		}
		pArea->set_value("*.texture_quality", lp_CONFIG->unitTextureQuality);
		pArea->set_value("*.interface_transparency", int(lp_CONFIG->menuTransparency * 255.0f));
		pArea->set_value("*.shadow_map_size", lp_CONFIG->shadowmap_size);
		pArea->set_state("*.grab_inputs", lp_CONFIG->grab_inputs);
		pArea->set_value("*.sound_volume", lp_CONFIG->sound_volume);
		pArea->set_value("*.music_volume", lp_CONFIG->music_volume);
		pArea->set_state("*.far_sight", lp_CONFIG->far_sight);
		pArea->set_value("*.anisotropy", lp_CONFIG->anisotropy);
		pArea->set_value("*.mouse_sensitivity", (int)(lp_CONFIG->mouse_sensivity * 100.0f));
		pArea->set_state("*.disable_perspective", lp_CONFIG->ortho_camera);
		pArea->set_state("*.right_click_interface", lp_CONFIG->right_click_interface);
		pArea->set_state("*.disable_GLSL", lp_CONFIG->disable_GLSL);
		pArea->set_state("*.underwater_bright", lp_CONFIG->underwater_bright);
		pArea->set_state("*.use_texture_compression", lp_CONFIG->use_texture_compression);
		pArea->set_state("*.low_definition_map", lp_CONFIG->low_definition_map);
		pArea->set_state("*.sky", lp_CONFIG->render_sky);
		pArea->set_state("*.particle", lp_CONFIG->particle);
		pArea->set_state("*.explosion_particles", lp_CONFIG->explosion_particles);
		pArea->set_state("*.waves", lp_CONFIG->waves);
		pArea->set_state("*.height_line", lp_CONFIG->height_line);
		pArea->set_state("*.detail_tex", lp_CONFIG->detail_tex);
		pArea->set_state("*.use_texture_cache", lp_CONFIG->use_texture_cache);
		pArea->set_state("*.draw_console_loading", lp_CONFIG->draw_console_loading);
		pArea->set_state("*.fullscreen", lp_CONFIG->fullscreen);
		pArea->set_state("*.developer_mode", lp_CONFIG->developerMode);
		pArea->set_state("*.tool_tips", lp_CONFIG->tooltips);
		I18N::Instance()->retrieveAllLanguages(languageList);
		if (pArea->get_object("*.LANG"))
		{
			Gui::GUIOBJ::Ptr objLang = pArea->get_object("*.LANG");
			objLang->Text.clear();
			I18N::Language *l = I18N::Instance()->language(lp_CONFIG->Lang);
			if (l)
				objLang->Text.push_back(l->caption());
			else
				objLang->Text.push_back(lp_CONFIG->Lang);
			for (unsigned int i = 0; i < languageList.size(); i++)
				objLang->Text.push_back(languageList[i].caption());
		}
		if (pArea->get_object("*.camera_zoom") )
			pArea->caption( "*.camera_zoom", pArea->get_object("*.camera_zoom")->Text[1+lp_CONFIG->camera_zoom]);
		pArea->caption( "*.camera_def_angle", String() << lp_CONFIG->camera_def_angle );
		pArea->caption( "*.camera_def_h", String() << lp_CONFIG->camera_def_h );
		pArea->caption( "*.camera_zoom_speed", String() << lp_CONFIG->camera_zoom_speed );
		if (pArea->get_object("*.screenres") )
		{
			Gui::GUIOBJ::Ptr obj = pArea->get_object("*.screenres");
			obj->Text.clear();
			int current = 0;
			while( current < nb_res &&
				   ( res_width[ current ] != lp_CONFIG->screen_width
					 || res_height[ current ] != lp_CONFIG->screen_height
					 || res_bpp[ current ] != lp_CONFIG->color_depth ) )
				current++;
			if (current >= nb_res ) current = 0;
			obj->Text.push_back( String() << res_width[ current ] << "x" << res_height[ current ] << "x" << res_bpp[ current ] );
			for( int i = 0 ; i < nb_res ; i++ )
				obj->Text.push_back( String() << res_width[ i ] << "x" << res_height[ i ] << "x" << res_bpp[ i ] );
		}
		Gui::GUIOBJ::Ptr tmpO = pArea->get_object("*.shadow_quality");
		if (tmpO)
		{
			const unsigned int indx = 1 + Math::Max(0, Math::Min((int)lp_CONFIG->shadow_quality, 3));
			if (indx < tmpO->Text.size())
				pArea->caption("*.shadow_quality", tmpO->Text[indx]);
		}

		pArea->caption("*.timefactor", String() << (int)lp_CONFIG->timefactor);
		switch( lp_CONFIG->fsaa )
		{
			case 2: pArea->caption("*.fsaa", "x2");    break;
			case 4: pArea->caption("*.fsaa", "x4");    break;
			case 6: pArea->caption("*.fsaa", "x6");    break;
			case 8: pArea->caption("*.fsaa", "x8");    break;
			default: pArea->caption("*.fsaa", I18N::Translate("no fsaa"));
		}
		if (pArea->get_object("*.water_quality"))
		{
			Gui::GUIOBJ::Ptr obj = pArea->get_object("*.water_quality");
			pArea->caption("*.water_quality", obj->Text[1 + lp_CONFIG->water_quality]);
		}

		if (pArea->get_object("*.mod"))
		{
			Gui::GUIOBJ::Ptr obj = pArea->get_object("*.mod");

			if (obj->Text.size() >= 2)
				obj->Text[0] = obj->Text[1];
			else
				obj->Text.resize(1);

			String current_selection = TA3D_CURRENT_MOD.length() > 6 ? Substr(TA3D_CURRENT_MOD, 5, TA3D_CURRENT_MOD.length() - 6 ) : "";
			String::List mod_list = Mods::instance()->getModNameList(Mods::MOD_INSTALLED);
			mod_list.sort();
			mod_list.unique();
			for (String::List::iterator i = mod_list.begin() ; i != mod_list.end() ; ++i)
			{
				obj->Text.push_back( *i );
				if (ToLower( *i ) == ToLower(current_selection))
					obj->Text[0] = *i;
			}
		}

		pArea->caption("*.player_name", lp_CONFIG->player_name);

		if (pArea->get_object("*.skin"))
		{
			Gui::GUIOBJ::Ptr obj = pArea->get_object("*.skin");

			obj->Text.resize(1);
			obj->Text[0] = I18N::Translate( "default.skn");

			String::Vector skin_list;
			VFS::Instance()->getFilelist("gui\\*.skn", skin_list);

			String skin_name;
			const String::Vector::iterator end = skin_list.end();
			for (String::Vector::iterator i = skin_list.begin(); i != end; ++i)
			{
				skin_name = Paths::ExtractFileName(*i, false);
				obj->Text.push_back(skin_name);
				if (String("gui/") << ToLower(skin_name) == ToLower(lp_CONFIG->skin_name))
					obj->Text[0] = skin_name;
			}
		}

		if (pArea->get_object("*.l_files"))
		{
			Gui::GUIOBJ::Ptr obj = pArea->get_object("*.l_files");
			sound_manager->getPlayListFiles(obj->Text);
		}

		if (lp_CONFIG->quickstart)
			I_Msg( TA3D::TA3D_IM_GUI_MSG, "config_confirm.show");

		save = false;
		timer = msec_timer;

		return true;
	}