Ejemplo n.º 1
0
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
void FireEventForEachFileFound( const std::string& eventToFire, const std::string& directory, const std::string& searchPattern, bool recurseSubfolders )
{
    Strings files;
    EnumerateFiles( directory, searchPattern, files, recurseSubfolders );

    for (std::string& file : files)
    {
        std::string fileWithoutPath = ExtractFileNameFromPath( file );
        std::string fileName = RemoveFileExtension( fileWithoutPath );
        Strings fileNameTokens;
        Tokenize( fileWithoutPath, fileNameTokens, "." );
        std::string fileExtension = "." + fileNameTokens[1];
        std::string relativePath = ConvertBackSlashesToForwardSlashes( file );
        char fullPath[_MAX_PATH];
        _fullpath( fullPath, relativePath.c_str(), _MAX_PATH );
        std::string fullFilePath = ConvertBackSlashesToForwardSlashes( std::string( fullPath ) );

        ConsolePrintf( "File without path:  %s\n File Name: %s\n File Extension: %s\n File Relative: %s\n File Absolute: %s\n", fileWithoutPath.c_str(), fileName.c_str(), fileExtension.c_str(), relativePath.c_str(), fullFilePath.c_str() );

        NamedProperties props;
        props.Set( "FileName", fileWithoutPath );
        props.Set( "FileExtension", fileExtension );
        props.Set( "FileNameWithoutExtension", fileName );
        props.Set( "FileRelativePath", relativePath );
        props.Set( "FileAbsolutePath", fullFilePath );

        FireEvent( eventToFire, props );
    }
}
///-----------------------------------------------------------------------
///
///-----------------------------------------------------------------------
void ReportXMLDocumentUsage( XMLNode& xmlDocumentToReport, const ResourceStream& resourceStream, bool reportUsed )
{
	UNUSED( reportUsed );

	std::vector< XMLNode > unusedElements ;
	GetUnusedElements( xmlDocumentToReport, unusedElements );

	if ( !unusedElements.empty() )
	{
		std::string warningMessage = Stringf( "Unused elements in file: %s\n", resourceStream.GetJazzPath().c_str() );
		for ( std::vector< XMLNode >::iterator xmlNodeIter = unusedElements.begin(); xmlNodeIter != unusedElements.end(); ++xmlNodeIter )
		{
			XMLNode& unusedNode = (*xmlNodeIter);
			int stringSize = 0 ;
			char* nodeString = unusedNode.createXMLString( 1, &stringSize );
			if ( nodeString )
			{
				if ( stringSize > 2048 )
				{
					nodeString[ 2040 ] = '.' ;
					nodeString[ 2041 ] = '.' ;
					nodeString[ 2042 ] = '.' ;
					nodeString[ 2043 ] = 0 ;
				}
				delete nodeString ;
			}
		}

		NamedProperties warningProperties ;
		warningProperties.Set( "Warning", warningMessage );
//		FireEvent( "SystemWarningEvent", warningProperties );
	}

}
Ejemplo n.º 3
0
void BaseWidget::Update(double deltaSeconds) {
	
	//consider, not updating at all if hidden
	
	WidgetStateProperties& currentStateProperties = GetCurrentStateProperties();

	//calls this widget's update event
	std::string updateEventNameStr = "";
	currentStateProperties.GetProperty("updateEvent", updateEventNameStr);
	if (updateEventNameStr != "") {
		NamedProperties updateEventParams;
		updateEventParams.Set("widgetInstance", this);
		updateEventParams.Set("deltaSeconds", deltaSeconds);
		EventSystem::GetInstance().FireEvent(updateEventNameStr, updateEventParams);
	}

	ProcessInput(deltaSeconds);
	
	currentStateProperties.Update(deltaSeconds);

	//optimize: only update if it is rendering, or if it is dirty
	if (!m_isHidden) {
		UpdateRenderComponent(deltaSeconds);
		SetUICollider2DComponent();
	}
}
Ejemplo n.º 4
0
	void Font::renderText( const std::string& text, const mat4f& transformation, float fontHeight, const Color4f& color, const vec2f& relPos, bool drawWithShadow, bool fixedWidth )
	{
		
		Mesh* sMesh = nullptr;
		if( drawWithShadow )
		{
			sMesh = generateVertices( text, vec3f( -1.0f, -1.0f, -0.001f ), fontHeight, vec3f( 1.0f, 0.0f, 0.0f ), 
					vec3f( 0.0f, 1.0f, 0.0f ), color::FADEDBLACK, relPos, fixedWidth );
		}

		Mesh* mesh = generateVertices( text, vec3f(), fontHeight, vec3f( 1.0f, 0.0f, 0.0f ), 
				vec3f( 0.0f, 1.0f, 0.0f ), color, relPos, fixedWidth );

		Material* material = Material::getMaterial( mesh->getMaterial( 0 ) );
		material->updateUniform( "uFontHeight", fontHeight );
		//matStackf modelStack;
		//modelStack.translate( pos );
		NamedProperties params;
		params.set( "modelMatrix", transformation );
		params.set( "sMesh", sMesh );
		if( sMesh )
			fireEvent( "renderMesh", params );
		params.set( "mesh", mesh );
		fireEvent( "renderMesh", params );
			
		SAFE_DELETE( sMesh );
		SAFE_DELETE( mesh );
	}
