Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lilligreen committed Aug 14, 2014
2 parents f7bc37b + 4fd6365 commit 9aaed1c
Show file tree
Hide file tree
Showing 32 changed files with 1,000 additions and 108 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![Torque Logo](http://static.garagegames.com/static/pg/logokits/Torque-Logo_H.png)
## Torque 2D 3.0
## Torque 2D 3.1

MIT Licensed Open Source version of Torque 2D from GarageGames. Maintained by the T2D Steering Committee and contributions from the community.

Expand Down
1 change: 1 addition & 0 deletions engine/source/2d/assets/ParticleAssetEmitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ ParticleAssetEmitter::ParticleAssetEmitter() :
mAnimationAsset.registerRefreshNotify( this );

mNamedImageFrame = "";
mUsingNamedFrame = false;
}

//------------------------------------------------------------------------------
Expand Down
17 changes: 15 additions & 2 deletions engine/source/2d/assets/ParticleAssetField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,21 @@ void ParticleAssetField::onTamlCustomRead( const TamlCustomNode* pCustomNode )
keys.push_back( key );
}

// Set the value bounds.
setValueBounds( maxTime, minValue, maxValue, defaultValue );
// If value bounds are present but no keys, assign the field its default values.
if ( !keys.size() )
{
DataKey key;
key.mTime = getMinTime();
key.mValue = getDefaultValue();
keys.push_back( key );
}

// Did we read in any value bounds?
if ( mValueBoundsDirty )
{
// Set the value bounds.
setValueBounds( maxTime, minValue, maxValue, defaultValue );
}

// Set the value scale.
setValueScale( valueScale );
Expand Down
2 changes: 1 addition & 1 deletion engine/source/2d/assets/ParticleAsset_ScriptBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ ConsoleMethodWithDocs(ParticleAsset, deselectField, ConsoleVoid, 2, 2, ())
/*! Gets the selected field name or nothing if no field is selected.
@return The selected field name or nothing if no fields is selected.
*/
ConsoleMethodWithDocs(ParticleAsset, getSelectedField, ConsoleBool, 2, 2, ())
ConsoleMethodWithDocs(ParticleAsset, getSelectedField, ConsoleString, 2, 2, ())
{
// Get the selected field.
const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();
Expand Down
12 changes: 12 additions & 0 deletions engine/source/2d/core/SpriteBatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,18 @@ bool SpriteBatch::selectSpriteName( const char* pName )

//------------------------------------------------------------------------------

U32 SpriteBatch::getSpriteId( void ) const
{
// Finish if a sprite is not selected.
if ( !checkSpriteSelected() )
return 0;

// Get sprite id.
return mSelectedSprite->getBatchId();
}

//------------------------------------------------------------------------------

void SpriteBatch::setSpriteImage( const char* pAssetId, const U32 imageFrame )
{
// Debug Profiling.
Expand Down
1 change: 1 addition & 0 deletions engine/source/2d/core/SpriteBatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class SpriteBatch
bool selectSpriteName( const char* pName );
inline void deselectSprite( void ) { mSelectedSprite = NULL; }
bool isSpriteSelected( void ) const { return mSelectedSprite != NULL; }
U32 getSpriteId( void ) const;

void setSpriteImage( const char* pAssetId, const U32 imageFrame );
void setSpriteImage( const char* pAssetId, const char* namedFrame );
Expand Down
12 changes: 12 additions & 0 deletions engine/source/2d/core/SpriteBatchItem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static StringTableEntry spriteImageFrameName = StringTable->insert("Frame
static StringTableEntry spriteNamedImageFrameName = StringTable->insert("NamedFrame");
static StringTableEntry spriteAnimationName = StringTable->insert("Animation");
static StringTableEntry spriteDataObjectName = StringTable->insert("DataObject");
static StringTableEntry spriteUserDataName = StringTable->insert("UserData");

//------------------------------------------------------------------------------

Expand Down Expand Up @@ -433,6 +434,12 @@ void SpriteBatchItem::onTamlCustomWrite( TamlCustomNode* pParentNode )
// Write data object.
if ( getDataObject() != NULL )
pSpriteNode->addNode( getDataObject() );

if ( getUserData() != NULL)
{
const char* UserDatastr = (const char*) getUserData();
pSpriteNode->addField( "UserData", UserDatastr );
}
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -582,6 +589,11 @@ void SpriteBatchItem::onTamlCustomRead( const TamlCustomNode* pSpriteNode )
// Set logical position.
setLogicalPosition( LogicalPosition( pLogicalPositionArgs ) );
}
else if ( fieldName == spriteUserDataName )
{
StringTableEntry UserDatastr = StringTable->insert(pSpriteField->getFieldValue());
setUserData((void *)UserDatastr);
}
}

// Fetch sprite children.
Expand Down
69 changes: 68 additions & 1 deletion engine/source/2d/core/Utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ConsoleGetType( Typeb2AABB )

// Format AABB.
char* pBuffer = Con::getReturnBuffer(64);
dSprintf(pBuffer, 64, "%.5g %.5g", pAABB->lowerBound.x, pAABB->lowerBound.y, pAABB->upperBound.x, pAABB->upperBound.y );
dSprintf(pBuffer, 64, "%.5g %.5g %.5g %.5g", pAABB->lowerBound.x, pAABB->lowerBound.y, pAABB->upperBound.x, pAABB->upperBound.y );
return pBuffer;
}

