예제 #1
0
void CIwGameXmlNode::UpdateAttribute(CIwGameString& name, const char* value)
{
	CIwGameXmlAttribute* old_attribute = GetAttribute(name.c_str());

	if (old_attribute == NULL)
	{
		// Attribute was not present so add
		CIwGameXmlAttribute* attribute = CIwGameXmlParser::AllocAttribute();
		attribute->setName((char*)name.c_str(), name.GetLength());
		attribute->setValue((char*)value, strlen(value));
		Attributes.push_back(attribute);
	}
	else
	{
		// Attribute was present so update it
		old_attribute->setName((char*)name.c_str(), name.GetLength());
		old_attribute->setValue((char*)value, strlen(value));
	}
}
예제 #2
0
//
//
//
//	MobFox specific implementation
//
//
//
bool CIwGameAds::RequestAdMobFox()
{
	// Build request URI string
	RequestURI = "http://my.mobfox.com/request.php";

	CIwGameString body;
	CIwGameString urlencoded;

	body = "rt=api";
	body += "&u=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
	body += "&i=";
	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&o=";
	body += CIwGameString(UDID);
	body += "&m=live";
	body += "&s=";
	body += ApplicationID;
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
예제 #3
0
bool CIwGameImage::LoadFromXoml(IIwGameXomlResource* parent, bool load_children, CIwGameXmlNode* node)
{
	// Process image attributes
	CIwGameString* name = NULL;
	CIwGameString* location = NULL;
	bool preload = true;
	bool blocking = false;
	CIwGameString* condition = NULL;

	CIwGameScene* scene = NULL;
	if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Actor_Hash)
		scene = ((CIwGameActor*)parent)->getScene();
	else
	if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Scene_Hash)
		scene = (CIwGameScene*)parent;

	for (CIwGameXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++)
	{
		unsigned int name_hash = (*it)->getName().getHash();

		if (name_hash == CIwGameXomlNames::Name_Hash)
		{
			name = &(*it)->GetValue();
			setName(name->c_str());
		}
		else
		if (name_hash == CIwGameXomlNames::Tag_Hash)
			setTag((*it)->GetValue().c_str());
		else
		if (name_hash == CIwGameXomlNames::Location_Hash)
			location = &(*it)->GetValue();
		else
 		if (name_hash == CIwGameXomlNames::Preload_Hash)
			preload = (*it)->GetValueAsBool();
		else
 		if (name_hash == CIwGameXomlNames::Blocking_Hash)
			blocking = (*it)->GetValueAsBool();
		else
		if (name_hash == CIwGameXomlNames::Condition_Hash)
			condition = &(*it)->GetValue();
		else
		if (name_hash == CIwGameXomlNames::Format_Hash)
		{
			FormatSet = true;
			unsigned int format_hash = (*it)->GetValue().getHash();
			if (format_hash == IW_GAME_HASH("RGB_565"))
				Format = CIwImage::RGB_565;
			else
			if (format_hash == IW_GAME_HASH("RGBA_4444"))
				Format = CIwImage::RGBA_4444;
			else
			if (format_hash == IW_GAME_HASH("RGBA_5551"))
				Format = CIwImage::RGBA_5551;
			else
			if (format_hash == IW_GAME_HASH("RGB_888"))
				Format = CIwImage::RGB_888;
			else
			if (format_hash == IW_GAME_HASH("RGBA_6666"))
				Format = CIwImage::RGBA_6666;
			else
			if (format_hash == IW_GAME_HASH("RGB_332"))
				Format = CIwImage::RGB_332;
			else
			if (format_hash == IW_GAME_HASH("RGBA_8888"))
				Format = CIwImage::RGBA_8888;
			else
			{
				FormatSet = false;
				CIwGameError::LogError("Warning: Invalid texture format set - ", (*it)->GetValue().c_str());
			}
		}
		else
 		if (name_hash == CIwGameXomlNames::Filter_Hash)
			setFilter((*it)->GetValueAsBool());
	}

	if (location == NULL || name == NULL)
		CIwGameError::LogError("Warning: An Image requires a location and a name to be specified");

	if (condition != NULL)
	{
		// Find the condition variable
		bool condition_not = false;
		CIwGameXomlVariable* var = NULL;
		if (*(condition->c_str()) == '!')
		{
			condition_not = true;
			CIwGameString cond = condition->c_str() + 1;
			var = CIwGameXomlVariable::GetVariable(cond, scene);
		}
		else
			var = CIwGameXomlVariable::GetVariable(*condition, scene);
		if (var != NULL)
		{
			bool res = var->isTrue();
			if (condition_not)
				res = !res;
			if (!res)
			{
				IW_GAME_XOML->setExitOnError(false);
				return false;
			}
		}
#if defined (_DEBUG)
		else
			CIwGameError::LogError("Warning: condition variable not found - ", condition->c_str());
#endif // _DEBUG
	}

	if (location != NULL)
	{
		// Check to see if image is located externally
		if (CIwGameFile::isHttp(location->c_str(), location->GetLength()))
		{
			Init(location->c_str());
		}
		else
		if (CIwGameFile::isFile(location->c_str(), location->GetLength()))
		{
			Init(location->c_str());
		}
		else
		{
			// Find resource group
			CIwGameResourceGroup* group = NULL;
			if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Scene_Hash)
				group = (CIwGameResourceGroup*)scene->getResourceManager()->findResource(location->c_str(), CIwGameXomlNames::ResourceGroup_Hash);
			else
				group = (CIwGameResourceGroup*)IW_GAME_GLOBAL_RESOURCES->getResourceManager()->findResource(location->c_str(), CIwGameXomlNames::ResourceGroup_Hash);

			if (group != NULL)
				Init(name->c_str(), group->getResourceGroup());
			else
			{
				CIwGameError::LogError("Error: XOML - Invalid image resource group name - ", location->c_str());
				return false;
			}
		}
		if (preload)
		{
			Load(blocking);
		}
	}

	// If we are declared inside a scene then image is local to the scene
	if (scene != NULL)
		return scene->getResourceManager()->addResource(this);
	else
		return IW_GAME_GLOBAL_RESOURCES->getResourceManager()->addResource(this);

	return true;
}
예제 #4
0
//
//
//
//	ImMobi specific implementation
//
//
//
bool CIwGameAds::RequestAdInMobi()
{
	// Build M2M request URI string
	RequestURI = "http://w.inmobi.com/showad.asm";				// Live
//	RequestURI = "http://i.w.sandbox.inmobi.com/showad.asm";	// Test
    
    int slotSize = (int)SlotSize;

	CIwGameString body;
	CIwGameString urlencoded;

	body = "mk-siteid=";
	body += ApplicationID;
	body += "&mk-carrier=";
	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&h-user-agent=";
	urlencoded.URLEncode(UserAgent.c_str());
	urlencoded.ToLower();
	body += urlencoded;
	body += "&u-id=";
	body += CIwGameString(UDID);
	body += "&d-localization=";
	urlencoded.URLEncode(s3eDeviceGetString(S3E_DEVICE_LOCALE));
	urlencoded.ToLower();
	body += urlencoded;
//	body += "&d-netType=wifi";
	body += "&d-netType=carrier";
    body += "&mk-ad-slot=";
    body += CIwGameString(slotSize);
	body += "&mk-version=pr-SPEC-CTATA-20130111";
	if (UserAge != 0)
	{
		body += "&u-age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&u-gender=f";
		else
			body += "&u-gender=m";
	}
	if (!UserGPSLocation.IsEmpty())
	{
		body += "&u-latlong=";
		body += UserGPSLocation;
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&u-interests=";
		body += UserKeywords;
	}
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}
//	body.ToLower();

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("X-Mkhoj-SiteID", ApplicationID.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
예제 #5
0
bool CIwGameAds::RequestAdMadvertise()
{
	// Build M2M request URI string
	RequestURI = "http://ad.madvertise.de/site/";
	RequestURI += ApplicationID;

	CIwGameString body;
	CIwGameString urlencoded;

	body += "ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
//	body += "&ip=";
//	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&requester=madvertise_api";
	body += "&version=api_2.1";
	body += "&unique_device_id=";
	body += CIwGameString(UDID);
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}

/*	CIwGameString local = s3eDeviceGetString(S3E_DEVICE_LOCALE);
	int pos = local.Contains('_');
	if (pos >= 0)
	{
		// Strip language and underscore
		local.setString(local.c_str() + pos + 1, 2);
		local.ToUpper();
		body += "&country=";
		body += local;
	}*/

	if (UserAge != 0)
	{
		body += "&age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&gender=F";
		else
			body += "&gender=M";
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&keywords=";
		body += UserKeywords;
	}

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
예제 #6
0
void CIwGameString::Copy(CIwGameString& string)
{
	Copy((char *)string.c_str(), 0, string.GetLength());
}