Ejemplo n.º 5
0
void BaseWidget::Render(OpenGLRenderer* renderer) {
	
	if (m_isHidden)
		return;
	
	WidgetStateProperties& currentStateProperties = GetCurrentStateProperties();

	std::string renderEventNameStr = "";
	currentStateProperties.GetProperty("renderEvent", renderEventNameStr);
	if (renderEventNameStr != "") {
		NamedProperties renderEventParams;
		renderEventParams.Set("widgetInstance", this);
		EventSystem::GetInstance().FireEvent(renderEventNameStr, renderEventParams);
	}

	float myEdgeSize;
	currentStateProperties.GetProperty("edgeSize", myEdgeSize);

	renderer->SetModelLineWidth((int)myEdgeSize);

	//basic render component
	m_edgeRenderComponent.Render2D(renderer);

	m_renderComponent.Render2D(renderer);

	//draw debug collider
	//renderer->DrawMeshQuad(m_UIColliderComponent.GetBox2DCollider(), Rgba::GREEN);
}
Ejemplo n.º 6
0
	//-------------------------------------------------------------------
	void Object::setRotation( const mat3f& rot, int frame )
	{
		Node::setRotation( rot, frame );
		NamedProperties params;
		params.set( "orientation", rot );
		params.set( "name", m_occlusionGeometryName );
		fireEvent( "setOrientationOfASGeometry", params );
	}
Ejemplo n.º 7
0
	//-------------------------------------------------------------------
	void Object::setScale( const vec3f& scale, int frame )
	{
		Node::setScale( scale, frame );
		NamedProperties params;
		params.set( "scale", scale );
		params.set( "name", m_occlusionGeometryName );
		fireEvent( "setScaleOfASGeometry", params );
	}
Ejemplo n.º 8
0
	//-------------------------------------------------------------------
	void Object::setPosition( const vec3f& pos, int frame )
	{
		Node::setPosition( pos, frame );
		NamedProperties params;
		params.set( "pos", pos );
		params.set( "name", m_occlusionGeometryName );
		fireEvent( "setPosOfASGeometry", params );
	}
Ejemplo n.º 9
0
void ReverseBufferJob::callback()
{
	std::string eventName = "HashBufferJob Complete";
	NamedProperties data = NamedProperties();
	NamedProperties::NamedHelper<char*> bufferData;
	bufferData.val = &m_destinationBuffer;
	data.addProperty(eventName, &bufferData);
	fireEventGlobal(eventName);
}
Ejemplo n.º 10
0
	//-------------------------------------------------------------------
	void Object::render()
	{
		matStackf modelStack;
		modelStack.applyMatrix( getWorldTransformation() );
		NamedProperties params;
		params.set( "modelMatrix", modelStack.top() );
		params.set( "mesh", m_mesh );
		fireEvent( "renderMesh", params );
	}
Ejemplo n.º 11
0
void HashBufferJob::callback()
{
	std::string eventName = "HashBufferJob Complete";
	NamedProperties data = NamedProperties();
	NamedProperties::NamedHelper<int> bufferData;
	bufferData.val = &m_hash;
	data.addProperty(eventName, &bufferData);
	fireEventGlobal(eventName);
}
Ejemplo n.º 12
0
	void Button::Render()
	{
		NamedProperties params;
		matStackf modelStack;
		modelStack.loadIdentity();
		modelStack.translate( m_boundingBox.getCenter() );
		params.set( "modelMatrix", modelStack.top() );
		params.set( "mesh", m_mesh );
		fireEvent( "renderMesh", params );
		//consolePrintf( "Button box: %s", m_boundingBox.toString().c_str() );
	}
Ejemplo n.º 13
0
	//----------------------------------------------------------------------
	void Spaceship::fireBullet()
	{
		if( m_weaponTimer->isTimeUp() )
		{
			NamedProperties params;
			params.set( "pos", getPosition() );
			params.set( "rotation", m_rotation );
			params.set( "teamNumber", m_teamNumber );
			fireEvent( "SpawnBullet", params );
			m_weaponTimer->start();
		}
	}
