Beispiel #1
0
int DietWizardDialog::getNecessaryFlags() const
{
	bool need_ingredients = false;
	bool need_categories = false;
	for ( int meal = 0;meal < mealNumber;meal++ ) {
		int dishNo = ( ( MealInput* ) ( mealTabs->widget( meal ) ) ) ->dishNo();
		for ( int dish = 0;dish < dishNo;dish++ ) {
			if ( !need_categories ) {
				if ( categoryFiltering( meal, dish ) ) {
					need_categories = true;
				}
			}

			if ( !need_ingredients ) {
				ConstraintList constraints;
				loadConstraints( meal, dish, &constraints );
				for ( ConstraintList::const_iterator ct_it = constraints.constBegin(); ct_it != constraints.constEnd(); ++ct_it ) {
					if ( (*ct_it).enabled ) {
						need_ingredients = true;
						break;
					}
				}
			}

			if ( need_ingredients && need_categories )
				break;
		}

		if ( need_ingredients && need_categories )
			break;
	}

	kDebug()<<"Do we need to load ingredients: "<<need_ingredients;
	kDebug()<<"Do we need to load categories: "<<need_categories;

	int flags = 0;
	if ( need_ingredients ) flags |= RecipeDB::Ingredients;
	if ( need_categories ) flags |= RecipeDB::Categories;

	return flags;
}
Beispiel #2
0
bool DietWizardDialog::checkConstraints( Recipe &rec, int meal, int dish )
{
	// Check if the properties are within the constraints
	ConstraintList constraints;
	loadConstraints( meal, dish, &constraints ); //load the constraints

	bool any_enabled = false;
	for ( ConstraintList::const_iterator ct_it = constraints.constBegin(); ct_it != constraints.constEnd(); ++ct_it ) {
		if ( (*ct_it).enabled ) {
			any_enabled = true;
			break;
		}
	}
	if ( !any_enabled )
		return true;

	// Calculate properties of the recipe
	calculateProperties( rec, database );

	bool withinLimits = checkLimits( rec.properties, constraints );

	return ( withinLimits );
}
Beispiel #3
0
void gkGamePlayer::load(gkBlendFile* playerData)
{
	gkScene* dest = m_levelData->getLevel();
	gkScene* tscene = playerData->getMainScene();


	GK_ASSERT(
	    tscene->hasObject(GK_RESOURCE_PLAYER_SKEL) &&
	    tscene->hasObject(GK_RESOURCE_PLAYER_MESH) &&
	    tscene->hasObject(GK_RESOURCE_PLAYER_VIEW) &&
	    tscene->hasObject(GK_RESOURCE_PLAYER_ZROT) &&
	    tscene->hasObject(GK_RESOURCE_PLAYER_XROT) &&
	    tscene->hasObject(GK_RESOURCE_PLAYER_PHYS)
	);


	m_skeleton = tscene->getObject(GK_RESOURCE_PLAYER_SKEL)->getSkeleton();
	m_entity   = tscene->getObject(GK_RESOURCE_PLAYER_MESH)->getEntity();
	m_camera   = tscene->getObject(GK_RESOURCE_PLAYER_VIEW)->getCamera();
	m_zRot     = tscene->getObject(GK_RESOURCE_PLAYER_ZROT);
	m_xRot     = tscene->getObject(GK_RESOURCE_PLAYER_XROT);
	m_physics  = tscene->getObject(GK_RESOURCE_PLAYER_PHYS);

	m_playerData.setup(this);
	
	dest->addObject(m_skeleton);
	dest->addObject(m_entity);
	dest->addObject(m_camera);
	dest->addObject(m_zRot);
	dest->addObject(m_xRot);
	dest->addObject(m_physics);

	loadConstraints();
	loadAnimations();
	loadHuds();
}