Skip to content

Commit 9aaed1c

Browse files
committed
Merge branch 'development'
2 parents f7bc37b + 4fd6365 commit 9aaed1c

32 files changed

+1000
-108
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![Torque Logo](http://static.garagegames.com/static/pg/logokits/Torque-Logo_H.png)
2-
## Torque 2D 3.0
2+
## Torque 2D 3.1
33

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

engine/source/2d/assets/ParticleAssetEmitter.cc

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ ParticleAssetEmitter::ParticleAssetEmitter() :
205205
mAnimationAsset.registerRefreshNotify( this );
206206

207207
mNamedImageFrame = "";
208+
mUsingNamedFrame = false;
208209
}
209210

210211
//------------------------------------------------------------------------------

engine/source/2d/assets/ParticleAssetField.cc

+15-2
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,21 @@ void ParticleAssetField::onTamlCustomRead( const TamlCustomNode* pCustomNode )
670670
keys.push_back( key );
671671
}
672672

673-
// Set the value bounds.
674-
setValueBounds( maxTime, minValue, maxValue, defaultValue );
673+
// If value bounds are present but no keys, assign the field its default values.
674+
if ( !keys.size() )
675+
{
676+
DataKey key;
677+
key.mTime = getMinTime();
678+
key.mValue = getDefaultValue();
679+
keys.push_back( key );
680+
}
681+
682+
// Did we read in any value bounds?
683+
if ( mValueBoundsDirty )
684+
{
685+
// Set the value bounds.
686+
setValueBounds( maxTime, minValue, maxValue, defaultValue );
687+
}
675688

676689
// Set the value scale.
677690
setValueScale( valueScale );

engine/source/2d/assets/ParticleAsset_ScriptBinding.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ ConsoleMethodWithDocs(ParticleAsset, deselectField, ConsoleVoid, 2, 2, ())
143143
/*! Gets the selected field name or nothing if no field is selected.
144144
@return The selected field name or nothing if no fields is selected.
145145
*/
146-
ConsoleMethodWithDocs(ParticleAsset, getSelectedField, ConsoleBool, 2, 2, ())
146+
ConsoleMethodWithDocs(ParticleAsset, getSelectedField, ConsoleString, 2, 2, ())
147147
{
148148
// Get the selected field.
149149
const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();

engine/source/2d/core/SpriteBatch.cc

+12
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ bool SpriteBatch::selectSpriteName( const char* pName )
457457

458458
//------------------------------------------------------------------------------
459459

460+
U32 SpriteBatch::getSpriteId( void ) const
461+
{
462+
// Finish if a sprite is not selected.
463+
if ( !checkSpriteSelected() )
464+
return 0;
465+
466+
// Get sprite id.
467+
return mSelectedSprite->getBatchId();
468+
}
469+
470+
//------------------------------------------------------------------------------
471+
460472
void SpriteBatch::setSpriteImage( const char* pAssetId, const U32 imageFrame )
461473
{
462474
// Debug Profiling.

engine/source/2d/core/SpriteBatch.h

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class SpriteBatch
120120
bool selectSpriteName( const char* pName );
121121
inline void deselectSprite( void ) { mSelectedSprite = NULL; }
122122
bool isSpriteSelected( void ) const { return mSelectedSprite != NULL; }
123+
U32 getSpriteId( void ) const;
123124

124125
void setSpriteImage( const char* pAssetId, const U32 imageFrame );
125126
void setSpriteImage( const char* pAssetId, const char* namedFrame );

engine/source/2d/core/SpriteBatchItem.cc

+12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static StringTableEntry spriteImageFrameName = StringTable->insert("Frame
5757
static StringTableEntry spriteNamedImageFrameName = StringTable->insert("NamedFrame");
5858
static StringTableEntry spriteAnimationName = StringTable->insert("Animation");
5959
static StringTableEntry spriteDataObjectName = StringTable->insert("DataObject");
60+
static StringTableEntry spriteUserDataName = StringTable->insert("UserData");
6061

6162
//------------------------------------------------------------------------------
6263

@@ -433,6 +434,12 @@ void SpriteBatchItem::onTamlCustomWrite( TamlCustomNode* pParentNode )
433434
// Write data object.
434435
if ( getDataObject() != NULL )
435436
pSpriteNode->addNode( getDataObject() );
437+
438+
if ( getUserData() != NULL)
439+
{
440+
const char* UserDatastr = (const char*) getUserData();
441+
pSpriteNode->addField( "UserData", UserDatastr );
442+
}
436443
}
437444

438445
//------------------------------------------------------------------------------
@@ -582,6 +589,11 @@ void SpriteBatchItem::onTamlCustomRead( const TamlCustomNode* pSpriteNode )
582589
// Set logical position.
583590
setLogicalPosition( LogicalPosition( pLogicalPositionArgs ) );
584591
}
592+
else if ( fieldName == spriteUserDataName )
593+
{
594+
StringTableEntry UserDatastr = StringTable->insert(pSpriteField->getFieldValue());
595+
setUserData((void *)UserDatastr);
596+
}
585597
}
586598