Expand Down Expand Up @@ -327,4 +327,71 @@ U32 mGetStringElementCount( const char* inString )
return wordCount;
}

//-----------------------------------------------------------------------------

U32 mConvertStringToMask( const char* string )
{
// Grab the element count of the first parameter.
const U32 elementCount = Utility::mGetStringElementCount(string);

// Make sure we get at least one number.
if (elementCount < 1)
return MASK_ALL;
else if ( elementCount == 1 )
{
if ( dStricmp( string, "all" ) == 0 )
return MASK_ALL;
else if ( dStricmp( string, "none" ) == 0 || dStricmp( string, "off" ) == 0 )
return 0;
}

// The mask.
U32 mask = 0;

// Convert the string to a mask.
for (U32 i = 0; i < elementCount; i++)
{
S32 bit = dAtoi(Utility::mGetStringElement(string, i));

// Make sure the group is valid.
if ((bit < 0) || (bit >= MASK_BITCOUNT))
{
Con::warnf("Utility::mConvertStringToMask() - Invalid group specified (%d); skipped!", bit);
continue;
}

mask |= (1 << bit);
}

return mask;
}

//-----------------------------------------------------------------------------

const char* mConvertMaskToString( const U32 mask )
{
bool first = true;
static char bits[128];
bits[0] = '\0';

if (!mask)
{
dSprintf(bits, 8, "none");
return bits;
}

for (S32 i = 0; i < MASK_BITCOUNT; i++)
{
if (mask & BIT(i))
{
char bit[4];
dSprintf(bit, 4, "%s%d", first ? "" : " ", i);
first = false;
dStrcat(bits, bit);
}
}

return bits;
}

} // Namespace Utility
2 changes: 2 additions & 0 deletions engine/source/2d/core/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Vector2 mGetStringElementVector( const char* inString, const U32 index = 0 );
VectorF mGetStringElementVector3D( const char* inString, const U32 index = 0 );
const char* mGetStringElement( const char* inString, const U32 index, const bool copyBuffer = true );
U32 mGetStringElementCount( const char *string );
U32 mConvertStringToMask( const char* string );
const char* mConvertMaskToString( const U32 mask );

} // Namespace Utility.

Expand Down
4 changes: 3 additions & 1 deletion engine/source/2d/gui/SceneWindow_ScriptBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,11 @@ ConsoleMethodWithDocs(SceneWindow, getTargetCameraSize, ConsoleString, 2, 2, ())
//-----------------------------------------------------------------------------

/*! Set the target camera area.
@param x1 / y1 Coordinates of the upper left corner of the target area.
@param x2 / y2 Coordinates of the lower right corner of the target area.
@return No return value.
*/
ConsoleMethodWithDocs(SceneWindow, setTargetCameraArea, ConsoleVoid, 3, 6, (x / y / width / height))
ConsoleMethodWithDocs(SceneWindow, setTargetCameraArea, ConsoleVoid, 3, 6, (x1 / y1 / x2 / y2))
{
// Upper left bound.
Vector2 v1;
Expand Down
Loading

0 comments on commit 9aaed1c

Please sign in to comment.