Ejemplo n.º 14
0
	//----------------------------------------------------------------
	void Entity::renderOrders()
	{
		vec2f currentPos = m_position;
		for( size_t i = 0; i <  m_orders.size(); ++i )
		{
			Mesh* line = MeshFactory::generateLine( currentPos, m_orders[i]->getTargetLocation() );
			NamedProperties params;
			params.set( "mesh", line );
			fireEvent( "renderMesh", params );
			
			currentPos = m_orders[i]->getTargetLocation();
			SAFE_DELETE( line );
		}
	}
Ejemplo n.º 15
0
UISystem::UISystem() 
{
	//Read all styles and widgets 

	s_rootWidget = new GroupWidget();

	std::vector<std::string> out_styles;
	FindAllFilesOfType("Data/Styles/", "*", out_styles);

	for (auto it = out_styles.begin(); it != out_styles.end(); ++it) {
		std::string filePath = *it;
		ReadStyleFile(filePath);
	}

	std::vector<std::string> out_widgets;
	FindAllFilesOfType("Data/Widgets/", "*", out_widgets);

	for (auto it = out_widgets.begin(); it != out_widgets.end(); ++it) {
		std::string filePath = *it;
		ReadWidgetFile(filePath);
	}

	WidgetStyle wid;
	NamedProperties defaultProps;
	NamedProperties allProps;

	KeyFrameAnimation<RGBA> animColor;
	animColor.AddAnimationFrameAtParameter(RGBA(50, 255, 50, 255), 0.f);
	//defaultProps.Set("color", animColor);

	KeyFrameAnimation<Vec2> offsetAnim;
	offsetAnim.AddAnimationFrameAtParameter(Vec2(100.f, 500.f), 0.f);
	allProps.Set("offset", offsetAnim);

	KeyFrameAnimation<RGBA> animColor2;
	animColor2.AddAnimationFrameAtParameter(RGBA(255, 0, 0, 255), 0.f);
	allProps.Set("color", animColor2);

	wid.AddProperty(UI_STATE_DEFAULT, defaultProps);
	wid.AddGeneralProperty(allProps);
	WidgetBase* widget = AddStyledWidgetExplicitly("Button", "Default", wid, s_rootWidget);

	std::string name;
	widget->GetPropertyForCurrentState("name", name);

	//ToggleWidgetVisibility(name);
	ToggleWidgetEnabled(name);


}
Ejemplo n.º 16
0
	void Font::render3DText( const std::string& text, const vec3f& pos, float fontHeight, vec3f rasterDir, vec3f up, const Color4f& color, const vec2f& relPos, bool fixedWidth )
	{
		
		Mesh* mesh = generateVertices( text, pos, fontHeight, rasterDir, up, color, relPos, fixedWidth );

		matStackf modelStack;
		modelStack.translate( pos );
		NamedProperties params;
		params.set( "modelMatrix", modelStack.top() );
		params.set( "mesh", mesh );
		fireEvent( "renderMesh", params );

		SAFE_DELETE( mesh );
	}
Ejemplo n.º 17
0
	void MSMap::Render()
	{
		NamedProperties params;
		matStackf matStack;
		params.set( "mesh", m_platformMesh );

		for( int i = 0; i < m_platformRenderLocations.size(); ++i )
		{
			matStack.loadIdentity();
			m_platformRenderLocations[i].y = m_mapYPos;
			matStack.translate( m_platformRenderLocations[i] );
			params.set( "modelMatrix", matStack.top() );
			fireEvent( "renderMesh", params );
		}
	}
Ejemplo n.º 18
0
	SpaceGameActor::SpaceGameActor( const std::string& id, short teamNumber, int screenWidth, int screenHeight )
		:	Actor( id )
		,	SCREEN_WIDTH( screenWidth )
		,	SCREEN_HEIGHT( screenHeight )
		,	m_radius( 0.0f )
		,	IMPULSE_POWER( 100.0f )
		,	ROTATION_POWER( 5.0f )
		,	m_forwardImpulse( 0.0f )
		,	m_rotation( 0.0f )
		,	m_teamNumber( teamNumber )
		,	m_wasSpawnedLastFrame( true )
	{
		NamedProperties params;
		params.set( "SGA", this );
		fireEvent( "addSGAToCollisionMgr", params );
	}
Ejemplo n.º 19
0
	Object::Object( const std::string& id, Mesh* mesh )
		:	Node( id )
		,	m_mesh( mesh )
	{
		if( mesh != nullptr )
		{
			Material* mat = Material::getMaterial( m_mesh->getMaterial() );
			m_occlusionGeometryName = id + "asGeom";
			NamedProperties params;
			params.set( "name", m_occlusionGeometryName );
			params.set( "mesh", m_mesh );
			params.set( "directOcclusion", mat->getDirectOcclusion() );
			params.set( "reverbOcclusion", mat->getReverbOcclusion() );
			fireEvent( "createASGeometry", params );
		}
	}