587599
// Fetch sprite children.

engine/source/2d/core/Utility.cc

+68-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ConsoleGetType( Typeb2AABB )
4141

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

@@ -327,4 +327,71 @@ U32 mGetStringElementCount( const char* inString )
327327
return wordCount;
328328
}
329329

330+
//-----------------------------------------------------------------------------
331+
332+
U32 mConvertStringToMask( const char* string )
333+
{
334+
// Grab the element count of the first parameter.
335+
const U32 elementCount = Utility::mGetStringElementCount(string);
336+
337+
// Make sure we get at least one number.
338+
if (elementCount < 1)
339+
return MASK_ALL;
340+
else if ( elementCount == 1 )
341+
{
342+
if ( dStricmp( string, "all" ) == 0 )
343+
return MASK_ALL;
344+
else if ( dStricmp( string, "none" ) == 0 || dStricmp( string, "off" ) == 0 )
345+
return 0;
346+
}
347+
348+
// The mask.
349+
U32 mask = 0;
350+
351+
// Convert the string to a mask.
352+
for (U32 i = 0; i < elementCount; i++)
353+
{
354+
S32 bit = dAtoi(Utility::mGetStringElement(string, i));
355+
356+
// Make sure the group is valid.
357+
if ((bit < 0) || (bit >= MASK_BITCOUNT))
358+
{
359+
Con::warnf("Utility::mConvertStringToMask() - Invalid group specified (%d); skipped!", bit);
360+
continue;
361+
}
362+
363+
mask |= (1 << bit);
364+
}
365+
366+
return mask;
367+
}
368+
369+
//-----------------------------------------------------------------------------
370+
371+
const char* mConvertMaskToString( const U32 mask )
372+
{
373+
bool first = true;
374+
static char bits[128];
375+
bits[0] = '\0';
376+
377+
if (!mask)
378+
{
379+
dSprintf(bits, 8, "none");
380+
return bits;
381+
}
382+
383+
for (S32 i = 0; i < MASK_BITCOUNT; i++)
384+
{
385+
if (mask & BIT(i))
386+
{
387+
char bit[4];
388+
dSprintf(bit, 4, "%s%d", first ? "" : " ", i);
389+
first = false;
390+
dStrcat(bits, bit);
391+
}
392+
}
393+
394+
return bits;
395+
}
396+
330397
} // Namespace Utility

engine/source/2d/core/Utility.h

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ Vector2 mGetStringElementVector( const char* inString, const U32 index = 0 );
8080
VectorF mGetStringElementVector3D( const char* inString, const U32 index = 0 );
8181
const char* mGetStringElement( const char* inString, const U32 index, const bool copyBuffer = true );
8282
U32 mGetStringElementCount( const char *string );
83+
U32 mConvertStringToMask( const char* string );
84+
const char* mConvertMaskToString( const U32 mask );
8385

8486
} // Namespace Utility.
8587

engine/source/2d/gui/SceneWindow_ScriptBinding.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,11 @@ ConsoleMethodWithDocs(SceneWindow, getTargetCameraSize, ConsoleString, 2, 2, ())
374374
//-----------------------------------------------------------------------------
375375

376376
/*! Set the target camera area.
377+
@param x1 / y1 Coordinates of the upper left corner of the target area.
378+
@param x2 / y2 Coordinates of the lower right corner of the target area.
377379
@return No return value.
378380
*/
379-
ConsoleMethodWithDocs(SceneWindow, setTargetCameraArea, ConsoleVoid, 3, 6, (x / y / width / height))
381+
ConsoleMethodWithDocs(SceneWindow, setTargetCameraArea, ConsoleVoid, 3, 6, (x1 / y1 / x2 / y2))
380382
{
381383
// Upper left bound.
382384
Vector2 v1;

0 commit comments

Comments
 (0)