Ejemplo n.º 20
0
	//-------------------------------------------------
	void RTSCamera::onMouseButtonDown( NamedProperties& params )
	{
		int keyCode;
		vec2i mouseCoords;
		
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			if( keyCode == GLUT_MIDDLE_BUTTON )
			{
				if( params.get( "screenCoords", mouseCoords ) == NamedProperties::SUCCESS )
					m_lastDragPos = mouseCoords;
								
				m_isDragging = true;
			}
		}
	}
Ejemplo n.º 21
0
	void CollisionSystem::AddNewActor(NamedProperties& np)
	{
		Actor* unit = NULL;

		np.Get("Actor", unit);
		m_registeredUnits.push_back(unit);
	}
Ejemplo n.º 22
0
	//-------------------------------------------------
	void RTSCamera::onSpecialKeyUp( NamedProperties& params )
	{
		int keyCode;
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			m_activeSpecialKeys[ keyCode ] = false;
		}
	}
Ejemplo n.º 23
0
	void MSMap::RenderLayer( int layer )
	{
		NamedProperties params;
		matStackf matStack;
		matStack.loadIdentity();

		if( 0 <= layer && layer < m_currentObstaclesOnMap.size() )
		{
			for( int i = 0; i < m_currentObstaclesOnMap[layer].size(); ++i )
			{
				matStack.loadIdentity();
				matStack.translate( m_currentObstaclesOnMap[layer][i]->boundingBox.getCenter() );
				params.set( "modelMatrix", matStack.top() );
				params.set( "mesh", m_currentObstaclesOnMap[layer][i]->mesh );
				fireEvent( "renderMesh", params );
			}
		}
	}
Ejemplo n.º 24
0
	//-------------------------------------------------
	void RTSCamera::onMouseButtonUp( NamedProperties& params )
	{
		int keyCode;
		if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS )
		{
			if( keyCode == GLUT_MIDDLE_BUTTON )
				m_isDragging = false;
		}
	}
Ejemplo n.º 25
0
//-----------------------------------------------------------------------------------------------
void Server::SetPortToBindToFromParameters( NamedProperties& parameters )
{
	std::string portAsString;

	parameters.Get( "param1", portAsString );

	FATAL_ASSERTION( portAsString != "", "Command: port did not receive the correct parameters.\nport expects a non empty string." );

	m_currentServerPort = u_short( atoi( portAsString.c_str() ) );
}
Ejemplo n.º 26
0
//-----------------------------------------------------------------------------------------------
void Server::SetServerIpFromParameters( NamedProperties& parameters )
{
	std::string ipAddressAsString;

	parameters.Get( "param1", ipAddressAsString );

	FATAL_ASSERTION( ipAddressAsString != "", "Command: ip did not receive the correct parameters.\nip expects a non empty string." );

	m_currentServerIPAddressAsString = ipAddressAsString;
}
Ejemplo n.º 27
0
	//-------------------------------------------------------------------
	void AttackMoveOrders::entityKilled( NamedProperties& params )
	{
		Entity* entityKilled = nullptr;
		if( params.get( "entity", entityKilled ) == NamedProperties::SUCCESS )
		{
			if( entityKilled == m_currentTargetEntity )
			{
				m_currentTargetEntity = nullptr;
			}
		}
	}
Ejemplo n.º 28
0
void WidgetBase::ApplyWidgetProperties(const NamedProperties& widgetDescriptor)
{
	for (UIState state = UI_STATE_DEFAULT; state < NUM_UI_STATES; state = (UIState)(state + 1)) {
		std::string stateName = GetNameForState((UIState)state);
		NamedProperties currentNP;
		PropertyGetResult currentGetResult = widgetDescriptor.Get(stateName, currentNP);

		if (currentGetResult == RESULT_SUCCESS) {
			CopyStatePropertyToWidget(state, currentNP);
		}
	}
}
Ejemplo n.º 29
0
	//----------------------------------------------------------------------
	void PlayerController::shipDiedEvt( NamedProperties& params )
	{
		Spaceship* tempShip;
		if( params.get( "spaceship", tempShip ) == NamedProperties::SUCCESS )
		{
			if( tempShip == m_ship )
			{
				m_shipRespawnTimer->start();
				m_ship = nullptr;
			}
		}
	}
Ejemplo n.º 30
0
	//-------------------------------------------------
	void RTSCamera::onMouseMove( NamedProperties& params )
	{
		vec2i mouseCoords;
		if( m_isDragging )
		{
			if( params.get( "mouseCoords", mouseCoords ) == NamedProperties::SUCCESS )
			{
				vec2i dirMouseSpace = mouseCoords - m_lastDragPos;
				vec2f dir = vec2f( (float)dirMouseSpace.x, (float)dirMouseSpace.y );
				dir.normalize();
				setPosition( getPosition() - dir );
			}
		}
	}