Merge pull request #1923 from elfprince13/stringTableEmptyString

String table empty string
This commit is contained in:
Areloch 2017-01-25 21:06:44 -06:00 committed by GitHub
commit 7185d9664d
57 changed files with 1732 additions and 1732 deletions

View file

@ -64,16 +64,16 @@
class fxFoliageItem class fxFoliageItem
{ {
public: public:
MatrixF Transform; MatrixF Transform;
F32 Width; F32 Width;
F32 Height; F32 Height;
Box3F FoliageBox; Box3F FoliageBox;
bool Flipped; bool Flipped;
F32 SwayPhase; F32 SwayPhase;
F32 SwayTimeRatio; F32 SwayTimeRatio;
F32 LightPhase; F32 LightPhase;
F32 LightTimeRatio; F32 LightTimeRatio;
U32 LastFrameSerialID; U32 LastFrameSerialID;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -104,9 +104,9 @@ public:
Box3F QuadrantBox; Box3F QuadrantBox;
fxFoliageQuadrantNode* QuadrantChildNode[4]; fxFoliageQuadrantNode* QuadrantChildNode[4];
Vector<fxFoliageItem*> RenderList; Vector<fxFoliageItem*> RenderList;
// Used in DrawIndexPrimitive call. // Used in DrawIndexPrimitive call.
U32 startIndex; U32 startIndex;
U32 primitiveCount; U32 primitiveCount;
}; };
@ -152,7 +152,7 @@ protected:
void CreateFoliage(void); void CreateFoliage(void);
void DestroyFoliage(void); void DestroyFoliage(void);
void DestroyFoliageItems(); void DestroyFoliageItems();
void SyncFoliageReplicators(void); void SyncFoliageReplicators(void);
@ -172,11 +172,11 @@ protected:
Vector<fxFoliageItem*> mReplicatedFoliage; Vector<fxFoliageItem*> mReplicatedFoliage;
fxFoliageRenderList mFrustumRenderSet; fxFoliageRenderList mFrustumRenderSet;
GFXVertexBufferHandle<GFXVertexFoliage> mVertexBuffer; GFXVertexBufferHandle<GFXVertexFoliage> mVertexBuffer;
GFXPrimitiveBufferHandle mPrimBuffer; GFXPrimitiveBufferHandle mPrimBuffer;
GFXShaderRef mShader; GFXShaderRef mShader;
ShaderData* mShaderData; ShaderData* mShaderData;
GBitmap* mAlphaLookup; GBitmap* mAlphaLookup;
MRandomLCG RandomGen; MRandomLCG RandomGen;
F32 mFadeInGradient; F32 mFadeInGradient;
@ -193,8 +193,8 @@ protected:
U32 mNextAllocatedNodeIdx; // Next Allocated Node Index. U32 mNextAllocatedNodeIdx; // Next Allocated Node Index.
U32 mBillboardsAcquired; // Billboards Acquired. U32 mBillboardsAcquired; // Billboards Acquired.
// Used for alpha lookup in the pixel shader // Used for alpha lookup in the pixel shader
GFXTexHandle mAlphaTexture; GFXTexHandle mAlphaTexture;
GFXStateBlockRef mPlacementSB; GFXStateBlockRef mPlacementSB;
GFXStateBlockRef mRenderSB; GFXStateBlockRef mRenderSB;
@ -223,15 +223,15 @@ protected:
bool mDirty; bool mDirty;
void SetupShader(); void SetupShader();
void SetupBuffers(); void SetupBuffers();
void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance*); void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance*);
void renderBuffers(SceneRenderState* state); void renderBuffers(SceneRenderState* state);
void renderArc(const F32 fRadiusX, const F32 fRadiusY); void renderArc(const F32 fRadiusX, const F32 fRadiusY);
void renderPlacementArea(const F32 ElapsedTime); void renderPlacementArea(const F32 ElapsedTime);
void renderQuad(fxFoliageQuadrantNode* quadNode, const MatrixF& RenderTransform, const bool UseDebug); void renderQuad(fxFoliageQuadrantNode* quadNode, const MatrixF& RenderTransform, const bool UseDebug);
void computeAlphaTex(); void computeAlphaTex();
public: public:
fxFoliageReplicator(); fxFoliageReplicator();
~fxFoliageReplicator(); ~fxFoliageReplicator();
@ -325,7 +325,7 @@ public:
mUseDebugInfo = false; mUseDebugInfo = false;
mDebugBoxHeight = 1.0f; mDebugBoxHeight = 1.0f;
mSeed = 1376312589; mSeed = 1376312589;
mFoliageFile = StringTable->insert(""); mFoliageFile = StringTable->EmptyString();
mFoliageTexture = GFXTexHandle(); mFoliageTexture = GFXTexHandle();
mFoliageCount = 10; mFoliageCount = 10;
mFoliageRetries = 100; mFoliageRetries = 100;

View file

@ -153,7 +153,7 @@ public:
{ {
// Set Defaults. // Set Defaults.
mSeed = 1376312589; mSeed = 1376312589;
mShapeFile = StringTable->insert(""); mShapeFile = StringTable->EmptyString();
mShapeCount = 10; mShapeCount = 10;
mShapeRetries = 100; mShapeRetries = 100;
mInnerRadiusX = 0; mInnerRadiusX = 0;

View file

@ -129,10 +129,10 @@ PrecipitationData::PrecipitationData()
{ {
soundProfile = NULL; soundProfile = NULL;
mDropName = StringTable->insert(""); mDropName = StringTable->EmptyString();
mDropShaderName = StringTable->insert(""); mDropShaderName = StringTable->EmptyString();
mSplashName = StringTable->insert(""); mSplashName = StringTable->EmptyString();
mSplashShaderName = StringTable->insert(""); mSplashShaderName = StringTable->EmptyString();
mDropsPerSide = 4; mDropsPerSide = 4;
mSplashesPerSide = 2; mSplashesPerSide = 2;

View file

@ -57,7 +57,7 @@ RibbonData::RibbonData()
mUseFadeOut = false; mUseFadeOut = false;
mFadeAwayStep = 0.032f; mFadeAwayStep = 0.032f;
segmentsPerUpdate = 1; segmentsPerUpdate = 1;
mMatName = StringTable->insert(""); mMatName = StringTable->EmptyString();
mTileScale = 1.0f; mTileScale = 1.0f;
mFixedTexcoords = false; mFixedTexcoords = false;
mSegmentSkipAmount = 0; mSegmentSkipAmount = 0;
@ -318,7 +318,7 @@ void Ribbon::processTick(const Move* move)
safeDeleteObject(); safeDeleteObject();
return; return;
//} //}
//mSegmentPoints.pop_back(); //mSegmentPoints.pop_back();
} }
@ -456,7 +456,7 @@ void Ribbon::setShaderParams() {
F32 length = (F32)mDataBlock->mRibbonLength; F32 length = (F32)mDataBlock->mRibbonLength;
Point3F radius(numSegments / length, numSegments, length); Point3F radius(numSegments / length, numSegments, length);
MaterialParameters* matParams = mRibbonMat->getMaterialParameters(); MaterialParameters* matParams = mRibbonMat->getMaterialParameters();
matParams->setSafe( mRadiusSC, radius ); matParams->setSafe( mRadiusSC, radius );
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View file

@ -225,7 +225,7 @@ ConsoleDocClass( WayPoint,
WayPoint::WayPoint() WayPoint::WayPoint()
{ {
mName = StringTable->insert(""); mName = StringTable->EmptyString();
} }
void WayPoint::setHidden(bool hidden) void WayPoint::setHidden(bool hidden)
@ -256,7 +256,7 @@ void WayPoint::inspectPostApply()
{ {
Parent::inspectPostApply(); Parent::inspectPostApply();
if(!mName || !mName[0]) if(!mName || !mName[0])
mName = StringTable->insert(""); mName = StringTable->EmptyString();
setMaskBits(UpdateNameMask|UpdateTeamMask); setMaskBits(UpdateNameMask|UpdateTeamMask);
} }
@ -281,7 +281,7 @@ void WayPoint::unpackUpdate(NetConnection * con, BitStream * stream)
void WayPoint::initPersistFields() void WayPoint::initPersistFields()
{ {
addGroup("Misc"); addGroup("Misc");
addField("markerName", TypeCaseString, Offset(mName, WayPoint), "Unique name representing this waypoint"); addField("markerName", TypeCaseString, Offset(mName, WayPoint), "Unique name representing this waypoint");
endGroup("Misc"); endGroup("Misc");
Parent::initPersistFields(); Parent::initPersistFields();
@ -363,7 +363,7 @@ bool SpawnSphere::onAdd()
if (!isGhost()) if (!isGhost())
{ {
onAdd_callback( getId()); onAdd_callback( getId());
if (mAutoSpawn) if (mAutoSpawn)
spawnObject(); spawnObject();
@ -527,7 +527,7 @@ ConsoleDocClass( CameraBookmark,
CameraBookmark::CameraBookmark() CameraBookmark::CameraBookmark()
{ {
mName = StringTable->insert(""); mName = StringTable->EmptyString();
} }
bool CameraBookmark::onAdd() bool CameraBookmark::onAdd()
@ -571,7 +571,7 @@ void CameraBookmark::inspectPostApply()
{ {
Parent::inspectPostApply(); Parent::inspectPostApply();
if(!mName || !mName[0]) if(!mName || !mName[0])
mName = StringTable->insert(""); mName = StringTable->EmptyString();
setMaskBits(UpdateNameMask); setMaskBits(UpdateNameMask);
if( isMethod("onInspectPostApply") ) if( isMethod("onInspectPostApply") )
@ -595,7 +595,7 @@ void CameraBookmark::unpackUpdate(NetConnection * con, BitStream * stream)
void CameraBookmark::initPersistFields() void CameraBookmark::initPersistFields()
{ {
//addGroup("Misc"); //addGroup("Misc");
//addField("name", TypeCaseString, Offset(mName, CameraBookmark)); //addField("name", TypeCaseString, Offset(mName, CameraBookmark));
//endGroup("Misc"); //endGroup("Misc");

View file

@ -257,15 +257,15 @@ PlayerData::PlayerData()
firstPersonShadows = false; firstPersonShadows = false;
// Used for third person image rendering // Used for third person image rendering
imageAnimPrefix = StringTable->insert(""); imageAnimPrefix = StringTable->EmptyString();
allowImageStateAnimation = false; allowImageStateAnimation = false;
// Used for first person image rendering // Used for first person image rendering
imageAnimPrefixFP = StringTable->insert(""); imageAnimPrefixFP = StringTable->EmptyString();
for (U32 i=0; i<ShapeBase::MaxMountedImages; ++i) for (U32 i=0; i<ShapeBase::MaxMountedImages; ++i)
{ {
shapeNameFP[i] = StringTable->insert(""); shapeNameFP[i] = StringTable->EmptyString();
mCRCFP[i] = 0; mCRCFP[i] = 0;
mValidShapeFP[i] = false; mValidShapeFP[i] = false;
} }
@ -418,7 +418,7 @@ PlayerData::PlayerData()
jumpTowardsNormal = true; jumpTowardsNormal = true;
physicsPlayerType = StringTable->insert(""); physicsPlayerType = StringTable->EmptyString();
dMemset( actionList, 0, sizeof(actionList) ); dMemset( actionList, 0, sizeof(actionList) );
} }
@ -6652,7 +6652,7 @@ DefineEngineMethod( Player, setActionThread, bool, ( const char* name, bool hold
"@tsexample\n" "@tsexample\n"
"// Place the player in a sitting position after being mounted\n" "// Place the player in a sitting position after being mounted\n"
"%player.setActionThread( \"sitting\", true, true );\n" "%player.setActionThread( \"sitting\", true, true );\n"
"@endtsexample\n") "@endtsexample\n")
{ {
return object->setActionThread( name, hold, true, fsp); return object->setActionThread( name, hold, true, fsp);
} }
@ -6700,11 +6700,11 @@ DefineEngineMethod( Player, clearControlObject, void, (),,
"Returns control to the player. This internally calls " "Returns control to the player. This internally calls "
"Player::setControlObject(0).\n" "Player::setControlObject(0).\n"
"@tsexample\n" "@tsexample\n"
"%player.clearControlObject();\n" "%player.clearControlObject();\n"
"echo(%player.getControlObject()); //<-- Returns 0, player assumes control\n" "echo(%player.getControlObject()); //<-- Returns 0, player assumes control\n"
"%player.setControlObject(%vehicle);\n" "%player.setControlObject(%vehicle);\n"
"echo(%player.getControlObject()); //<-- Returns %vehicle, player controls the vehicle now.\n" "echo(%player.getControlObject()); //<-- Returns %vehicle, player controls the vehicle now.\n"
"@endtsexample\n" "@endtsexample\n"
"@note If the player does not have a control object, the player will receive all moves " "@note If the player does not have a control object, the player will receive all moves "
"from its GameConnection. If you're looking to remove control from the player itself " "from its GameConnection. If you're looking to remove control from the player itself "
"(i.e. stop sending moves to the player) use GameConnection::setControlObject() to transfer " "(i.e. stop sending moves to the player) use GameConnection::setControlObject() to transfer "
@ -6762,63 +6762,63 @@ void Player::consoleInit()
"@brief Determines if the player is rendered or not.\n\n" "@brief Determines if the player is rendered or not.\n\n"
"Used on the client side to disable the rendering of all Player objects. This is " "Used on the client side to disable the rendering of all Player objects. This is "
"mainly for the tools or debugging.\n" "mainly for the tools or debugging.\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::renderMyItems",TypeBool, &sRenderMyItems, Con::addVariable("$player::renderMyItems",TypeBool, &sRenderMyItems,
"@brief Determines if mounted shapes are rendered or not.\n\n" "@brief Determines if mounted shapes are rendered or not.\n\n"
"Used on the client side to disable the rendering of all Player mounted objects. This is " "Used on the client side to disable the rendering of all Player mounted objects. This is "
"mainly used for the tools or debugging.\n" "mainly used for the tools or debugging.\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::renderCollision", TypeBool, &sRenderPlayerCollision, Con::addVariable("$player::renderCollision", TypeBool, &sRenderPlayerCollision,
"@brief Determines if the player's collision mesh should be rendered.\n\n" "@brief Determines if the player's collision mesh should be rendered.\n\n"
"This is mainly used for the tools and debugging.\n" "This is mainly used for the tools and debugging.\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::minWarpTicks",TypeF32,&sMinWarpTicks, Con::addVariable("$player::minWarpTicks",TypeF32,&sMinWarpTicks,
"@brief Fraction of tick at which instant warp occures on the client.\n\n" "@brief Fraction of tick at which instant warp occures on the client.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::maxWarpTicks",TypeS32,&sMaxWarpTicks, Con::addVariable("$player::maxWarpTicks",TypeS32,&sMaxWarpTicks,
"@brief When a warp needs to occur due to the client being too far off from the server, this is the " "@brief When a warp needs to occur due to the client being too far off from the server, this is the "
"maximum number of ticks we'll allow the client to warp to catch up.\n\n" "maximum number of ticks we'll allow the client to warp to catch up.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::maxPredictionTicks",TypeS32,&sMaxPredictionTicks, Con::addVariable("$player::maxPredictionTicks",TypeS32,&sMaxPredictionTicks,
"@brief Maximum number of ticks to predict on the client from the last known move obtained from the server.\n\n" "@brief Maximum number of ticks to predict on the client from the last known move obtained from the server.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::maxImpulseVelocity", TypeF32, &sMaxImpulseVelocity, Con::addVariable("$player::maxImpulseVelocity", TypeF32, &sMaxImpulseVelocity,
"@brief The maximum velocity allowed due to a single impulse.\n\n" "@brief The maximum velocity allowed due to a single impulse.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
// Move triggers // Move triggers
Con::addVariable("$player::jumpTrigger", TypeS32, &sJumpTrigger, Con::addVariable("$player::jumpTrigger", TypeS32, &sJumpTrigger,
"@brief The move trigger index used for player jumping.\n\n" "@brief The move trigger index used for player jumping.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::crouchTrigger", TypeS32, &sCrouchTrigger, Con::addVariable("$player::crouchTrigger", TypeS32, &sCrouchTrigger,
"@brief The move trigger index used for player crouching.\n\n" "@brief The move trigger index used for player crouching.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::proneTrigger", TypeS32, &sProneTrigger, Con::addVariable("$player::proneTrigger", TypeS32, &sProneTrigger,
"@brief The move trigger index used for player prone pose.\n\n" "@brief The move trigger index used for player prone pose.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::sprintTrigger", TypeS32, &sSprintTrigger, Con::addVariable("$player::sprintTrigger", TypeS32, &sSprintTrigger,
"@brief The move trigger index used for player sprinting.\n\n" "@brief The move trigger index used for player sprinting.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::imageTrigger0", TypeS32, &sImageTrigger0, Con::addVariable("$player::imageTrigger0", TypeS32, &sImageTrigger0,
"@brief The move trigger index used to trigger mounted image 0.\n\n" "@brief The move trigger index used to trigger mounted image 0.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::imageTrigger1", TypeS32, &sImageTrigger1, Con::addVariable("$player::imageTrigger1", TypeS32, &sImageTrigger1,
"@brief The move trigger index used to trigger mounted image 1 or alternate fire " "@brief The move trigger index used to trigger mounted image 1 or alternate fire "
"on mounted image 0.\n\n" "on mounted image 0.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::jumpJetTrigger", TypeS32, &sJumpJetTrigger, Con::addVariable("$player::jumpJetTrigger", TypeS32, &sJumpJetTrigger,
"@brief The move trigger index used for player jump jetting.\n\n" "@brief The move trigger index used for player jump jetting.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
Con::addVariable("$player::vehicleDismountTrigger", TypeS32, &sVehicleDismountTrigger, Con::addVariable("$player::vehicleDismountTrigger", TypeS32, &sVehicleDismountTrigger,
"@brief The move trigger index used to dismount player.\n\n" "@brief The move trigger index used to dismount player.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
// ExtendedMove support // ExtendedMove support
Con::addVariable("$player::extendedMoveHeadPosRotIndex", TypeS32, &smExtendedMoveHeadPosRotIndex, Con::addVariable("$player::extendedMoveHeadPosRotIndex", TypeS32, &smExtendedMoveHeadPosRotIndex,
"@brief The ExtendedMove position/rotation index used for head movements.\n\n" "@brief The ExtendedMove position/rotation index used for head movements.\n\n"
"@ingroup GameObjects\n"); "@ingroup GameObjects\n");
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View file

@ -152,13 +152,13 @@ ShapeBaseData::ShapeBaseData()
shadowMaxVisibleDistance( 80.0f ), shadowMaxVisibleDistance( 80.0f ),
shadowProjectionDistance( 10.0f ), shadowProjectionDistance( 10.0f ),
shadowSphereAdjust( 1.0f ), shadowSphereAdjust( 1.0f ),
shapeName( StringTable->insert("") ), shapeName( StringTable->EmptyString() ),
cloakTexName( StringTable->insert("") ), cloakTexName( StringTable->EmptyString() ),
cubeDescId( 0 ), cubeDescId( 0 ),
reflectorDesc( NULL ), reflectorDesc( NULL ),
debris( NULL ), debris( NULL ),
debrisID( 0 ), debrisID( 0 ),
debrisShapeName( StringTable->insert("") ), debrisShapeName( StringTable->EmptyString() ),
explosion( NULL ), explosion( NULL ),
explosionID( 0 ), explosionID( 0 ),
underwaterExplosion( NULL ), underwaterExplosion( NULL ),
@ -447,12 +447,12 @@ bool ShapeBaseData::_setMass( void* object, const char* index, const char* data
{ {
ShapeBaseData* shape = reinterpret_cast< ShapeBaseData* >( object ); ShapeBaseData* shape = reinterpret_cast< ShapeBaseData* >( object );
F32 mass = dAtof(data); F32 mass = dAtof(data);
if (mass <= 0) if (mass <= 0)
mass = 0.01f; mass = 0.01f;
shape->mass = mass; shape->mass = mass;
return false; return false;
} }
@ -935,8 +935,8 @@ ShapeBase::ShapeBase()
mScriptThread[i].thread = 0; mScriptThread[i].thread = 0;
mScriptThread[i].state = Thread::Stop; mScriptThread[i].state = Thread::Stop;
mScriptThread[i].atEnd = false; mScriptThread[i].atEnd = false;
mScriptThread[i].timescale = 1.f; mScriptThread[i].timescale = 1.f;
mScriptThread[i].position = -1.f; mScriptThread[i].position = -1.f;
} }
for (i = 0; i < MaxTriggerKeys; i++) for (i = 0; i < MaxTriggerKeys; i++)
@ -1042,7 +1042,7 @@ bool ShapeBase::onAdd()
} }
/* /*
if(mDataBlock->cloakTexName != StringTable->insert("")) if(mDataBlock->cloakTexName != StringTable->EmptyString())
mCloakTexture = TextureHandle(mDataBlock->cloakTexName, MeshTexture, false); mCloakTexture = TextureHandle(mDataBlock->cloakTexName, MeshTexture, false);
*/ */
// Accumulation and environment mapping // Accumulation and environment mapping
@ -1512,8 +1512,8 @@ void ShapeBase::onCameraScopeQuery(NetConnection *cr, CameraScopeQuery * query)
eyeTransform.getColumn(1, &query->orientation); eyeTransform.getColumn(1, &query->orientation);
// Get the visible distance. // Get the visible distance.
if (getSceneManager() != NULL) if (getSceneManager() != NULL)
query->visibleDistance = getSceneManager()->getVisibleDistance(); query->visibleDistance = getSceneManager()->getVisibleDistance();
Parent::onCameraScopeQuery( cr, query ); Parent::onCameraScopeQuery( cr, query );
} }
@ -2154,18 +2154,18 @@ void ShapeBase::updateAudioPos()
const char *ShapeBase::getThreadSequenceName( U32 slot ) const char *ShapeBase::getThreadSequenceName( U32 slot )
{ {
Thread& st = mScriptThread[slot]; Thread& st = mScriptThread[slot];
if ( st.sequence == -1 ) if ( st.sequence == -1 )
{ {
// Invalid Animation. // Invalid Animation.
return ""; return "";
} }
// Name Index // Name Index
const U32 nameIndex = getShape()->sequences[st.sequence].nameIndex; const U32 nameIndex = getShape()->sequences[st.sequence].nameIndex;
// Return Name. // Return Name.
return getShape()->getName( nameIndex ); return getShape()->getName( nameIndex );
} }
bool ShapeBase::setThreadSequence(U32 slot, S32 seq, bool reset) bool ShapeBase::setThreadSequence(U32 slot, S32 seq, bool reset)
@ -2200,39 +2200,39 @@ bool ShapeBase::setThreadSequence(U32 slot, S32 seq, bool reset)
void ShapeBase::updateThread(Thread& st) void ShapeBase::updateThread(Thread& st)
{ {
switch (st.state) switch (st.state)
{ {
case Thread::Stop: case Thread::Stop:
{ {
mShapeInstance->setTimeScale( st.thread, 1.f ); mShapeInstance->setTimeScale( st.thread, 1.f );
mShapeInstance->setPos( st.thread, ( st.timescale > 0.f ) ? 1.0f : 0.0f ); mShapeInstance->setPos( st.thread, ( st.timescale > 0.f ) ? 1.0f : 0.0f );
} // Drop through to pause state } // Drop through to pause state
case Thread::Pause: case Thread::Pause:
{ {
mShapeInstance->setTimeScale( st.thread, 0.f ); mShapeInstance->setTimeScale( st.thread, 0.f );
} break; } break;
case Thread::Play: case Thread::Play:
{ {
if (st.atEnd) if (st.atEnd)
{ {
mShapeInstance->setTimeScale(st.thread,1); mShapeInstance->setTimeScale(st.thread,1);
mShapeInstance->setPos( st.thread, ( st.timescale > 0.f ) ? 1.0f : 0.0f ); mShapeInstance->setPos( st.thread, ( st.timescale > 0.f ) ? 1.0f : 0.0f );
mShapeInstance->setTimeScale(st.thread,0); mShapeInstance->setTimeScale(st.thread,0);
st.state = Thread::Stop; st.state = Thread::Stop;
} }
else else
{ {
if ( st.position != -1.f ) if ( st.position != -1.f )
{ {
mShapeInstance->setTimeScale( st.thread, 1.f ); mShapeInstance->setTimeScale( st.thread, 1.f );
mShapeInstance->setPos( st.thread, st.position ); mShapeInstance->setPos( st.thread, st.position );
} }
mShapeInstance->setTimeScale(st.thread, st.timescale ); mShapeInstance->setTimeScale(st.thread, st.timescale );
} }
} break; } break;
case Thread::Destroy: case Thread::Destroy:
{ {
@ -2244,7 +2244,7 @@ void ShapeBase::updateThread(Thread& st)
st.thread = 0; st.thread = 0;
} }
} break; } break;
} }
} }
bool ShapeBase::stopThread(U32 slot) bool ShapeBase::stopThread(U32 slot)
@ -2297,50 +2297,50 @@ bool ShapeBase::playThread(U32 slot)
bool ShapeBase::setThreadPosition( U32 slot, F32 pos ) bool ShapeBase::setThreadPosition( U32 slot, F32 pos )
{ {
Thread& st = mScriptThread[slot]; Thread& st = mScriptThread[slot];
if (st.sequence != -1) if (st.sequence != -1)
{ {
setMaskBits(ThreadMaskN << slot); setMaskBits(ThreadMaskN << slot);
st.position = pos; st.position = pos;
st.atEnd = false; st.atEnd = false;
updateThread(st); updateThread(st);
return true; return true;
} }
return false; return false;
} }
bool ShapeBase::setThreadDir(U32 slot,bool forward) bool ShapeBase::setThreadDir(U32 slot,bool forward)
{ {
Thread& st = mScriptThread[slot]; Thread& st = mScriptThread[slot];
if (st.sequence != -1) if (st.sequence != -1)
{ {
if ( ( st.timescale >= 0.f ) != forward ) if ( ( st.timescale >= 0.f ) != forward )
{ {
setMaskBits(ThreadMaskN << slot); setMaskBits(ThreadMaskN << slot);
st.timescale *= -1.f ; st.timescale *= -1.f ;
st.atEnd = false; st.atEnd = false;
updateThread(st); updateThread(st);
} }
return true; return true;
} }
return false; return false;
} }
bool ShapeBase::setThreadTimeScale( U32 slot, F32 timeScale ) bool ShapeBase::setThreadTimeScale( U32 slot, F32 timeScale )
{ {
Thread& st = mScriptThread[slot]; Thread& st = mScriptThread[slot];
if (st.sequence != -1) if (st.sequence != -1)
{ {
if (st.timescale != timeScale) if (st.timescale != timeScale)
{ {
setMaskBits(ThreadMaskN << slot); setMaskBits(ThreadMaskN << slot);
st.timescale = timeScale; st.timescale = timeScale;
updateThread(st); updateThread(st);
} }
return true; return true;
} }
return false; return false;
} }
void ShapeBase::advanceThreads(F32 dt) void ShapeBase::advanceThreads(F32 dt)
@ -2349,7 +2349,7 @@ void ShapeBase::advanceThreads(F32 dt)
Thread& st = mScriptThread[i]; Thread& st = mScriptThread[i];
if (st.thread) { if (st.thread) {
if (!mShapeInstance->getShape()->sequences[st.sequence].isCyclic() && !st.atEnd && if (!mShapeInstance->getShape()->sequences[st.sequence].isCyclic() && !st.atEnd &&
( ( st.timescale > 0.f )? mShapeInstance->getPos(st.thread) >= 1.0: ( ( st.timescale > 0.f )? mShapeInstance->getPos(st.thread) >= 1.0:
mShapeInstance->getPos(st.thread) <= 0)) { mShapeInstance->getPos(st.thread) <= 0)) {
st.atEnd = true; st.atEnd = true;
updateThread(st); updateThread(st);
@ -4392,7 +4392,7 @@ DefineEngineMethod( ShapeBase, isEnabled, bool, (),,
DefineEngineMethod(ShapeBase, blowUp, void, (),, "@brief Explodes an object into pieces.") DefineEngineMethod(ShapeBase, blowUp, void, (),, "@brief Explodes an object into pieces.")
{ {
object->blowUp(); object->blowUp();
} }
DefineEngineMethod( ShapeBase, applyDamage, void, ( F32 amount ),, DefineEngineMethod( ShapeBase, applyDamage, void, ( F32 amount ),,
@ -4696,22 +4696,22 @@ void ShapeBase::consoleInit()
"@see ShapeBase::setDamageFlash()\n" "@see ShapeBase::setDamageFlash()\n"
"@see ShapeBase::getDamageFlash()\n" "@see ShapeBase::getDamageFlash()\n"
"@note Relies on the flash postFx.\n" "@note Relies on the flash postFx.\n"
"@ingroup gameObjects\n"); "@ingroup gameObjects\n");
Con::addVariable("SB::WODec", TypeF32, &sWhiteoutDec, "Speed to reduce the whiteout effect per tick.\n\n" Con::addVariable("SB::WODec", TypeF32, &sWhiteoutDec, "Speed to reduce the whiteout effect per tick.\n\n"
"@see ShapeBase::setWhiteOut()\n" "@see ShapeBase::setWhiteOut()\n"
"@see ShapeBase::getWhiteOut" "@see ShapeBase::getWhiteOut"
"@note Relies on the flash postFx.\n" "@note Relies on the flash postFx.\n"
"@ingroup gameObjects\n"); "@ingroup gameObjects\n");
Con::addVariable("SB::FullCorrectionDistance", TypeF32, &sFullCorrectionDistance, Con::addVariable("SB::FullCorrectionDistance", TypeF32, &sFullCorrectionDistance,
"@brief Distance at which a weapon's muzzle vector is fully corrected to match where the player is looking.\n\n" "@brief Distance at which a weapon's muzzle vector is fully corrected to match where the player is looking.\n\n"
"When a weapon image has correctMuzzleVector set and the Player is in 1st person, the muzzle vector from the " "When a weapon image has correctMuzzleVector set and the Player is in 1st person, the muzzle vector from the "
"weapon is modified to match where the player is looking. Beyond the FullCorrectionDistance the muzzle vector " "weapon is modified to match where the player is looking. Beyond the FullCorrectionDistance the muzzle vector "
"is always corrected. Between FullCorrectionDistance and the player, the weapon's muzzle vector is adjusted so that " "is always corrected. Between FullCorrectionDistance and the player, the weapon's muzzle vector is adjusted so that "
"the closer the aim point is to the player, the closer the muzzle vector is to the true (non-corrected) one.\n" "the closer the aim point is to the player, the closer the muzzle vector is to the true (non-corrected) one.\n"
"@ingroup gameObjects\n"); "@ingroup gameObjects\n");
Con::addVariable("SB::CloakSpeed", TypeF32, &sCloakSpeed, Con::addVariable("SB::CloakSpeed", TypeF32, &sCloakSpeed,
"@brief Time to cloak, in seconds.\n\n" "@brief Time to cloak, in seconds.\n\n"
"@ingroup gameObjects\n"); "@ingroup gameObjects\n");
} }
void ShapeBase::_updateHiddenMeshes() void ShapeBase::_updateHiddenMeshes()
@ -4832,17 +4832,17 @@ DefineEngineMethod( ShapeBase, getTargetName, const char*, ( S32 index ),,
"@see getTargetCount()\n") "@see getTargetCount()\n")
{ {
ShapeBase *obj = dynamic_cast< ShapeBase* > ( object ); ShapeBase *obj = dynamic_cast< ShapeBase* > ( object );
if(obj) if(obj)
{ {
// Try to use the client object (so we get the reskinned targets in the Material Editor) // Try to use the client object (so we get the reskinned targets in the Material Editor)
if ((ShapeBase*)obj->getClientObject()) if ((ShapeBase*)obj->getClientObject())
obj = (ShapeBase*)obj->getClientObject(); obj = (ShapeBase*)obj->getClientObject();
return obj->getShapeInstance()->getTargetName(index); return obj->getShapeInstance()->getTargetName(index);
} }
return ""; return "";
} }
DefineEngineMethod( ShapeBase, getTargetCount, S32, (),, DefineEngineMethod( ShapeBase, getTargetCount, S32, (),,
@ -4861,7 +4861,7 @@ DefineEngineMethod( ShapeBase, getTargetCount, S32, (),,
if (obj->getShapeInstance() != NULL) if (obj->getShapeInstance() != NULL)
return obj->getShapeInstance()->getTargetCount(); return obj->getShapeInstance()->getTargetCount();
} }
return -1; return -1;
} }
@ -4938,10 +4938,10 @@ DefineEngineMethod( ShapeBase, getModelFile, const char *, (),,
"@return the shape filename\n\n" ) "@return the shape filename\n\n" )
{ {
GameBaseData * datablock = object->getDataBlock(); GameBaseData * datablock = object->getDataBlock();
if( !datablock ) if( !datablock )
return String::EmptyString; return String::EmptyString;
const char *fieldName = StringTable->insert( String("shapeFile") ); const char *fieldName = StringTable->insert( String("shapeFile") );
return datablock->getDataField( fieldName, NULL ); return datablock->getDataField( fieldName, NULL );
} }

View file

@ -49,40 +49,40 @@ ConsoleDocClass( SimXMLDocument,
"// Thanks to Rex Hiebert for this example\n" "// Thanks to Rex Hiebert for this example\n"
"// Given the following XML\n" "// Given the following XML\n"
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n"
"<DataTables>\n" "<DataTables>\n"
" <table tableName=\"2DShapes\">\n" " <table tableName=\"2DShapes\">\n"
" <rec id=\"1\">Triangle</rec>\n" " <rec id=\"1\">Triangle</rec>\n"
" <rec id=\"2\">Square</rec>\n" " <rec id=\"2\">Square</rec>\n"
" <rec id=\"3\">Circle</rec>\n" " <rec id=\"3\">Circle</rec>\n"
" </table>\n" " </table>\n"
" <table tableName=\"3DShapes\">\n" " <table tableName=\"3DShapes\">\n"
" <rec id=\"1\">Pyramid</rec>\n" " <rec id=\"1\">Pyramid</rec>\n"
" <rec id=\"2\">Cube</rec>\n" " <rec id=\"2\">Cube</rec>\n"
" <rec id=\"3\">Sphere</rec>\n" " <rec id=\"3\">Sphere</rec>\n"
" </table>\n" " </table>\n"
"</DataTables>\n\n" "</DataTables>\n\n"
"// Using SimXMLDocument by itself\n" "// Using SimXMLDocument by itself\n"
"function readXmlExample(%filename)\n" "function readXmlExample(%filename)\n"
"{\n" "{\n"
" %xml = new SimXMLDocument() {};\n" " %xml = new SimXMLDocument() {};\n"
" %xml.loadFile(%filename);\n\n" " %xml.loadFile(%filename);\n\n"
" %xml.pushChildElement(\"DataTables\");\n" " %xml.pushChildElement(\"DataTables\");\n"
" %xml.pushFirstChildElement(\"table\");\n" " %xml.pushFirstChildElement(\"table\");\n"
" while(true)\n" " while(true)\n"
" {\n" " {\n"
" echo(\"TABLE:\" SPC %xml.attribute(\"tableName\"));\n" " echo(\"TABLE:\" SPC %xml.attribute(\"tableName\"));\n"
" %xml.pushFirstChildElement(\"rec\");\n" " %xml.pushFirstChildElement(\"rec\");\n"
" while (true)\n" " while (true)\n"
" {\n" " {\n"
" %id = %xml.attribute(\"id\");\n" " %id = %xml.attribute(\"id\");\n"
" %desc = %xml.getData();\n" " %desc = %xml.getData();\n"
" echo(\" Shape\" SPC %id SPC %desc);\n" " echo(\" Shape\" SPC %id SPC %desc);\n"
" if (!%xml.nextSiblingElement(\"rec\")) break;\n" " if (!%xml.nextSiblingElement(\"rec\")) break;\n"
" }\n" " }\n"
" %xml.popElement();\n" " %xml.popElement();\n"
" if (!%xml.nextSiblingElement(\"table\")) break;\n" " if (!%xml.nextSiblingElement(\"table\")) break;\n"
" }\n" " }\n"
"}\n\n" "}\n\n"
"// Thanks to Scott Peal for this example\n" "// Thanks to Scott Peal for this example\n"
"// Using FileObject in conjunction with SimXMLDocument\n" "// Using FileObject in conjunction with SimXMLDocument\n"
@ -90,45 +90,45 @@ ConsoleDocClass( SimXMLDocument,
"// <Models>\n" "// <Models>\n"
"// <Model category=\"\" name=\"\" path=\"\" />\n" "// <Model category=\"\" name=\"\" path=\"\" />\n"
"// </Models>\n" "// </Models>\n"
"function getModelsInCatagory()\n" "function getModelsInCatagory()\n"
"{\n" "{\n"
" %file = \"./Catalog.xml\";\n" " %file = \"./Catalog.xml\";\n"
" %fo = new FileObject();\n" " %fo = new FileObject();\n"
" %text = \"\";\n\n" " %text = \"\";\n\n"
" if(%fo.openForRead(%file))\n" " if(%fo.openForRead(%file))\n"
" {\n" " {\n"
" while(!%fo.isEOF())\n" " while(!%fo.isEOF())\n"
" {\n" " {\n"
" %text = %text @ %fo.readLine();\n" " %text = %text @ %fo.readLine();\n"
" if (!%fo.isEOF()) %text = %text @ \"\\n\";\n" " if (!%fo.isEOF()) %text = %text @ \"\\n\";\n"
" }\n" " }\n"
" }\n" " }\n"
" else\n" " else\n"
" {\n" " {\n"
" echo(\"Unable to locate the file: \" @ %file);\n" " echo(\"Unable to locate the file: \" @ %file);\n"
" }\n\n" " }\n\n"
" %fo.delete();\n\n" " %fo.delete();\n\n"
" %xml = new SimXMLDocument() {};\n" " %xml = new SimXMLDocument() {};\n"
" %xml.parse(%text);\n" " %xml.parse(%text);\n"
" // \"Get\" inside of the root element, \"Models\".\n" " // \"Get\" inside of the root element, \"Models\".\n"
" %xml.pushChildElement(0);\n\n" " %xml.pushChildElement(0);\n\n"
" // \"Get\" into the first child element\n" " // \"Get\" into the first child element\n"
" if (%xml.pushFirstChildElement(\"Model\"))\n" " if (%xml.pushFirstChildElement(\"Model\"))\n"
" {\n" " {\n"
" while (true)\n" " while (true)\n"
" {\n" " {\n"
" // \n" " // \n"
" // Here, i read the element's attributes.\n" " // Here, i read the element's attributes.\n"
" // You might want to save these values in an array or call the %xml.getElementValue()\n" " // You might want to save these values in an array or call the %xml.getElementValue()\n"
" // if you have a different XML structure.\n\n" " // if you have a different XML structure.\n\n"
" %catagory = %xml.attribute(\"catagory\");\n" " %catagory = %xml.attribute(\"catagory\");\n"
" %name = %xml.attribute(\"name\");\n" " %name = %xml.attribute(\"name\");\n"
" %path = %xml.attribute(\"path\");\n\n" " %path = %xml.attribute(\"path\");\n\n"
" // now, read the next \"Model\"\n" " // now, read the next \"Model\"\n"
" if (!%xml.nextSiblingElement(\"Model\")) break;\n" " if (!%xml.nextSiblingElement(\"Model\")) break;\n"
" }\n" " }\n"
" }\n" " }\n"
"}\n" "}\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@note SimXMLDocument is a wrapper around TinyXml, a standard XML library. If you're familiar " "@note SimXMLDocument is a wrapper around TinyXml, a standard XML library. If you're familiar "
@ -504,13 +504,13 @@ const char* SimXMLDocument::elementValue()
{ {
if(m_paNode.empty()) if(m_paNode.empty())
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
const S32 iLastElement = m_paNode.size() - 1; const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement]; TiXmlElement* pNode = m_paNode[iLastElement];
if(!pNode) if(!pNode)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
return pNode->Value(); return pNode->Value();
@ -545,18 +545,18 @@ const char* SimXMLDocument::attribute(const char* rAttribute)
{ {
if(m_paNode.empty()) if(m_paNode.empty())
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
const S32 iLastElement = m_paNode.size() - 1; const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement]; TiXmlElement* pNode = m_paNode[iLastElement];
if(!pNode) if(!pNode)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
if(!pNode->Attribute(rAttribute)) if(!pNode->Attribute(rAttribute))
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
return pNode->Attribute(rAttribute); return pNode->Attribute(rAttribute);
@ -629,20 +629,20 @@ const char* SimXMLDocument::firstAttribute()
// Get the current element // Get the current element
if(m_paNode.empty()) if(m_paNode.empty())
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
const S32 iLastElement = m_paNode.size() - 1; const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement]; TiXmlElement* pNode = m_paNode[iLastElement];
if(!pNode) if(!pNode)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
// Gets its first attribute, if any // Gets its first attribute, if any
m_CurrentAttribute = pNode->FirstAttribute(); m_CurrentAttribute = pNode->FirstAttribute();
if(!m_CurrentAttribute) if(!m_CurrentAttribute)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
return m_CurrentAttribute->Name(); return m_CurrentAttribute->Name();
@ -666,20 +666,20 @@ const char* SimXMLDocument::lastAttribute()
// Get the current element // Get the current element
if(m_paNode.empty()) if(m_paNode.empty())
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
const S32 iLastElement = m_paNode.size() - 1; const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement]; TiXmlElement* pNode = m_paNode[iLastElement];
if(!pNode) if(!pNode)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
// Gets its last attribute, if any // Gets its last attribute, if any
m_CurrentAttribute = pNode->LastAttribute(); m_CurrentAttribute = pNode->LastAttribute();
if(!m_CurrentAttribute) if(!m_CurrentAttribute)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
return m_CurrentAttribute->Name(); return m_CurrentAttribute->Name();
@ -703,14 +703,14 @@ const char* SimXMLDocument::nextAttribute()
{ {
if(!m_CurrentAttribute) if(!m_CurrentAttribute)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
// Gets its next attribute, if any // Gets its next attribute, if any
m_CurrentAttribute = m_CurrentAttribute->Next(); m_CurrentAttribute = m_CurrentAttribute->Next();
if(!m_CurrentAttribute) if(!m_CurrentAttribute)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
return m_CurrentAttribute->Name(); return m_CurrentAttribute->Name();
@ -734,14 +734,14 @@ const char* SimXMLDocument::prevAttribute()
{ {
if(!m_CurrentAttribute) if(!m_CurrentAttribute)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
// Gets its next attribute, if any // Gets its next attribute, if any
m_CurrentAttribute = m_CurrentAttribute->Previous(); m_CurrentAttribute = m_CurrentAttribute->Previous();
if(!m_CurrentAttribute) if(!m_CurrentAttribute)
{ {
return StringTable->insert(""); return StringTable->EmptyString();
} }
return m_CurrentAttribute->Name(); return m_CurrentAttribute->Name();

View file

@ -411,7 +411,7 @@ ObjectDeclNode *ObjectDeclNode::alloc( S32 lineNumber, ExprNode *classNameExpr,
if(parentObject) if(parentObject)
ret->parentObject = parentObject; ret->parentObject = parentObject;
else else
ret->parentObject = StringTable->insert(""); ret->parentObject = StringTable->EmptyString();
return ret; return ret;
} }

View file

@ -435,7 +435,7 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
if(offset < globalSize) if(offset < globalSize)
ste = StringTable->insert(globalStrings + offset); ste = StringTable->insert(globalStrings + offset);
else else
ste = StringTable->insert(""); ste = StringTable->EmptyString();
U32 count; U32 count;
st.read(&count); st.read(&count);
while(count--) while(count--)
@ -455,8 +455,8 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso) bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso)
{ {
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread"); AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
// This will return true, but return value is ignored // This will return true, but return value is ignored
char *script; char *script;
chompUTF8BOM( inScript, &script ); chompUTF8BOM( inScript, &script );
@ -572,8 +572,8 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame) ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame)
{ {
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread"); AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
// Check for a UTF8 script file // Check for a UTF8 script file
char *string; char *string;
chompUTF8BOM( inString, &string ); chompUTF8BOM( inString, &string );

View file

@ -41,8 +41,8 @@ ConsoleDocClass( FieldBrushObject,
FieldBrushObject::FieldBrushObject() FieldBrushObject::FieldBrushObject()
{ {
// Reset Description. // Reset Description.
mDescription = StringTable->insert(""); mDescription = StringTable->EmptyString();
mSortName = StringTable->insert(""); mSortName = StringTable->EmptyString();
} }
@ -109,15 +109,15 @@ void FieldBrushObject::destroyFields()
static char replacebuf[1024]; static char replacebuf[1024];
static char* suppressSpaces(const char* in_pname) static char* suppressSpaces(const char* in_pname)
{ {
U32 i = 0; U32 i = 0;
char chr; char chr;
do do
{ {
chr = in_pname[i]; chr = in_pname[i];
replacebuf[i++] = (chr != 32) ? chr : '_'; replacebuf[i++] = (chr != 32) ? chr : '_';
} while(chr); } while(chr);
return replacebuf; return replacebuf;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -125,7 +125,7 @@ static char* suppressSpaces(const char* in_pname)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* simObjName), , "(simObject) Query available static-field groups for selected object./\n" DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* simObjName), , "(simObject) Query available static-field groups for selected object./\n"
"@param simObject Object to query static-field groups on.\n" "@param simObject Object to query static-field groups on.\n"
"@return Space-seperated static-field group list.") "@return Space-seperated static-field group list.")
{ {
// Fetch selected object. // Fetch selected object.
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) ); SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
@ -194,7 +194,7 @@ DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* sim
DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* simObjName, const char* groupList), (""), "(simObject, [groupList]) Query available static-fields for selected object./\n" DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* simObjName, const char* groupList), (""), "(simObject, [groupList]) Query available static-fields for selected object./\n"
"@param simObject Object to query static-fields on.\n" "@param simObject Object to query static-fields on.\n"
"@param groupList groups to filter static-fields against.\n" "@param groupList groups to filter static-fields against.\n"
"@return Space-seperated static-field list.") "@return Space-seperated static-field list.")
{ {
// Fetch selected object. // Fetch selected object.
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) ); SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
@ -369,7 +369,7 @@ DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* sim
DefineConsoleMethod(FieldBrushObject, copyFields, void, (const char* simObjName, const char* pFieldList), (""), "(simObject, [fieldList]) Copy selected static-fields for selected object./\n" DefineConsoleMethod(FieldBrushObject, copyFields, void, (const char* simObjName, const char* pFieldList), (""), "(simObject, [fieldList]) Copy selected static-fields for selected object./\n"
"@param simObject Object to copy static-fields from.\n" "@param simObject Object to copy static-fields from.\n"
"@param fieldList fields to filter static-fields against.\n" "@param fieldList fields to filter static-fields against.\n"
"@return No return value.") "@return No return value.")
{ {
// Fetch selected object. // Fetch selected object.
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) ); SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
@ -502,7 +502,7 @@ void FieldBrushObject::copyFields( SimObject* pSimObject, const char* fieldList
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineConsoleMethod(FieldBrushObject, pasteFields, void, (const char* simObjName), , "(simObject) Paste copied static-fields to selected object./\n" DefineConsoleMethod(FieldBrushObject, pasteFields, void, (const char* simObjName), , "(simObject) Paste copied static-fields to selected object./\n"
"@param simObject Object to paste static-fields to.\n" "@param simObject Object to paste static-fields to.\n"
"@return No return value.") "@return No return value.")
{ {
// Fetch selected object. // Fetch selected object.
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) ); SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );

View file

@ -210,7 +210,7 @@ DefineEngineFunction( findNextFile, String, ( const char* pattern ), ( "" ),
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineFunction( getFileCount, S32, ( const char* pattern, bool recurse ), ( "", true ), DefineEngineFunction( getFileCount, S32, ( const char* pattern, bool recurse ), ( "", true ),
"@brief Returns the number of files in the directory tree that match the given patterns\n\n" "@brief Returns the number of files in the directory tree that match the given patterns\n\n"
"This function differs from getFileCountMultiExpr() in that it supports a single search " "This function differs from getFileCountMultiExpr() in that it supports a single search "
"pattern being passed in.\n\n" "pattern being passed in.\n\n"
@ -246,7 +246,7 @@ DefineEngineFunction( getFileCount, S32, ( const char* pattern, bool recurse ),
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool recurse ), ( "", true), DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool recurse ), ( "", true),
"@brief Returns the first file in the directory system matching the given patterns.\n\n" "@brief Returns the first file in the directory system matching the given patterns.\n\n"
"Use the corresponding findNextFileMultiExpr() to step through " "Use the corresponding findNextFileMultiExpr() to step through "
"the results. If you're only interested in the number of files returned by the " "the results. If you're only interested in the number of files returned by the "
@ -259,10 +259,10 @@ DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool
"call to findFirstFile() and findFirstFileMultiExpr() initiates a new search and renders " "call to findFirstFile() and findFirstFileMultiExpr() initiates a new search and renders "
"a previous search invalid.\n\n" "a previous search invalid.\n\n"
"@param pattern The path and file name pattern to match against, such as *.cs. Separate " "@param pattern The path and file name pattern to match against, such as *.cs. Separate "
"multiple patterns with TABs. For example: \"*.cs\" TAB \"*.dso\"\n" "multiple patterns with TABs. For example: \"*.cs\" TAB \"*.dso\"\n"
"@param recurse If true, the search will exhaustively recurse into subdirectories " "@param recurse If true, the search will exhaustively recurse into subdirectories "
"of the given path and match the given filename patterns.\n" "of the given path and match the given filename patterns.\n"
"@return String of the first matching file path, or an empty string if no matching " "@return String of the first matching file path, or an empty string if no matching "
"files were found.\n\n" "files were found.\n\n"
@ -280,7 +280,7 @@ DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool
"@see findNextFileMultiExpr()" "@see findNextFileMultiExpr()"
"@see getFileCountMultiExpr()" "@see getFileCountMultiExpr()"
"@see findFirstFile()" "@see findFirstFile()"
"@ingroup FileSearches") "@ingroup FileSearches")
{ {
S32 numResults = buildFileList(pattern, recurse, true); S32 numResults = buildFileList(pattern, recurse, true);
@ -302,7 +302,7 @@ DefineEngineFunction(findFirstFileMultiExpr, String, ( const char* pattern, bool
DefineEngineFunction(findNextFileMultiExpr, String, ( const char* pattern ), (""), DefineEngineFunction(findNextFileMultiExpr, String, ( const char* pattern ), (""),
"@brief Returns the next file matching a search begun in findFirstFileMultiExpr().\n\n" "@brief Returns the next file matching a search begun in findFirstFileMultiExpr().\n\n"
"@param pattern The path and file name pattern to match against. This is optional " "@param pattern The path and file name pattern to match against. This is optional "
"and may be left out as it is not used by the code. It is here for legacy reasons.\n" "and may be left out as it is not used by the code. It is here for legacy reasons.\n"
"@return String of the next matching file path, or an empty string if no matching " "@return String of the next matching file path, or an empty string if no matching "
"files were found.\n\n" "files were found.\n\n"
@ -319,7 +319,7 @@ DefineEngineFunction(findNextFileMultiExpr, String, ( const char* pattern ), (""
"@endtsexample\n\n" "@endtsexample\n\n"
"@see findFirstFileMultiExpr()" "@see findFirstFileMultiExpr()"
"@ingroup FileSearches") "@ingroup FileSearches")
{ {
if ( sgFindFilesPos + 1 > sgFindFilesResults.size() ) if ( sgFindFilesPos + 1 > sgFindFilesResults.size() )
return String(); return String();
@ -328,16 +328,16 @@ DefineEngineFunction(findNextFileMultiExpr, String, ( const char* pattern ), (""
} }
DefineEngineFunction(getFileCountMultiExpr, S32, ( const char* pattern, bool recurse ), ( "", true), DefineEngineFunction(getFileCountMultiExpr, S32, ( const char* pattern, bool recurse ), ( "", true),
"@brief Returns the number of files in the directory tree that match the given patterns\n\n" "@brief Returns the number of files in the directory tree that match the given patterns\n\n"
"If you're interested in a list of files that match the given patterns and not just " "If you're interested in a list of files that match the given patterns and not just "
"the number of files, use findFirstFileMultiExpr() and findNextFileMultiExpr().\n\n" "the number of files, use findFirstFileMultiExpr() and findNextFileMultiExpr().\n\n"
"@param pattern The path and file name pattern to match against, such as *.cs. Separate " "@param pattern The path and file name pattern to match against, such as *.cs. Separate "
"multiple patterns with TABs. For example: \"*.cs\" TAB \"*.dso\"\n" "multiple patterns with TABs. For example: \"*.cs\" TAB \"*.dso\"\n"
"@param recurse If true, the search will exhaustively recurse into subdirectories " "@param recurse If true, the search will exhaustively recurse into subdirectories "
"of the given path and match the given filename pattern.\n" "of the given path and match the given filename pattern.\n"
"@return Number of files located using the patterns\n\n" "@return Number of files located using the patterns\n\n"
"@tsexample\n" "@tsexample\n"
"// Count all DTS or Collada models\n" "// Count all DTS or Collada models\n"
@ -347,7 +347,7 @@ DefineEngineFunction(getFileCountMultiExpr, S32, ( const char* pattern, bool rec
"@see findFirstFileMultiExpr()" "@see findFirstFileMultiExpr()"
"@see findNextFileMultiExpr()" "@see findNextFileMultiExpr()"
"@ingroup FileSearches") "@ingroup FileSearches")
{ {
S32 numResults = buildFileList(pattern, recurse, true); S32 numResults = buildFileList(pattern, recurse, true);
@ -399,14 +399,14 @@ DefineEngineFunction(isFile, bool, ( const char* fileName ),,
} }
DefineEngineFunction( IsDirectory, bool, ( const char* directory ),, DefineEngineFunction( IsDirectory, bool, ( const char* directory ),,
"@brief Determines if a specified directory exists or not\n\n" "@brief Determines if a specified directory exists or not\n\n"
"@param directory String containing path in the form of \"foo/bar\"\n" "@param directory String containing path in the form of \"foo/bar\"\n"
"@return Returns true if the directory was found.\n" "@return Returns true if the directory was found.\n"
"@note Do not include a trailing slash '/'.\n" "@note Do not include a trailing slash '/'.\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
String dir(Torque::Path::CleanSeparators(directory)); String dir(Torque::Path::CleanSeparators(directory));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), dir.c_str()); Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), dir.c_str());
@ -416,12 +416,12 @@ DefineEngineFunction( IsDirectory, bool, ( const char* directory ),,
} }
DefineEngineFunction(isWriteableFileName, bool, ( const char* fileName ),, DefineEngineFunction(isWriteableFileName, bool, ( const char* fileName ),,
"@brief Determines if a file name can be written to using File I/O\n\n" "@brief Determines if a file name can be written to using File I/O\n\n"
"@param fileName Name and path of file to check\n" "@param fileName Name and path of file to check\n"
"@return Returns true if the file can be written to.\n" "@return Returns true if the file can be written to.\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
String filename(Torque::Path::CleanSeparators(fileName)); String filename(Torque::Path::CleanSeparators(fileName));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), filename.c_str()); Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), filename.c_str());
@ -434,32 +434,32 @@ DefineEngineFunction(isWriteableFileName, bool, ( const char* fileName ),,
} }
DefineEngineFunction(startFileChangeNotifications, void, (),, DefineEngineFunction(startFileChangeNotifications, void, (),,
"@brief Start watching resources for file changes\n\n" "@brief Start watching resources for file changes\n\n"
"Typically this is called during initializeCore().\n\n" "Typically this is called during initializeCore().\n\n"
"@see stopFileChangeNotifications()\n" "@see stopFileChangeNotifications()\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
Torque::FS::StartFileChangeNotifications(); Torque::FS::StartFileChangeNotifications();
} }
DefineEngineFunction(stopFileChangeNotifications, void, (),, DefineEngineFunction(stopFileChangeNotifications, void, (),,
"@brief Stop watching resources for file changes\n\n" "@brief Stop watching resources for file changes\n\n"
"Typically this is called during shutdownCore().\n\n" "Typically this is called during shutdownCore().\n\n"
"@see startFileChangeNotifications()\n" "@see startFileChangeNotifications()\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
Torque::FS::StopFileChangeNotifications(); Torque::FS::StopFileChangeNotifications();
} }
DefineEngineFunction(getDirectoryList, String, ( const char* path, S32 depth ), ( "", 0 ), DefineEngineFunction(getDirectoryList, String, ( const char* path, S32 depth ), ( "", 0 ),
"@brief Gathers a list of directories starting at the given path.\n\n" "@brief Gathers a list of directories starting at the given path.\n\n"
"@param path String containing the path of the directory\n" "@param path String containing the path of the directory\n"
"@param depth Depth of search, as in how many subdirectories to parse through\n" "@param depth Depth of search, as in how many subdirectories to parse through\n"
"@return Tab delimited string containing list of directories found during search, \"\" if no files were found\n" "@return Tab delimited string containing list of directories found during search, \"\" if no files were found\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
// Grab the full path. // Grab the full path.
char fullpath[1024]; char fullpath[1024];
@ -508,23 +508,23 @@ DefineEngineFunction(getDirectoryList, String, ( const char* path, S32 depth ),
} }
DefineEngineFunction(fileSize, S32, ( const char* fileName ),, DefineEngineFunction(fileSize, S32, ( const char* fileName ),,
"@brief Determines the size of a file on disk\n\n" "@brief Determines the size of a file on disk\n\n"
"@param fileName Name and path of the file to check\n" "@param fileName Name and path of the file to check\n"
"@return Returns filesize in bytes, or -1 if no file\n" "@return Returns filesize in bytes, or -1 if no file\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName); Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName);
return Platform::getFileSize( sgScriptFilenameBuffer ); return Platform::getFileSize( sgScriptFilenameBuffer );
} }
DefineEngineFunction( fileModifiedTime, String, ( const char* fileName ),, DefineEngineFunction( fileModifiedTime, String, ( const char* fileName ),,
"@brief Returns a platform specific formatted string with the last modified time for the file.\n\n" "@brief Returns a platform specific formatted string with the last modified time for the file.\n\n"
"@param fileName Name and path of file to check\n" "@param fileName Name and path of file to check\n"
"@return Formatted string (OS specific) containing modified time, \"9/3/2010 12:33:47 PM\" for example\n" "@return Formatted string (OS specific) containing modified time, \"9/3/2010 12:33:47 PM\" for example\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName); Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName);
@ -566,12 +566,12 @@ DefineEngineFunction( fileCreatedTime, String, ( const char* fileName ),,
} }
DefineEngineFunction(fileDelete, bool, ( const char* path ),, DefineEngineFunction(fileDelete, bool, ( const char* path ),,
"@brief Delete a file from the hard drive\n\n" "@brief Delete a file from the hard drive\n\n"
"@param path Name and path of the file to delete\n" "@param path Name and path of the file to delete\n"
"@note THERE IS NO RECOVERY FROM THIS. Deleted file is gone for good.\n" "@note THERE IS NO RECOVERY FROM THIS. Deleted file is gone for good.\n"
"@return True if file was successfully deleted\n" "@return True if file was successfully deleted\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
static char fileName[1024]; static char fileName[1024];
static char sandboxFileName[1024]; static char sandboxFileName[1024];
@ -586,11 +586,11 @@ DefineEngineFunction(fileDelete, bool, ( const char* path ),,
//---------------------------------------------------------------- //----------------------------------------------------------------
DefineEngineFunction(fileExt, String, ( const char* fileName ),, DefineEngineFunction(fileExt, String, ( const char* fileName ),,
"@brief Get the extension of a file\n\n" "@brief Get the extension of a file\n\n"
"@param fileName Name and path of file\n" "@param fileName Name and path of file\n"
"@return String containing the extension, such as \".exe\" or \".cs\"\n" "@return String containing the extension, such as \".exe\" or \".cs\"\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
const char *ret = dStrrchr(fileName, '.'); const char *ret = dStrrchr(fileName, '.');
if(ret) if(ret)
@ -626,11 +626,11 @@ DefineEngineFunction(fileBase, String, ( const char* fileName ),,
} }
DefineEngineFunction(fileName, String, ( const char* fileName ),, DefineEngineFunction(fileName, String, ( const char* fileName ),,
"@brief Get only the file name of a path and file name string (removes path)\n\n" "@brief Get only the file name of a path and file name string (removes path)\n\n"
"@param fileName Name and path of file to check\n" "@param fileName Name and path of file to check\n"
"@return String containing the file name, minus the path\n" "@return String containing the file name, minus the path\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
S32 pathLen = dStrlen( fileName ); S32 pathLen = dStrlen( fileName );
FrameTemp<char> szPathCopy( pathLen + 1); FrameTemp<char> szPathCopy( pathLen + 1);
@ -649,11 +649,11 @@ DefineEngineFunction(fileName, String, ( const char* fileName ),,
} }
DefineEngineFunction(filePath, String, ( const char* fileName ),, DefineEngineFunction(filePath, String, ( const char* fileName ),,
"@brief Get the path of a file (removes name and extension)\n\n" "@brief Get the path of a file (removes name and extension)\n\n"
"@param fileName Name and path of file to check\n" "@param fileName Name and path of file to check\n"
"@return String containing the path, minus name and extension\n" "@return String containing the path, minus name and extension\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
S32 pathLen = dStrlen( fileName ); S32 pathLen = dStrlen( fileName );
FrameTemp<char> szPathCopy( pathLen + 1); FrameTemp<char> szPathCopy( pathLen + 1);
@ -672,10 +672,10 @@ DefineEngineFunction(filePath, String, ( const char* fileName ),,
} }
DefineEngineFunction(getWorkingDirectory, String, (),, DefineEngineFunction(getWorkingDirectory, String, (),,
"@brief Reports the current directory\n\n" "@brief Reports the current directory\n\n"
"@return String containing full file path of working directory\n" "@return String containing full file path of working directory\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
return Platform::getCurrentDirectory(); return Platform::getCurrentDirectory();
} }
@ -687,13 +687,13 @@ DefineEngineFunction(getWorkingDirectory, String, (),,
// are not currently built with TORQUE_TOOLS defined. // are not currently built with TORQUE_TOOLS defined.
DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd ), ( "", ""), DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd ), ( "", ""),
"@brief Converts a relative file path to a full path\n\n" "@brief Converts a relative file path to a full path\n\n"
"For example, \"./console.log\" becomes \"C:/Torque/t3d/examples/FPS Example/game/console.log\"\n" "For example, \"./console.log\" becomes \"C:/Torque/t3d/examples/FPS Example/game/console.log\"\n"
"@param path Name of file or path to check\n" "@param path Name of file or path to check\n"
"@param cwd Optional current working directory from which to build the full path.\n" "@param cwd Optional current working directory from which to build the full path.\n"
"@return String containing non-relative directory of path\n" "@return String containing non-relative directory of path\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
static const U32 bufSize = 512; static const U32 bufSize = 512;
char *buf = Con::getReturnBuffer(bufSize); char *buf = Con::getReturnBuffer(bufSize);
@ -702,25 +702,25 @@ DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd )
} }
DefineEngineFunction(makeRelativePath, String, ( const char* path, const char* to ), ( "", ""), DefineEngineFunction(makeRelativePath, String, ( const char* path, const char* to ), ( "", ""),
"@brief Turns a full or local path to a relative one\n\n" "@brief Turns a full or local path to a relative one\n\n"
"For example, \"./game/art\" becomes \"game/art\"\n" "For example, \"./game/art\" becomes \"game/art\"\n"
"@param path Full path (may include a file) to convert\n" "@param path Full path (may include a file) to convert\n"
"@param to Optional base path used for the conversion. If not supplied the current " "@param to Optional base path used for the conversion. If not supplied the current "
"working directory is used.\n" "working directory is used.\n"
"@returns String containing relative path\n" "@returns String containing relative path\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
return Platform::makeRelativePathName( path, dStrlen(to) > 1 ? to : NULL ); return Platform::makeRelativePathName( path, dStrlen(to) > 1 ? to : NULL );
} }
DefineEngineFunction(pathConcat, String, ( const char* path, const char* file), ( "", ""), DefineEngineFunction(pathConcat, String, ( const char* path, const char* file), ( "", ""),
"@brief Combines two separate strings containing a file path and file name together into a single string\n\n" "@brief Combines two separate strings containing a file path and file name together into a single string\n\n"
"@param path String containing file path\n" "@param path String containing file path\n"
"@param file String containing file name\n" "@param file String containing file name\n"
"@return String containing concatenated file name and path\n" "@return String containing concatenated file name and path\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
static const U32 bufSize = 1024; static const U32 bufSize = 1024;
char *buf = Con::getReturnBuffer(bufSize); char *buf = Con::getReturnBuffer(bufSize);
@ -731,10 +731,10 @@ DefineEngineFunction(pathConcat, String, ( const char* path, const char* file),
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineFunction(getExecutableName, String, (),, DefineEngineFunction(getExecutableName, String, (),,
"@brief Gets the name of the game's executable\n\n" "@brief Gets the name of the game's executable\n\n"
"@return String containing this game's executable name\n" "@return String containing this game's executable name\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
return Platform::getExecutableName(); return Platform::getExecutableName();
} }

View file

@ -34,22 +34,22 @@
IMPLEMENT_CONOBJECT(PersistenceManager); IMPLEMENT_CONOBJECT(PersistenceManager);
ConsoleDocClass( PersistenceManager, ConsoleDocClass( PersistenceManager,
"@brief this class manages updating SimObjects in the file they were " "@brief this class manages updating SimObjects in the file they were "
"created in non-destructively (mostly aimed at datablocks and materials).\n\n" "created in non-destructively (mostly aimed at datablocks and materials).\n\n"
"Basic scripting interface:\n\n" "Basic scripting interface:\n\n"
" - Creation: new PersistenceManager(FooManager);\n" " - Creation: new PersistenceManager(FooManager);\n"
" - Flag objects as dirty: FooManager.setDirty(<object name or id>);\n" " - Flag objects as dirty: FooManager.setDirty(<object name or id>);\n"
" - Remove objects from dirty list: FooManager.removeDirty(<object name or id>);\n" " - Remove objects from dirty list: FooManager.removeDirty(<object name or id>);\n"
" - List all currently dirty objects: FooManager.listDirty();\n" " - List all currently dirty objects: FooManager.listDirty();\n"
" - Check to see if an object is dirty: FooManager.isDirty(<object name or id>);\n" " - Check to see if an object is dirty: FooManager.isDirty(<object name or id>);\n"
" - Save dirty objects to their files: FooManager.saveDirty();\n\n" " - Save dirty objects to their files: FooManager.saveDirty();\n\n"
"@note Dirty objects don't update their files until saveDirty() is " "@note Dirty objects don't update their files until saveDirty() is "
"called so you can change their properties after you flag them as dirty\n\n" "called so you can change their properties after you flag them as dirty\n\n"
"@note Currently only used by editors, not intended for actual game development\n\n" "@note Currently only used by editors, not intended for actual game development\n\n"
"@ingroup Console\n" "@ingroup Console\n"
"@ingroup Editors\n" "@ingroup Editors\n"
"@internal"); "@internal");
PersistenceManager::PersistenceManager() PersistenceManager::PersistenceManager()
{ {
@ -328,7 +328,7 @@ void PersistenceManager::parseObject()
if (mParser.tokenICmp(")")) if (mParser.tokenICmp(")"))
{ {
mCurrentObject->name = StringTable->insert(""); mCurrentObject->name = StringTable->EmptyString();
mCurrentObject->nameLine = mParser.getCurrentLine(); mCurrentObject->nameLine = mParser.getCurrentLine();
mCurrentObject->namePosition = mParser.getTokenLineOffset(); mCurrentObject->namePosition = mParser.getTokenLineOffset();
@ -890,7 +890,7 @@ PersistenceManager::ParsedObject* PersistenceManager::findParsedObject(SimObject
{ {
const ParsedProperty &prop = testObj->properties[j]; const ParsedProperty &prop = testObj->properties[j];
if ( dStrcmp( prop.name, "internalName" ) == 0 && if ( dStrcmp( prop.name, "internalName" ) == 0 &&
dStrcmp( prop.value, object->getInternalName() ) == 0 ) dStrcmp( prop.value, object->getInternalName() ) == 0 )
return testObj; return testObj;
else if ( dStrcmp(prop.name, "internalName") == 0) else if ( dStrcmp(prop.name, "internalName") == 0)
@ -2037,24 +2037,24 @@ bool PersistenceManager::saveDirtyObject(SimObject* object)
const char *name = object->getName(); const char *name = object->getName();
if (name) if (name)
{ {
Con::errorf("PersistenceManager::saveDirtyObject(): Unable to open %s to save %s %s (%d)", Con::errorf("PersistenceManager::saveDirtyObject(): Unable to open %s to save %s %s (%d)",
dirtyObject.fileName, object->getClassName(), name, object->getId()); dirtyObject.fileName, object->getClassName(), name, object->getId());
} }
else else
{ {
Con::errorf("PersistenceManager::saveDirtyObject(): Unable to open %s to save %s (%d)", Con::errorf("PersistenceManager::saveDirtyObject(): Unable to open %s to save %s (%d)",
dirtyObject.fileName, object->getClassName(), object->getId()); dirtyObject.fileName, object->getClassName(), object->getId());
} }
return false; return false;
} }
// if the file exists then lets update and save // if the file exists then lets update and save
if(mCurrentFile) if(mCurrentFile)
{ {
updateObject(object); updateObject(object);
saveDirtyFile(); saveDirtyFile();
} }
break; break;
} }
@ -2230,7 +2230,7 @@ DefineConsoleMethod( PersistenceManager, removeDirty, void, ( const char * objNa
"Remove a SimObject from the dirty list.") "Remove a SimObject from the dirty list.")
{ {
SimObject *dirtyObject = NULL; SimObject *dirtyObject = NULL;
if (dStrcmp( objName,"")!=0) if (dStrcmp( objName,"")!=0)
{ {
if (!Sim::findObject(objName, dirtyObject)) if (!Sim::findObject(objName, dirtyObject))
{ {

View file

@ -343,10 +343,10 @@ bool collapseScriptFilename(char *filename, U32 size, const char *src)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ConsoleFunction(expandFilename, const char*, 2, 2, "(string filename)" ConsoleFunction(expandFilename, const char*, 2, 2, "(string filename)"
"@brief Grabs the full path of a specified file\n\n" "@brief Grabs the full path of a specified file\n\n"
"@param filename Name of the local file to locate\n" "@param filename Name of the local file to locate\n"
"@return String containing the full filepath on disk\n" "@return String containing the full filepath on disk\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
TORQUE_UNUSED(argc); TORQUE_UNUSED(argc);
static const U32 bufSize = 1024; static const U32 bufSize = 1024;
@ -356,9 +356,9 @@ ConsoleFunction(expandFilename, const char*, 2, 2, "(string filename)"
} }
ConsoleFunction(expandOldFilename, const char*, 2, 2, "(string filename)" ConsoleFunction(expandOldFilename, const char*, 2, 2, "(string filename)"
"@brief Retrofits a filepath that uses old Torque style\n\n" "@brief Retrofits a filepath that uses old Torque style\n\n"
"@return String containing filepath with new formatting\n" "@return String containing filepath with new formatting\n"
"@ingroup FileSystem") "@ingroup FileSystem")
{ {
TORQUE_UNUSED(argc); TORQUE_UNUSED(argc);
static const U32 bufSize = 1024; static const U32 bufSize = 1024;
@ -372,7 +372,7 @@ ConsoleFunction(expandOldFilename, const char*, 2, 2, "(string filename)"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ConsoleToolFunction(collapseFilename, const char*, 2, 2, "(string filename)" ConsoleToolFunction(collapseFilename, const char*, 2, 2, "(string filename)"
"@internal Editor use only") "@internal Editor use only")
{ {
TORQUE_UNUSED(argc); TORQUE_UNUSED(argc);
static const U32 bufSize = 1024; static const U32 bufSize = 1024;
@ -382,7 +382,7 @@ ConsoleToolFunction(collapseFilename, const char*, 2, 2, "(string filename)"
} }
ConsoleToolFunction(setScriptPathExpando, void, 3, 4, "(string expando, string path[, bool toolsOnly])" ConsoleToolFunction(setScriptPathExpando, void, 3, 4, "(string expando, string path[, bool toolsOnly])"
"@internal Editor use only") "@internal Editor use only")
{ {
if(argc == 4) if(argc == 4)
Con::setScriptPathExpando(argv[1], argv[2], dAtob(argv[3])); Con::setScriptPathExpando(argv[1], argv[2], dAtob(argv[3]));
@ -391,13 +391,13 @@ ConsoleToolFunction(setScriptPathExpando, void, 3, 4, "(string expando, string p
} }
ConsoleToolFunction(removeScriptPathExpando, void, 2, 2, "(string expando)" ConsoleToolFunction(removeScriptPathExpando, void, 2, 2, "(string expando)"
"@internal Editor use only") "@internal Editor use only")
{ {
Con::removeScriptPathExpando(argv[1]); Con::removeScriptPathExpando(argv[1]);
} }
ConsoleToolFunction(isScriptPathExpando, bool, 2, 2, "(string expando)" ConsoleToolFunction(isScriptPathExpando, bool, 2, 2, "(string expando)"
"@internal Editor use only") "@internal Editor use only")
{ {
return Con::isScriptPathExpando(argv[1]); return Con::isScriptPathExpando(argv[1]);
} }

View file

@ -53,13 +53,13 @@ ConsoleDocClass( ScriptObject,
); );
IMPLEMENT_CALLBACK( ScriptObject, onAdd, void, ( SimObjectId ID ), ( ID ), IMPLEMENT_CALLBACK( ScriptObject, onAdd, void, ( SimObjectId ID ), ( ID ),
"Called when this ScriptObject is added to the system.\n" "Called when this ScriptObject is added to the system.\n"
"@param ID Unique object ID assigned when created (%this in script).\n" "@param ID Unique object ID assigned when created (%this in script).\n"
); );
IMPLEMENT_CALLBACK( ScriptObject, onRemove, void, ( SimObjectId ID ), ( ID ), IMPLEMENT_CALLBACK( ScriptObject, onRemove, void, ( SimObjectId ID ), ( ID ),
"Called when this ScriptObject is removed from the system.\n" "Called when this ScriptObject is removed from the system.\n"
"@param ID Unique object ID assigned when created (%this in script).\n" "@param ID Unique object ID assigned when created (%this in script).\n"
); );
ScriptObject::ScriptObject() ScriptObject::ScriptObject()
@ -105,18 +105,18 @@ ConsoleDocClass( ScriptTickObject,
); );
IMPLEMENT_CALLBACK( ScriptTickObject, onInterpolateTick, void, ( F32 delta ), ( delta ), IMPLEMENT_CALLBACK( ScriptTickObject, onInterpolateTick, void, ( F32 delta ), ( delta ),
"This is called every frame, but only if the object is set to process ticks.\n" "This is called every frame, but only if the object is set to process ticks.\n"
"@param delta The time delta for this frame.\n" "@param delta The time delta for this frame.\n"
); );
IMPLEMENT_CALLBACK( ScriptTickObject, onProcessTick, void, (), (), IMPLEMENT_CALLBACK( ScriptTickObject, onProcessTick, void, (), (),
"Called once every 32ms if this object is set to process ticks.\n" "Called once every 32ms if this object is set to process ticks.\n"
); );
IMPLEMENT_CALLBACK( ScriptTickObject, onAdvanceTime, void, ( F32 timeDelta ), ( timeDelta ), IMPLEMENT_CALLBACK( ScriptTickObject, onAdvanceTime, void, ( F32 timeDelta ), ( timeDelta ),
"This is called every frame regardless if the object is set to process ticks, but only " "This is called every frame regardless if the object is set to process ticks, but only "
"if the callOnAdvanceTime property is set to true.\n" "if the callOnAdvanceTime property is set to true.\n"
"@param timeDelta The time delta for this frame.\n" "@param timeDelta The time delta for this frame.\n"
"@see callOnAdvanceTime\n" "@see callOnAdvanceTime\n"
); );
@ -188,37 +188,37 @@ DefineEngineMethod( ScriptTickObject, isProcessingTicks, bool, ( ),,
IMPLEMENT_CONOBJECT(ScriptGroup); IMPLEMENT_CONOBJECT(ScriptGroup);
ConsoleDocClass( ScriptGroup, ConsoleDocClass( ScriptGroup,
"@brief Essentially a SimGroup, but with onAdd and onRemove script callbacks.\n\n" "@brief Essentially a SimGroup, but with onAdd and onRemove script callbacks.\n\n"
"@tsexample\n" "@tsexample\n"
"// First container, SimGroup containing a ScriptGroup\n" "// First container, SimGroup containing a ScriptGroup\n"
"new SimGroup(Scenes)\n" "new SimGroup(Scenes)\n"
"{\n" "{\n"
" // Subcontainer, ScriptGroup containing variables\n" " // Subcontainer, ScriptGroup containing variables\n"
" // related to a cut scene and a starting WayPoint\n" " // related to a cut scene and a starting WayPoint\n"
" new ScriptGroup(WelcomeScene)\n" " new ScriptGroup(WelcomeScene)\n"
" {\n" " {\n"
" class = \"Scene\";\n" " class = \"Scene\";\n"
" pathName = \"Pathx\";\n" " pathName = \"Pathx\";\n"
" description = \"A small orc village set in the Hardesty mountains. This town and its surroundings will be used to illustrate some the Torque Game Engine\'s features.\";\n" " description = \"A small orc village set in the Hardesty mountains. This town and its surroundings will be used to illustrate some the Torque Game Engine\'s features.\";\n"
" pathTime = \"0\";\n" " pathTime = \"0\";\n"
" title = \"Welcome to Orc Town\";\n\n" " title = \"Welcome to Orc Town\";\n\n"
" new WayPoint(start)\n" " new WayPoint(start)\n"
" {\n" " {\n"
" position = \"163.873 -103.82 208.354\";\n" " position = \"163.873 -103.82 208.354\";\n"
" rotation = \"0.136165 -0.0544916 0.989186 44.0527\";\n" " rotation = \"0.136165 -0.0544916 0.989186 44.0527\";\n"
" scale = \"1 1 1\";\n" " scale = \"1 1 1\";\n"
" dataBlock = \"WayPointMarker\";\n" " dataBlock = \"WayPointMarker\";\n"
" team = \"0\";\n" " team = \"0\";\n"
" };\n" " };\n"
" };\n" " };\n"
"};\n" "};\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see SimGroup\n" "@see SimGroup\n"
"@ingroup Console\n" "@ingroup Console\n"
"@ingroup Scripting" "@ingroup Scripting"
); );
ScriptGroup::ScriptGroup() ScriptGroup::ScriptGroup()
@ -226,13 +226,13 @@ ScriptGroup::ScriptGroup()
} }
IMPLEMENT_CALLBACK( ScriptGroup, onAdd, void, ( SimObjectId ID ), ( ID ), IMPLEMENT_CALLBACK( ScriptGroup, onAdd, void, ( SimObjectId ID ), ( ID ),
"Called when this ScriptGroup is added to the system.\n" "Called when this ScriptGroup is added to the system.\n"
"@param ID Unique object ID assigned when created (%this in script).\n" "@param ID Unique object ID assigned when created (%this in script).\n"
); );
IMPLEMENT_CALLBACK( ScriptGroup, onRemove, void, ( SimObjectId ID ), ( ID ), IMPLEMENT_CALLBACK( ScriptGroup, onRemove, void, ( SimObjectId ID ), ( ID ),
"Called when this ScriptObject is removed from the system.\n" "Called when this ScriptObject is removed from the system.\n"
"@param ID Unique object ID assigned when created (%this in script).\n" "@param ID Unique object ID assigned when created (%this in script).\n"
); );
bool ScriptGroup::onAdd() bool ScriptGroup::onAdd()
@ -248,7 +248,7 @@ bool ScriptGroup::onAdd()
void ScriptGroup::onRemove() void ScriptGroup::onRemove()
{ {
// Call onRemove in script! // Call onRemove in script!
onRemove_callback(getId()); onRemove_callback(getId());
Parent::onRemove(); Parent::onRemove();
} }

View file

@ -139,7 +139,7 @@ DefineConsoleFunction( spawnObject, S32, ( const char * spawnClass
, const char * spawnProperties , const char * spawnProperties
, const char * spawnScript , const char * spawnScript
),("","","","") ,"spawnObject(class [, dataBlock, name, properties, script])" ),("","","","") ,"spawnObject(class [, dataBlock, name, properties, script])"
"@hide") "@hide")
{ {
SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript); SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript);
@ -203,12 +203,12 @@ ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1
} }
DefineConsoleFunction( getUniqueName, const char*, (const char * baseName), , DefineConsoleFunction( getUniqueName, const char*, (const char * baseName), ,
"( String baseName )\n" "( String baseName )\n"
"@brief Returns a unique unused SimObject name based on a given base name.\n\n" "@brief Returns a unique unused SimObject name based on a given base name.\n\n"
"@baseName Name to conver to a unique string if another instance exists\n" "@baseName Name to conver to a unique string if another instance exists\n"
"@note Currently only used by editors\n" "@note Currently only used by editors\n"
"@ingroup Editors\n" "@ingroup Editors\n"
"@internal") "@internal")
{ {
String outName = Sim::getUniqueName( baseName ); String outName = Sim::getUniqueName( baseName );
@ -247,10 +247,10 @@ DefineConsoleFunction( getUniqueInternalName, const char*, (const char * baseNam
} }
DefineConsoleFunction( isValidObjectName, bool, (const char * name), , "( string name )" DefineConsoleFunction( isValidObjectName, bool, (const char * name), , "( string name )"
"@brief Return true if the given name makes for a valid object name.\n\n" "@brief Return true if the given name makes for a valid object name.\n\n"
"@param name Name of object\n" "@param name Name of object\n"
"@return True if name is allowed, false if denied (usually because it starts with a number, _, or invalid character" "@return True if name is allowed, false if denied (usually because it starts with a number, _, or invalid character"
"@ingroup Console") "@ingroup Console")
{ {
return Sim::isValidObjectName( name ); return Sim::isValidObjectName( name );
} }

View file

@ -150,7 +150,7 @@ void SimNameDictionary::remove(SimObject* obj)
if(*walk == obj) if(*walk == obj)
{ {
*walk = obj->nextNameObject; *walk = obj->nextNameObject;
obj->nextNameObject = (SimObject*)-1; obj->nextNameObject = (SimObject*)-1;
hashEntryCount--; hashEntryCount--;
Mutex::unlockMutex(mutex); Mutex::unlockMutex(mutex);
@ -164,7 +164,7 @@ void SimNameDictionary::remove(SimObject* obj)
root.erase(name); root.erase(name);
#endif #endif
Mutex::unlockMutex(mutex); Mutex::unlockMutex(mutex);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -279,7 +279,7 @@ void SimManagerNameDictionary::remove(SimObject* obj)
if(*walk == obj) if(*walk == obj)
{ {
*walk = obj->nextManagerNameObject; *walk = obj->nextManagerNameObject;
obj->nextManagerNameObject = (SimObject*)-1; obj->nextManagerNameObject = (SimObject*)-1;
hashEntryCount--; hashEntryCount--;
Mutex::unlockMutex(mutex); Mutex::unlockMutex(mutex);
@ -293,7 +293,7 @@ void SimManagerNameDictionary::remove(SimObject* obj)
root.erase(name); root.erase(name);
#endif #endif
Mutex::unlockMutex(mutex); Mutex::unlockMutex(mutex);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -61,7 +61,7 @@ struct StringTableEntryEq
} }
}; };
typedef std::unordered_map<StringTableEntry, SimObject*, StringTableEntryHash, StringTableEntryEq> StringDictDef; typedef std::unordered_map<StringTableEntry, SimObject*, StringTableEntryHash, StringTableEntryEq> StringDictDef;
typedef std::unordered_map<SimObjectId, SimObject*> SimObjectIdDictDef; typedef std::unordered_map<SimObjectId, SimObject*> SimObjectIdDictDef;
#endif #endif

View file

@ -39,10 +39,10 @@ SimConsoleEvent::SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject)
mArgv[i].value = new ConsoleValue(); mArgv[i].value = new ConsoleValue();
mArgv[i].value->type = ConsoleValue::TypeInternalString; mArgv[i].value->type = ConsoleValue::TypeInternalString;
mArgv[i].value->init(); mArgv[i].value->init();
if (argv) if (argv)
{ {
mArgv[i].value->setStringValue((const char*)argv[i]); mArgv[i].value->setStringValue((const char*)argv[i]);
} }
} }
} }

View file

@ -93,7 +93,7 @@ static void shutdownEventQueue()
U32 postEvent(SimObject *destObject, SimEvent* event,U32 time) U32 postEvent(SimObject *destObject, SimEvent* event,U32 time)
{ {
AssertFatal(time == -1 || time >= getCurrentTime(), AssertFatal(time == -1 || time >= getCurrentTime(),
"Sim::postEvent() - Event time must be greater than or equal to the current time." ); "Sim::postEvent() - Event time must be greater than or equal to the current time." );
AssertFatal(destObject, "Sim::postEvent() - Destination object for event doesn't exist."); AssertFatal(destObject, "Sim::postEvent() - Destination object for event doesn't exist.");
@ -256,7 +256,7 @@ void advanceToTime(SimTime targetTime)
event->process(obj); event->process(obj);
delete event; delete event;
} }
gCurrentTime = targetTime; gCurrentTime = targetTime;
Mutex::unlockMutex(gEventQueueMutex); Mutex::unlockMutex(gEventQueueMutex);
} }
@ -393,7 +393,7 @@ SimObject* findObject(const char* name)
SimObject* findObject(SimObjectId id) SimObject* findObject(SimObjectId id)
{ {
return gIdDictionary->find(id); return gIdDictionary->find(id);
} }
SimObject *spawnObject(String spawnClass, String spawnDataBlock, String spawnName, SimObject *spawnObject(String spawnClass, String spawnDataBlock, String spawnName,
@ -600,7 +600,7 @@ SimDataBlockGroup::SimDataBlockGroup()
S32 QSORT_CALLBACK SimDataBlockGroup::compareModifiedKey(const void* a,const void* b) S32 QSORT_CALLBACK SimDataBlockGroup::compareModifiedKey(const void* a,const void* b)
{ {
const SimDataBlock* dba = *((const SimDataBlock**)a); const SimDataBlock* dba = *((const SimDataBlock**)a);
const SimDataBlock* dbb = *((const SimDataBlock**)b); const SimDataBlock* dbb = *((const SimDataBlock**)b);
return dba->getModifiedKey() - dbb->getModifiedKey(); return dba->getModifiedKey() - dbb->getModifiedKey();
@ -612,6 +612,6 @@ void SimDataBlockGroup::sort()
if(mLastModifiedKey != SimDataBlock::getNextModifiedKey()) if(mLastModifiedKey != SimDataBlock::getNextModifiedKey())
{ {
mLastModifiedKey = SimDataBlock::getNextModifiedKey(); mLastModifiedKey = SimDataBlock::getNextModifiedKey();
dQsort(objectList.address(),objectList.size(),sizeof(SimObject *),compareModifiedKey); dQsort(objectList.address(),objectList.size(),sizeof(SimObject *),compareModifiedKey);
} }
} }

View file

@ -81,7 +81,7 @@ SimObject::SimObject()
mFlags.set( ModStaticFields | ModDynamicFields ); mFlags.set( ModStaticFields | ModDynamicFields );
mFieldDictionary = NULL; mFieldDictionary = NULL;
mCanSaveFieldDictionary = true; mCanSaveFieldDictionary = true;
mClassName = NULL; mClassName = NULL;
mSuperClassName = NULL; mSuperClassName = NULL;
@ -592,7 +592,7 @@ void SimObject::setDeclarationLine(U32 lineNumber)
bool SimObject::registerObject() bool SimObject::registerObject()
{ {
AssertFatal( !mFlags.test( Added ), "reigsterObject - Object already registered!"); AssertFatal( !mFlags.test( Added ), "reigsterObject - Object already registered!");
mFlags.clear(Deleted | Removed); mFlags.clear(Deleted | Removed);
if(smForceId) if(smForceId)
{ {
@ -609,11 +609,11 @@ bool SimObject::registerObject()
AssertFatal(Sim::gIdDictionary && Sim::gNameDictionary, AssertFatal(Sim::gIdDictionary && Sim::gNameDictionary,
"SimObject::registerObject - tried to register an object before Sim::init()!"); "SimObject::registerObject - tried to register an object before Sim::init()!");
Sim::gIdDictionary->insert(this); Sim::gIdDictionary->insert(this);
Sim::gNameDictionary->insert(this); Sim::gNameDictionary->insert(this);
// Notify object // Notify object
bool ret = onAdd(); bool ret = onAdd();
if(!ret) if(!ret)
@ -661,10 +661,10 @@ void SimObject::deleteObject()
void SimObject::_destroySelf() void SimObject::_destroySelf()
{ {
AssertFatal( !isDeleted(), "SimObject::destroySelf - Object has already been deleted" ); AssertFatal( !isDeleted(), "SimObject::destroySelf - Object has already been deleted" );
AssertFatal( !isRemoved(), "SimObject::destroySelf - Object in the process of being removed" ); AssertFatal( !isRemoved(), "SimObject::destroySelf - Object in the process of being removed" );
mFlags.set( Deleted ); mFlags.set( Deleted );
if( mFlags.test( Added ) ) if( mFlags.test( Added ) )
unregisterObject(); unregisterObject();
@ -1308,7 +1308,7 @@ void SimObject::dumpClassHierarchy()
while(pRep) while(pRep)
{ {
Con::warnf("%s ->", pRep->getClassName()); Con::warnf("%s ->", pRep->getClassName());
pRep = pRep->getParentClass(); pRep = pRep->getParentClass();
} }
} }
@ -1376,7 +1376,7 @@ bool SimObject::isChildOfGroup(SimGroup* pGroup)
if(pGroup == dynamic_cast<SimGroup*>(this)) if(pGroup == dynamic_cast<SimGroup*>(this))
return true; return true;
SimGroup* temp = mGroup; SimGroup* temp = mGroup;
while(temp) while(temp)
{ {
if(temp == pGroup) if(temp == pGroup)
@ -2884,7 +2884,7 @@ DefineConsoleMethod( SimObject, isMemberOfClass, bool, ( const char* className )
return true; return true;
} }
pRep = pRep->getParentClass(); pRep = pRep->getParentClass();
} }
return false; return false;

View file

@ -826,7 +826,7 @@ class SimObject: public ConsoleObject, public TamlCallbacks
virtual bool readObject(Stream *stream); virtual bool readObject(Stream *stream);
/// Set whether fields created at runtime should be saved. Default is true. /// Set whether fields created at runtime should be saved. Default is true.
void setCanSaveDynamicFields( bool bCanSave ) { mCanSaveFieldDictionary = bCanSave; } void setCanSaveDynamicFields( bool bCanSave ) { mCanSaveFieldDictionary = bCanSave; }
/// Get whether fields created at runtime should be saved. Default is true. /// Get whether fields created at runtime should be saved. Default is true.
bool getCanSaveDynamicFields( ) { return mCanSaveFieldDictionary;} bool getCanSaveDynamicFields( ) { return mCanSaveFieldDictionary;}

View file

@ -30,7 +30,7 @@
SimObjectMemento::SimObjectMemento() SimObjectMemento::SimObjectMemento()
: mState( NULL ), : mState( NULL ),
mIsDatablock( false ) mIsDatablock( false )
{ {
} }
@ -45,16 +45,16 @@ void SimObjectMemento::save( SimObject *object )
dFree( mState ); dFree( mState );
mObjectName = String::EmptyString; mObjectName = String::EmptyString;
// Use a stream to save the state. // Use a stream to save the state.
MemStream stream( 256 ); MemStream stream( 256 );
U32 writeFlags = 0; U32 writeFlags = 0;
SimDataBlock* db = dynamic_cast<SimDataBlock*>(object); SimDataBlock* db = dynamic_cast<SimDataBlock*>(object);
if( !db ) if( !db )
stream.write( sizeof( "return " ) - 1, "return " ); stream.write( sizeof( "return " ) - 1, "return " );
else else
{ {
mIsDatablock = true; mIsDatablock = true;
// Cull the datablock name from the output so that // Cull the datablock name from the output so that
// we can easily replace it in case the datablock's name // we can easily replace it in case the datablock's name
@ -64,7 +64,7 @@ void SimObjectMemento::save( SimObject *object )
writeFlags |= SimObject::NoName; writeFlags |= SimObject::NoName;
} }
object->write( stream, 0, writeFlags ); object->write( stream, 0, writeFlags );
stream.write( (UTF8)0 ); stream.write( (UTF8)0 );
@ -82,9 +82,9 @@ SimObject *SimObjectMemento::restore() const
// TODO: We could potentially make this faster by // TODO: We could potentially make this faster by
// caching the CodeBlock generated from the string // caching the CodeBlock generated from the string
SimObject* object; SimObject* object;
if( !mIsDatablock ) if( !mIsDatablock )
{ {
// Set the redefine behavior to automatically giving // Set the redefine behavior to automatically giving
// the new objects unique names. This will restore the // the new objects unique names. This will restore the
// old names if they are still available or give reasonable // old names if they are still available or give reasonable
@ -95,22 +95,22 @@ SimObject *SimObjectMemento::restore() const
// Read the object. // Read the object.
const UTF8* result = Con::evaluate( mState ); const UTF8* result = Con::evaluate( mState );
// Restore the redefine behavior. // Restore the redefine behavior.
Con::setVariable( "$Con::redefineBehavior", oldRedefineBehavior ); Con::setVariable( "$Con::redefineBehavior", oldRedefineBehavior );
if ( !result || !result[ 0 ] ) if ( !result || !result[ 0 ] )
return NULL; return NULL;
// Look up the object. // Look up the object.
U32 objectId = dAtoi( result ); U32 objectId = dAtoi( result );
object = Sim::findObject( objectId ); object = Sim::findObject( objectId );
} }
else else
{ {
String objectName = mObjectName; String objectName = mObjectName;
// For datablocks, it's getting a little complicated. Datablock definitions cannot be used // For datablocks, it's getting a little complicated. Datablock definitions cannot be used
@ -140,16 +140,16 @@ SimObject *SimObjectMemento::restore() const
dStrcpy( &tempBuffer[ numCharsToLeftParen + uniqueNameLen ], &mState[ numCharsToLeftParen ] ); dStrcpy( &tempBuffer[ numCharsToLeftParen + uniqueNameLen ], &mState[ numCharsToLeftParen ] );
} }
Con::evaluate( tempBuffer ); Con::evaluate( tempBuffer );
if( tempBuffer != mState ) if( tempBuffer != mState )
dFree( tempBuffer ); dFree( tempBuffer );
if( objectName == String::EmptyString ) if( objectName == String::EmptyString )
return NULL; return NULL;
object = Sim::findObject( objectName ); object = Sim::findObject( objectName );
} }
return object; return object;
} }

View file

@ -42,7 +42,7 @@ protected:
/// The captured object's name. /// The captured object's name.
String mObjectName; String mObjectName;
bool mIsDatablock; bool mIsDatablock;
public: public:

View file

@ -29,13 +29,13 @@
IMPLEMENT_CONOBJECT( SimPersistSet ); IMPLEMENT_CONOBJECT( SimPersistSet );
ConsoleDocClass( SimPersistSet, ConsoleDocClass( SimPersistSet,
"@brief A SimSet that can be safely persisted.\n\n" "@brief A SimSet that can be safely persisted.\n\n"
"Uses SimPersistIDs to reference objects in the set " "Uses SimPersistIDs to reference objects in the set "
"while persisted on disk. This allows the set to resolve " "while persisted on disk. This allows the set to resolve "
"its references no matter whether they are loaded before or " "its references no matter whether they are loaded before or "
"after the set is created.\n\n" "after the set is created.\n\n"
"Not intended for game development, for editors or internal use only.\n\n " "Not intended for game development, for editors or internal use only.\n\n "
"@internal"); "@internal");
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -213,18 +213,18 @@ SimObject *loadObjectStream(Stream *stream)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineFunction(saveObject, bool, ( SimObject *object, const char *filename ),, DefineEngineFunction(saveObject, bool, ( SimObject *object, const char *filename ),,
"@brief Serialize the object to a file.\n\n" "@brief Serialize the object to a file.\n\n"
"@param object The object to serialize.\n" "@param object The object to serialize.\n"
"@param filename The file name and path.\n" "@param filename The file name and path.\n"
"@ingroup Console\n") "@ingroup Console\n")
{ {
return object && Sim::saveObject(object, filename); return object && Sim::saveObject(object, filename);
} }
DefineEngineFunction(loadObject, SimObject*, ( const char *filename ),, DefineEngineFunction(loadObject, SimObject*, ( const char *filename ),,
"@brief Loads a serialized object from a file.\n\n" "@brief Loads a serialized object from a file.\n\n"
"@param Name and path to text file containing the object\n" "@param Name and path to text file containing the object\n"
"@ingroup Console\n") "@ingroup Console\n")
{ {
return Sim::loadObjectStream(filename); return Sim::loadObjectStream(filename);
} }

View file

@ -121,7 +121,7 @@ bool ConsoleValueStack::reserveValues(U32 count, ConsoleValueRef *outValues)
//Con::printf("[%i]CSTK reserveValues %i", mStackPos, count); //Con::printf("[%i]CSTK reserveValues %i", mStackPos, count);
for (U32 i=0; i<count; i++) for (U32 i=0; i<count; i++)
{ {
outValues[i].value = &mStack[mStackPos+i]; outValues[i].value = &mStack[mStackPos+i];
} }
mStackPos += count; mStackPos += count;
return true; return true;

View file

@ -67,17 +67,17 @@ DefineConsoleFunction( telnetSetParameters, void, ( int port, const char* consol
"@param consolePass Password for read/write access to console.\n" "@param consolePass Password for read/write access to console.\n"
"@param listenPass Password for read access to console.\n" "@param listenPass Password for read access to console.\n"
"@param remoteEcho [optional] Enable echoing back to the client, off by default.\n\n" "@param remoteEcho [optional] Enable echoing back to the client, off by default.\n\n"
"@ingroup Debugging") "@ingroup Debugging")
{ {
if (TelConsole) if (TelConsole)
TelConsole->setTelnetParameters(port, consolePass, listenPass, remoteEcho); TelConsole->setTelnetParameters(port, consolePass, listenPass, remoteEcho);
} }
static void telnetCallback(U32 level, const char *consoleLine) static void telnetCallback(U32 level, const char *consoleLine)
{ {
TORQUE_UNUSED(level); TORQUE_UNUSED(level);
if (TelConsole) if (TelConsole)
TelConsole->processConsoleLine(consoleLine); TelConsole->processConsoleLine(consoleLine);
} }
TelnetConsole::TelnetConsole() TelnetConsole::TelnetConsole()
@ -121,9 +121,9 @@ void TelnetConsole::setTelnetParameters(S32 port, const char *telnetPassword, co
mAcceptPort = port; mAcceptPort = port;
if(mAcceptPort != -1 && mAcceptPort != 0) if(mAcceptPort != -1 && mAcceptPort != 0)
{ {
NetAddress address; NetAddress address;
Net::getIdealListenAddress(&address); Net::getIdealListenAddress(&address);
address.port = mAcceptPort; address.port = mAcceptPort;
mAcceptSocket = Net::openSocket(); mAcceptSocket = Net::openSocket();
Net::bindAddress(address, mAcceptSocket); Net::bindAddress(address, mAcceptSocket);

View file

@ -115,8 +115,8 @@ MODULE_END;
DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password, bool waitForClient ), (false), "( int port, string password, bool waitForClient )" DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password, bool waitForClient ), (false), "( int port, string password, bool waitForClient )"
"Open a debug server port on the specified port, requiring the specified password, " "Open a debug server port on the specified port, requiring the specified password, "
"and optionally waiting for the debug client to connect.\n" "and optionally waiting for the debug client to connect.\n"
"@internal Primarily used for Torsion and other debugging tools") "@internal Primarily used for Torsion and other debugging tools")
{ {
if (TelDebugger) if (TelDebugger)
{ {
@ -126,17 +126,17 @@ DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password,
DefineConsoleFunction( dbgIsConnected, bool, (), , "()" DefineConsoleFunction( dbgIsConnected, bool, (), , "()"
"Returns true if a script debugging client is connected else return false.\n" "Returns true if a script debugging client is connected else return false.\n"
"@internal Primarily used for Torsion and other debugging tools") "@internal Primarily used for Torsion and other debugging tools")
{ {
return TelDebugger && TelDebugger->isConnected(); return TelDebugger && TelDebugger->isConnected();
} }
DefineConsoleFunction( dbgDisconnect, void, (), , "()" DefineConsoleFunction( dbgDisconnect, void, (), , "()"
"Forcibly disconnects any attached script debugging client.\n" "Forcibly disconnects any attached script debugging client.\n"
"@internal Primarily used for Torsion and other debugging tools") "@internal Primarily used for Torsion and other debugging tools")
{ {
if (TelDebugger) if (TelDebugger)
TelDebugger->disconnect(); TelDebugger->disconnect();
} }
static void debuggerConsumer(U32 level, const char *line) static void debuggerConsumer(U32 level, const char *line)
@ -244,9 +244,9 @@ void TelnetDebugger::setDebugParameters(S32 port, const char *password, bool wai
mAcceptPort = port; mAcceptPort = port;
if(mAcceptPort != -1 && mAcceptPort != 0) if(mAcceptPort != -1 && mAcceptPort != 0)
{ {
NetAddress address; NetAddress address;
Net::getIdealListenAddress(&address); Net::getIdealListenAddress(&address);
address.port = mAcceptPort; address.port = mAcceptPort;
mAcceptSocket = Net::openSocket(); mAcceptSocket = Net::openSocket();
Net::bindAddress(address, mAcceptSocket); Net::bindAddress(address, mAcceptSocket);
@ -588,7 +588,7 @@ void TelnetDebugger::addAllBreakpoints(CodeBlock *code)
// TODO: This assumes that the OS file names are case // TODO: This assumes that the OS file names are case
// insensitive... Torque needs a dFilenameCmp() function. // insensitive... Torque needs a dFilenameCmp() function.
if( dStricmp( cur->fileName, code->name ) == 0 ) if( dStricmp( cur->fileName, code->name ) == 0 )
{ {
cur->code = code; cur->code = code;
// Find the fist breakline starting from and // Find the fist breakline starting from and
@ -741,7 +741,7 @@ void TelnetDebugger::removeBreakpoint(const char *fileName, S32 line)
{ {
Breakpoint *brk = *bp; Breakpoint *brk = *bp;
*bp = brk->next; *bp = brk->next;
if ( brk->code ) if ( brk->code )
brk->code->clearBreakpoint(brk->lineNumber); brk->code->clearBreakpoint(brk->lineNumber);
dFree(brk->testExpression); dFree(brk->testExpression);
delete brk; delete brk;
@ -754,7 +754,7 @@ void TelnetDebugger::removeAllBreakpoints()
while(walk) while(walk)
{ {
Breakpoint *temp = walk->next; Breakpoint *temp = walk->next;
if ( walk->code ) if ( walk->code )
walk->code->clearBreakpoint(walk->lineNumber); walk->code->clearBreakpoint(walk->lineNumber);
dFree(walk->testExpression); dFree(walk->testExpression);
delete walk; delete walk;
@ -792,10 +792,10 @@ void TelnetDebugger::setBreakOnNextStatement( bool enabled )
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile) for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile)
walk->clearAllBreaks(); walk->clearAllBreaks();
for(Breakpoint *w = mBreakpoints; w; w = w->next) for(Breakpoint *w = mBreakpoints; w; w = w->next)
{ {
if ( w->code ) if ( w->code )
w->code->setBreakpoint(w->lineNumber); w->code->setBreakpoint(w->lineNumber);
} }
mBreakOnNextStatement = false; mBreakOnNextStatement = false;
} }
} }
@ -848,7 +848,7 @@ void TelnetDebugger::debugStepOut()
setBreakOnNextStatement( false ); setBreakOnNextStatement( false );
mStackPopBreakIndex = gEvalState.getStackDepth() - 1; mStackPopBreakIndex = gEvalState.getStackDepth() - 1;
if ( mStackPopBreakIndex == 0 ) if ( mStackPopBreakIndex == 0 )
mStackPopBreakIndex = -1; mStackPopBreakIndex = -1;
mProgramPaused = false; mProgramPaused = false;
send("RUNNING\r\n"); send("RUNNING\r\n");
} }

View file

@ -49,42 +49,42 @@ void TypeValidator::consoleError(SimObject *object, const char *format, ...)
void FRangeValidator::validateType(SimObject *object, void *typePtr) void FRangeValidator::validateType(SimObject *object, void *typePtr)
{ {
F32 *v = (F32 *) typePtr; F32 *v = (F32 *) typePtr;
if(*v < minV || *v > maxV) if(*v < minV || *v > maxV)
{ {
consoleError(object, "Must be between %g and %g", minV, maxV); consoleError(object, "Must be between %g and %g", minV, maxV);
if(*v < minV) if(*v < minV)
*v = minV; *v = minV;
else if(*v > maxV) else if(*v > maxV)
*v = maxV; *v = maxV;
} }
} }
void IRangeValidator::validateType(SimObject *object, void *typePtr) void IRangeValidator::validateType(SimObject *object, void *typePtr)
{ {
S32 *v = (S32 *) typePtr; S32 *v = (S32 *) typePtr;
if(*v < minV || *v > maxV) if(*v < minV || *v > maxV)
{ {
consoleError(object, "Must be between %d and %d", minV, maxV); consoleError(object, "Must be between %d and %d", minV, maxV);
if(*v < minV) if(*v < minV)
*v = minV; *v = minV;
else if(*v > maxV) else if(*v > maxV)
*v = maxV; *v = maxV;
} }
} }
void IRangeValidatorScaled::validateType(SimObject *object, void *typePtr) void IRangeValidatorScaled::validateType(SimObject *object, void *typePtr)
{ {
S32 *v = (S32 *) typePtr; S32 *v = (S32 *) typePtr;
*v /= factor; *v /= factor;
if(*v < minV || *v > maxV) if(*v < minV || *v > maxV)
{ {
consoleError(object, "Scaled value must be between %d and %d", minV, maxV); consoleError(object, "Scaled value must be between %d and %d", minV, maxV);
if(*v < minV) if(*v < minV)
*v = minV; *v = minV;
else if(*v > maxV) else if(*v > maxV)
*v = maxV; *v = maxV;
} }
} }
void Point3NormalizeValidator::validateType(SimObject *object, void *typePtr) void Point3NormalizeValidator::validateType(SimObject *object, void *typePtr)

View file

@ -77,12 +77,12 @@ ConsoleDocClass( River,
#define NODE_RADIUS 15.0f #define NODE_RADIUS 15.0f
static U32 gIdxArray[6][2][3] = { static U32 gIdxArray[6][2][3] = {
{ { 0, 4, 5 }, { 0, 5, 1 }, }, // Top Face { { 0, 4, 5 }, { 0, 5, 1 }, }, // Top Face
{ { 2, 6, 4 }, { 2, 4, 0 }, }, // Left Face { { 2, 6, 4 }, { 2, 4, 0 }, }, // Left Face
{ { 1, 5, 7 }, { 1, 7, 3 }, }, // Right Face { { 1, 5, 7 }, { 1, 7, 3 }, }, // Right Face
{ { 2, 3, 7 }, { 2, 7, 6 }, }, // Bottom Face { { 2, 3, 7 }, { 2, 7, 6 }, }, // Bottom Face
{ { 0, 1, 3 }, { 0, 3, 2 }, }, // Front Face { { 0, 1, 3 }, { 0, 3, 2 }, }, // Front Face
{ { 4, 6, 7 }, { 4, 7, 5 }, }, // Back Face { { 4, 6, 7 }, { 4, 7, 5 }, }, // Back Face
}; };
struct RiverHitSegment struct RiverHitSegment
@ -93,10 +93,10 @@ struct RiverHitSegment
static S32 QSORT_CALLBACK compareHitSegments(const void* a,const void* b) static S32 QSORT_CALLBACK compareHitSegments(const void* a,const void* b)
{ {
const RiverHitSegment *fa = (RiverHitSegment*)a; const RiverHitSegment *fa = (RiverHitSegment*)a;
const RiverHitSegment *fb = (RiverHitSegment*)b; const RiverHitSegment *fb = (RiverHitSegment*)b;
return mSign(fb->t - fa->t); return mSign(fb->t - fa->t);
} }
static Point3F sSegmentPointComparePoints[4]; static Point3F sSegmentPointComparePoints[4];
@ -655,17 +655,17 @@ void River::consoleInit()
Parent::consoleInit(); Parent::consoleInit();
Con::addVariable( "$River::EditorOpen", TypeBool, &River::smEditorOpen, "For editor use.\n" Con::addVariable( "$River::EditorOpen", TypeBool, &River::smEditorOpen, "For editor use.\n"
"@ingroup Editors\n" ); "@ingroup Editors\n" );
Con::addVariable( "$River::showWalls", TypeBool, &River::smShowWalls, "For editor use.\n" Con::addVariable( "$River::showWalls", TypeBool, &River::smShowWalls, "For editor use.\n"
"@ingroup Editors\n" ); "@ingroup Editors\n" );
Con::addVariable( "$River::showNodes", TypeBool, &River::smShowNodes, "For editor use.\n" Con::addVariable( "$River::showNodes", TypeBool, &River::smShowNodes, "For editor use.\n"
"@ingroup Editors\n"); "@ingroup Editors\n");
Con::addVariable( "$River::showSpline", TypeBool, &River::smShowSpline, "For editor use.\n" Con::addVariable( "$River::showSpline", TypeBool, &River::smShowSpline, "For editor use.\n"
"@ingroup Editors\n" ); "@ingroup Editors\n" );
Con::addVariable( "$River::showRiver", TypeBool, &River::smShowRiver, "For editor use.\n" Con::addVariable( "$River::showRiver", TypeBool, &River::smShowRiver, "For editor use.\n"
"@ingroup Editors\n" ); "@ingroup Editors\n" );
Con::addVariable( "$River::showWireframe", TypeBool, &River::smWireframe, "For editor use.\n" Con::addVariable( "$River::showWireframe", TypeBool, &River::smWireframe, "For editor use.\n"
"@ingroup Editors\n"); "@ingroup Editors\n");
} }
bool River::addNodeFromField( void *object, const char *index, const char *data ) bool River::addNodeFromField( void *object, const char *index, const char *data )
@ -816,7 +816,7 @@ void River::innerRender( SceneRenderState *state )
_makeRenderBatches( camPosition ); _makeRenderBatches( camPosition );
if ( !River::smShowRiver ) if ( !River::smShowRiver )
return; return;
// If no material... we're done. // If no material... we're done.
@ -851,7 +851,7 @@ void River::innerRender( SceneRenderState *state )
U32 vertCount = ( endVert - startVert ) + 1; U32 vertCount = ( endVert - startVert ) + 1;
U32 idxCount = ( endIdx - startIdx ) + 1; U32 idxCount = ( endIdx - startIdx ) + 1;
U32 triangleCount = idxCount / 3; U32 triangleCount = idxCount / 3;
AssertFatal( startVert < mLowVertCount, "River, bad draw call!" ); AssertFatal( startVert < mLowVertCount, "River, bad draw call!" );
AssertFatal( startVert + vertCount <= mLowVertCount, "River, bad draw call!" ); AssertFatal( startVert + vertCount <= mLowVertCount, "River, bad draw call!" );
AssertFatal( triangleCount <= mLowTriangleCount, "River, bad draw call!" ); AssertFatal( triangleCount <= mLowTriangleCount, "River, bad draw call!" );
@ -962,7 +962,7 @@ U32 River::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
stream->write( mSegmentsPerBatch ); stream->write( mSegmentsPerBatch );
stream->write( mDepthScale ); stream->write( mDepthScale );
stream->write( mMaxDivisionSize ); stream->write( mMaxDivisionSize );
stream->write( mColumnCount ); stream->write( mColumnCount );
stream->write( mFlowMagnitude ); stream->write( mFlowMagnitude );
stream->write( mLodDistance ); stream->write( mLodDistance );
@ -1045,7 +1045,7 @@ void River::unpackUpdate(NetConnection * con, BitStream * stream)
// RiverMask // RiverMask
if(stream->readFlag()) if(stream->readFlag())
{ {
MatrixF ObjectMatrix; MatrixF ObjectMatrix;
stream->readAffineTransform(&ObjectMatrix); stream->readAffineTransform(&ObjectMatrix);
Parent::setTransform(ObjectMatrix); Parent::setTransform(ObjectMatrix);
@ -1053,7 +1053,7 @@ void River::unpackUpdate(NetConnection * con, BitStream * stream)
stream->read( &mSegmentsPerBatch ); stream->read( &mSegmentsPerBatch );
stream->read( &mDepthScale ); stream->read( &mDepthScale );
stream->read( &mMaxDivisionSize ); stream->read( &mMaxDivisionSize );
stream->read( &mColumnCount ); stream->read( &mColumnCount );
stream->read( &mFlowMagnitude ); stream->read( &mFlowMagnitude );
stream->read( &mLodDistance ); stream->read( &mLodDistance );
@ -1198,56 +1198,56 @@ void River::setScale( const VectorF &scale )
bool River::castRay(const Point3F &s, const Point3F &e, RayInfo* info) bool River::castRay(const Point3F &s, const Point3F &e, RayInfo* info)
{ {
Point3F start = s; Point3F start = s;
Point3F end = e; Point3F end = e;
mObjToWorld.mulP(start); mObjToWorld.mulP(start);
mObjToWorld.mulP(end); mObjToWorld.mulP(end);
F32 out = 1.0f; // The output fraction/percentage along the line defined by s and e F32 out = 1.0f; // The output fraction/percentage along the line defined by s and e
VectorF norm(0.0f, 0.0f, 0.0f); // The normal of the face intersected VectorF norm(0.0f, 0.0f, 0.0f); // The normal of the face intersected
Vector<RiverHitSegment> hitSegments; Vector<RiverHitSegment> hitSegments;
for ( U32 i = 0; i < mSegments.size(); i++ ) for ( U32 i = 0; i < mSegments.size(); i++ )
{ {
const RiverSegment &segment = mSegments[i]; const RiverSegment &segment = mSegments[i];
F32 t; F32 t;
VectorF n; VectorF n;
if ( segment.worldbounds.collideLine( start, end, &t, &n ) ) if ( segment.worldbounds.collideLine( start, end, &t, &n ) )
{ {
hitSegments.increment(); hitSegments.increment();
hitSegments.last().t = t; hitSegments.last().t = t;
hitSegments.last().idx = i; hitSegments.last().idx = i;
} }
} }
dQsort( hitSegments.address(), hitSegments.size(), sizeof(RiverHitSegment), compareHitSegments ); dQsort( hitSegments.address(), hitSegments.size(), sizeof(RiverHitSegment), compareHitSegments );
U32 idx0, idx1, idx2; U32 idx0, idx1, idx2;
F32 t; F32 t;
for ( U32 i = 0; i < hitSegments.size(); i++ ) for ( U32 i = 0; i < hitSegments.size(); i++ )
{ {
U32 segIdx = hitSegments[i].idx; U32 segIdx = hitSegments[i].idx;
const RiverSegment &segment = mSegments[segIdx]; const RiverSegment &segment = mSegments[segIdx];
// Each segment has 6 faces // Each segment has 6 faces
for ( U32 j = 0; j < 6; j++ ) for ( U32 j = 0; j < 6; j++ )
{ {
if ( j == 4 && segIdx != 0 ) if ( j == 4 && segIdx != 0 )
continue; continue;
if ( j == 5 && segIdx != mSegments.size() - 1 ) if ( j == 5 && segIdx != mSegments.size() - 1 )
continue; continue;
// Each face has 2 triangles // Each face has 2 triangles
for ( U32 k = 0; k < 2; k++ ) for ( U32 k = 0; k < 2; k++ )
{ {
idx0 = gIdxArray[j][k][0]; idx0 = gIdxArray[j][k][0];
idx1 = gIdxArray[j][k][1]; idx1 = gIdxArray[j][k][1];
idx2 = gIdxArray[j][k][2]; idx2 = gIdxArray[j][k][2];
const Point3F &v0 = segment[idx0]; const Point3F &v0 = segment[idx0];
const Point3F &v1 = segment[idx1]; const Point3F &v1 = segment[idx1];
@ -1257,40 +1257,40 @@ bool River::castRay(const Point3F &s, const Point3F &e, RayInfo* info)
v2, v1, v0, v2, v1, v0,
NULL, NULL,
&t ) ) &t ) )
continue; continue;
if ( t >= 0.0f && t < 1.0f && t < out ) if ( t >= 0.0f && t < 1.0f && t < out )
{ {
out = t; out = t;
// optimize this, can be calculated easily within // optimize this, can be calculated easily within
// the collision test // the collision test
norm = PlaneF( v0, v1, v2 ); norm = PlaneF( v0, v1, v2 );
} }
} }
} }
if (out >= 0.0f && out < 1.0f) if (out >= 0.0f && out < 1.0f)
break; break;
} }
if (out >= 0.0f && out < 1.0f) if (out >= 0.0f && out < 1.0f)
{ {
info->t = out; info->t = out;
info->normal = norm; info->normal = norm;
info->point.interpolate(start, end, out); info->point.interpolate(start, end, out);
info->face = -1; info->face = -1;
info->object = this; info->object = this;
return true; return true;
} }
return false; return false;
} }
bool River::collideBox(const Point3F &start, const Point3F &end, RayInfo* info) bool River::collideBox(const Point3F &start, const Point3F &end, RayInfo* info)
{ {
return false; return false;
} }
bool River::buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere ) bool River::buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere )
@ -1656,8 +1656,8 @@ void River::_generateVerts()
// These will depend on the level of subdivision per segment // These will depend on the level of subdivision per segment
// calculated below. // calculated below.
mHighVertCount = 0; mHighVertCount = 0;
mHighTriangleCount = 0; mHighTriangleCount = 0;
// Calculate the number of row/column subdivisions per each // Calculate the number of row/column subdivisions per each
// RiverSegment. // RiverSegment.
@ -1671,18 +1671,18 @@ void River::_generateVerts()
mColumnCount = mCeil( greatestWidth / mMaxDivisionSize ); mColumnCount = mCeil( greatestWidth / mMaxDivisionSize );
for ( U32 i = 0; i < mSegments.size(); i++ ) for ( U32 i = 0; i < mSegments.size(); i++ )
{ {
RiverSegment &segment = mSegments[i]; RiverSegment &segment = mSegments[i];
const RiverSlice *slice = segment.slice0; const RiverSlice *slice = segment.slice0;
const RiverSlice *nextSlice = segment.slice1; const RiverSlice *nextSlice = segment.slice1;
// Calculate the size of divisions in the forward direction ( p00 -> p01 ) // Calculate the size of divisions in the forward direction ( p00 -> p01 )
F32 segLength = (nextSlice->p1 - slice->p1).len(); F32 segLength = (nextSlice->p1 - slice->p1).len();
// A division count of one is actually NO subdivision, // A division count of one is actually NO subdivision,
// the segment corners are the only verts in this segment. // the segment corners are the only verts in this segment.
U32 numRows = 1; U32 numRows = 1;
if ( segLength > 0.0f ) if ( segLength > 0.0f )
numRows = mCeil( segLength / mMaxDivisionSize ); numRows = mCeil( segLength / mMaxDivisionSize );
@ -1693,33 +1693,33 @@ void River::_generateVerts()
// column data member we initialize all segments in the river to // column data member we initialize all segments in the river to
// the same (River::mColumnCount) // the same (River::mColumnCount)
// Calculate the size of divisions in the right direction ( p00 -> p10 ) // Calculate the size of divisions in the right direction ( p00 -> p10 )
// F32 segWidth = ( ( p11 - p01 ).len() + ( p10 - p00 ).len() ) * 0.5f; // F32 segWidth = ( ( p11 - p01 ).len() + ( p10 - p00 ).len() ) * 0.5f;
// U32 numColumns = 5; // U32 numColumns = 5;
//F32 columnSize = segWidth / numColumns; //F32 columnSize = segWidth / numColumns;
//while ( columnSize > mMaxDivisionSize ) //while ( columnSize > mMaxDivisionSize )
//{ //{
// numColumns++; // numColumns++;
// columnSize = segWidth / numColumns; // columnSize = segWidth / numColumns;
//} //}
// Save the calculated numb of columns / rows for this segment. // Save the calculated numb of columns / rows for this segment.
segment.columns = mColumnCount; segment.columns = mColumnCount;
segment.rows = numRows; segment.rows = numRows;
// Save the corresponding number of verts/prims // Save the corresponding number of verts/prims
segment.numVerts = ( 1 + mColumnCount ) * ( 1 + numRows ); segment.numVerts = ( 1 + mColumnCount ) * ( 1 + numRows );
segment.numTriangles = mColumnCount * numRows * 2; segment.numTriangles = mColumnCount * numRows * 2;
mHighVertCount += segment.numVerts; mHighVertCount += segment.numVerts;
mHighTriangleCount += segment.numTriangles; mHighTriangleCount += segment.numTriangles;
} }
// Number of low detail verts/prims. // Number of low detail verts/prims.
mLowVertCount = mSlices.size() * 2; mLowVertCount = mSlices.size() * 2;
mLowTriangleCount = mSegments.size() * 2; mLowTriangleCount = mSegments.size() * 2;
// Allocate the low detail VertexBuffer, // Allocate the low detail VertexBuffer,
// this will stay in memory and will never need to change. // this will stay in memory and will never need to change.
@ -1728,8 +1728,8 @@ void River::_generateVerts()
GFXWaterVertex *lowVertPtr = mVB_low.lock(); GFXWaterVertex *lowVertPtr = mVB_low.lock();
U32 vertCounter = 0; U32 vertCounter = 0;
// The texCoord.y value start/end for a segment // The texCoord.y value start/end for a segment
// as we loop through them. // as we loop through them.
F32 textCoordV = 0; F32 textCoordV = 0;
// //
@ -1760,7 +1760,7 @@ void River::_generateVerts()
{ {
// Increment the textCoordV for the next slice. // Increment the textCoordV for the next slice.
F32 segLen = ( mSlices[i+1].p1 - slice.p1 ).len(); F32 segLen = ( mSlices[i+1].p1 - slice.p1 ).len();
textCoordV += segLen; textCoordV += segLen;
} }
} }
@ -1771,8 +1771,8 @@ void River::_generateVerts()
// //
// Create the low-detail prim buffer(s) // Create the low-detail prim buffer(s)
// //
mPB_low.set( GFX, mLowTriangleCount * 3, mLowTriangleCount, GFXBufferTypeStatic ); mPB_low.set( GFX, mLowTriangleCount * 3, mLowTriangleCount, GFXBufferTypeStatic );
U16 *lowIdxBuff; U16 *lowIdxBuff;
mPB_low.lock(&lowIdxBuff); mPB_low.lock(&lowIdxBuff);
@ -1784,13 +1784,13 @@ void River::_generateVerts()
U32 offset = 0; U32 offset = 0;
// Fill the low-detail PrimitiveBuffer // Fill the low-detail PrimitiveBuffer
for ( U32 i = 0; i < mSegments.size(); i++ ) for ( U32 i = 0; i < mSegments.size(); i++ )
{ {
//const RiverSegment &segment = mSegments[i]; //const RiverSegment &segment = mSegments[i];
// Two triangles formed by the corner points of this segment // Two triangles formed by the corner points of this segment
// into the the low detail primitive buffer. // into the the low detail primitive buffer.
p00 = offset; p00 = offset;
p01 = p00 + 2; p01 = p00 + 2;
p11 = p01 + 1; p11 = p01 + 1;
p10 = p00 + 1; p10 = p00 + 1;

View file

@ -40,32 +40,32 @@ GFXGLStateBlock::GFXGLStateBlock(const GFXStateBlockDesc& desc) :
mCachedHashValue(desc.getHashValue()) mCachedHashValue(desc.getHashValue())
{ {
if( !GFXGL->mCapabilities.samplerObjects ) if( !GFXGL->mCapabilities.samplerObjects )
return; return;
static Map<GFXSamplerStateDesc, U32> mSamplersMap; static Map<GFXSamplerStateDesc, U32> mSamplersMap;
for(int i = 0; i < TEXTURE_STAGE_COUNT; ++i) for(int i = 0; i < TEXTURE_STAGE_COUNT; ++i)
{ {
GLuint &id = mSamplerObjects[i]; GLuint &id = mSamplerObjects[i];
GFXSamplerStateDesc &ssd = mDesc.samplers[i]; GFXSamplerStateDesc &ssd = mDesc.samplers[i];
Map<GFXSamplerStateDesc, U32>::Iterator itr = mSamplersMap.find(ssd); Map<GFXSamplerStateDesc, U32>::Iterator itr = mSamplersMap.find(ssd);
if(itr == mSamplersMap.end()) if(itr == mSamplersMap.end())
{ {
glGenSamplers(1, &id); glGenSamplers(1, &id);
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, minificationFilter(ssd.minFilter, ssd.mipFilter, 1) ); glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, minificationFilter(ssd.minFilter, ssd.mipFilter, 1) );
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GFXGLTextureFilter[ssd.magFilter]); glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GFXGLTextureFilter[ssd.magFilter]);
glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GFXGLTextureAddress[ssd.addressModeU]); glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GFXGLTextureAddress[ssd.addressModeU]);
glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GFXGLTextureAddress[ssd.addressModeV]); glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GFXGLTextureAddress[ssd.addressModeV]);
glSamplerParameteri(id, GL_TEXTURE_WRAP_R, GFXGLTextureAddress[ssd.addressModeW]); glSamplerParameteri(id, GL_TEXTURE_WRAP_R, GFXGLTextureAddress[ssd.addressModeW]);
if(static_cast< GFXGLDevice* >( GFX )->supportsAnisotropic() ) if(static_cast< GFXGLDevice* >( GFX )->supportsAnisotropic() )
glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, ssd.maxAnisotropy); glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, ssd.maxAnisotropy);
mSamplersMap[ssd] = id; mSamplersMap[ssd] = id;
} }
else else
id = itr->value; id = itr->value;
} }
} }
GFXGLStateBlock::~GFXGLStateBlock() GFXGLStateBlock::~GFXGLStateBlock()
@ -171,9 +171,9 @@ void GFXGLStateBlock::activate(const GFXGLStateBlock* oldState)
for (U32 i = 0; i < getMin(getOwningDevice()->getNumSamplers(), (U32) TEXTURE_STAGE_COUNT); i++) for (U32 i = 0; i < getMin(getOwningDevice()->getNumSamplers(), (U32) TEXTURE_STAGE_COUNT); i++)
{ {
if(!oldState || oldState->mSamplerObjects[i] != mSamplerObjects[i]) if(!oldState || oldState->mSamplerObjects[i] != mSamplerObjects[i])
glBindSampler(i, mSamplerObjects[i] ); glBindSampler(i, mSamplerObjects[i] );
} }
} }
// TODO: states added for detail blend // TODO: states added for detail blend
} }

View file

@ -59,21 +59,21 @@ ConsoleDocClass( GuiIconButtonCtrl,
"has been clicked.\n\n" "has been clicked.\n\n"
"@tsexample\n" "@tsexample\n"
"new GuiIconButtonCtrl(TestIconButton)\n" "new GuiIconButtonCtrl(TestIconButton)\n"
"{\n" "{\n"
" buttonMargin = \"4 4\";\n" " buttonMargin = \"4 4\";\n"
" iconBitmap = \"art/gui/lagIcon.png\";\n" " iconBitmap = \"art/gui/lagIcon.png\";\n"
" iconLocation = \"Center\";\n" " iconLocation = \"Center\";\n"
" sizeIconToButton = \"0\";\n" " sizeIconToButton = \"0\";\n"
" makeIconSquare = \"1\";\n" " makeIconSquare = \"1\";\n"
" textLocation = \"Bottom\";\n" " textLocation = \"Bottom\";\n"
" textMargin = \"-2\";\n" " textMargin = \"-2\";\n"
" autoSize = \"0\";\n" " autoSize = \"0\";\n"
" text = \"Lag Icon\";\n" " text = \"Lag Icon\";\n"
" textID = \"\"STR_LAG\"\";\n" " textID = \"\"STR_LAG\"\";\n"
" buttonType = \"PushButton\";\n" " buttonType = \"PushButton\";\n"
" profile = \"GuiIconButtonProfile\";\n" " profile = \"GuiIconButtonProfile\";\n"
"};\n" "};\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n" "@see GuiControl\n"
@ -85,7 +85,7 @@ ConsoleDocClass( GuiIconButtonCtrl,
GuiIconButtonCtrl::GuiIconButtonCtrl() GuiIconButtonCtrl::GuiIconButtonCtrl()
{ {
mBitmapName = StringTable->insert(""); mBitmapName = StringTable->EmptyString();
mTextLocation = TextLocLeft; mTextLocation = TextLocLeft;
mIconLocation = IconLocLeft; mIconLocation = IconLocLeft;
mTextMargin = 4; mTextMargin = 4;
@ -94,7 +94,7 @@ GuiIconButtonCtrl::GuiIconButtonCtrl()
mFitBitmapToButton = false; mFitBitmapToButton = false;
mMakeIconSquare = false; mMakeIconSquare = false;
mErrorBitmapName = StringTable->insert(""); mErrorBitmapName = StringTable->EmptyString();
mErrorTextureHandle = NULL; mErrorTextureHandle = NULL;
mAutoSize = false; mAutoSize = false;
@ -130,7 +130,7 @@ void GuiIconButtonCtrl::initPersistFields()
addField( "sizeIconToButton", TypeBool, Offset( mFitBitmapToButton, GuiIconButtonCtrl ),"If true, the icon will be scaled to be the same size as the button.\n"); addField( "sizeIconToButton", TypeBool, Offset( mFitBitmapToButton, GuiIconButtonCtrl ),"If true, the icon will be scaled to be the same size as the button.\n");
addField( "makeIconSquare", TypeBool, Offset( mMakeIconSquare, GuiIconButtonCtrl ),"If true, will make sure the icon is square.\n"); addField( "makeIconSquare", TypeBool, Offset( mMakeIconSquare, GuiIconButtonCtrl ),"If true, will make sure the icon is square.\n");
addField( "textLocation", TYPEID< TextLocation >(), Offset( mTextLocation, GuiIconButtonCtrl ),"Where to place the text on the control.\n" addField( "textLocation", TYPEID< TextLocation >(), Offset( mTextLocation, GuiIconButtonCtrl ),"Where to place the text on the control.\n"
"Options are 0 (None), 1 (Bottom), 2 (Right), 3 (Top), 4 (Left), 5 (Center).\n"); "Options are 0 (None), 1 (Bottom), 2 (Right), 3 (Top), 4 (Left), 5 (Center).\n");
addField( "textMargin", TypeS32, Offset( mTextMargin, GuiIconButtonCtrl ),"Margin between the icon and the text.\n"); addField( "textMargin", TypeS32, Offset( mTextMargin, GuiIconButtonCtrl ),"Margin between the icon and the text.\n");
addField( "autoSize", TypeBool, Offset( mAutoSize, GuiIconButtonCtrl ),"If true, the text and icon will be automatically sized to the size of the control.\n"); addField( "autoSize", TypeBool, Offset( mAutoSize, GuiIconButtonCtrl ),"If true, the text and icon will be automatically sized to the size of the control.\n");
Parent::initPersistFields(); Parent::initPersistFields();

View file

@ -49,7 +49,7 @@ ConsoleDocClass( GuiToggleButtonCtrl,
GuiToggleButtonCtrl::GuiToggleButtonCtrl() GuiToggleButtonCtrl::GuiToggleButtonCtrl()
{ {
setExtent(140, 30); setExtent(140, 30);
mButtonText = StringTable->insert(""); mButtonText = StringTable->EmptyString();
mStateOn = false; mStateOn = false;
mButtonType = ButtonTypeCheck; mButtonType = ButtonTypeCheck;
} }
@ -60,7 +60,7 @@ void GuiToggleButtonCtrl::onPreRender()
// If we have a script variable, make sure we're in sync // If we have a script variable, make sure we're in sync
if ( mConsoleVariable[0] ) if ( mConsoleVariable[0] )
mStateOn = Con::getBoolVariable( mConsoleVariable ); mStateOn = Con::getBoolVariable( mConsoleVariable );
} }
void GuiToggleButtonCtrl::onRender(Point2I offset, void GuiToggleButtonCtrl::onRender(Point2I offset,

View file

@ -43,7 +43,7 @@ ConsoleDocClass( GuiToolboxButtonCtrl,
//------------------------------------- //-------------------------------------
GuiToolboxButtonCtrl::GuiToolboxButtonCtrl() GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
{ {
mNormalBitmapName = StringTable->insert(""); mNormalBitmapName = StringTable->EmptyString();
mLoweredBitmapName = StringTable->insert("sceneeditor/client/images/buttondown"); mLoweredBitmapName = StringTable->insert("sceneeditor/client/images/buttondown");
mHoverBitmapName = StringTable->insert("sceneeditor/client/images/buttonup"); mHoverBitmapName = StringTable->insert("sceneeditor/client/images/buttonup");
setMinExtent(Point2I(16,16)); setMinExtent(Point2I(16,16));
@ -225,4 +225,4 @@ void GuiToolboxButtonCtrl::renderButton(GFXTexHandle &texture, Point2I &offset,
GFX->getDrawUtil()->drawBitmap(texture, finalOffset); GFX->getDrawUtil()->drawBitmap(texture, finalOffset);
renderChildControls( offset, updateRect); renderChildControls( offset, updateRect);
} }
} }

View file

@ -50,8 +50,8 @@ GuiFormCtrl::GuiFormCtrl()
mCaption = "[none]"; mCaption = "[none]";
mUseSmallCaption = false; mUseSmallCaption = false;
mContentLibrary = StringTable->insert(""); mContentLibrary = StringTable->EmptyString();
mContent = StringTable->insert(""); mContent = StringTable->EmptyString();
mCanSaveFieldDictionary = true; mCanSaveFieldDictionary = true;
mIsContainer = true; mIsContainer = true;
@ -158,7 +158,7 @@ void GuiFormCtrl::addObject(SimObject *newObj )
GuiControl* parent = getParent(); GuiControl* parent = getParent();
if ( parent ) if ( parent )
parent->addObject( newObj ); parent->addObject( newObj );
return; return;
} }
@ -213,7 +213,7 @@ bool GuiFormCtrl::resize(const Point2I &newPosition, const Point2I &newExtent)
static char buf[256]; static char buf[256];
mUseSmallCaption = true; mUseSmallCaption = true;
mSmallCaption = StringTable->insert(""); mSmallCaption = StringTable->EmptyString();
S32 strlen = dStrlen((const char*)mCaption); S32 strlen = dStrlen((const char*)mCaption);
for(S32 i=strlen; i>=0; --i) for(S32 i=strlen; i>=0; --i)

View file

@ -68,7 +68,7 @@ GuiPaneControl::GuiPaneControl()
mMouseOver = false; mMouseOver = false;
mDepressed = false; mDepressed = false;
mCaption = "A Pane"; mCaption = "A Pane";
mCaptionID = StringTable->insert(""); mCaptionID = StringTable->EmptyString();
mIsContainer = true; mIsContainer = true;
mOriginalExtents.set(10,10); mOriginalExtents.set(10,10);
@ -108,7 +108,7 @@ bool GuiPaneControl::onWake()
} }
if(mCaptionID && *mCaptionID != 0) if(mCaptionID && *mCaptionID != 0)
setCaptionID(mCaptionID); setCaptionID(mCaptionID);
mProfile->constructBitmapArray(); mProfile->constructBitmapArray();
if(mProfile->mUseBitmapArray && mProfile->mBitmapArrayRects.size()) if(mProfile->mUseBitmapArray && mProfile->mBitmapArrayRects.size())
@ -131,19 +131,19 @@ bool GuiPaneControl::onWake()
void GuiPaneControl::setCaptionID(const char *id) void GuiPaneControl::setCaptionID(const char *id)
{ {
S32 n = Con::getIntVariable(id, -1); S32 n = Con::getIntVariable(id, -1);
if(n != -1) if(n != -1)
{ {
mCaptionID = StringTable->insert(id); mCaptionID = StringTable->insert(id);
setCaptionID(n); setCaptionID(n);
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GuiPaneControl::setCaptionID(S32 id) void GuiPaneControl::setCaptionID(S32 id)
{ {
mCaption = getGUIString(id); mCaption = getGUIString(id);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -462,9 +462,9 @@ void GuiRolloutCtrl::processTick()
newHeight -= mAnimateStep; newHeight -= mAnimateStep;
if( !mIsAnimating ) if( !mIsAnimating )
{ {
mIsExpanded = false; mIsExpanded = false;
} }
} }
else // We're expanding ourself (Showing our contents) else // We're expanding ourself (Showing our contents)
{ {
@ -559,13 +559,13 @@ void GuiRolloutCtrl::onRender( Point2I offset, const RectI &updateRect )
if ( pChild ) if ( pChild )
{ {
if ( !mIsExpanded && !mIsAnimating && pChild->isVisible() ) if ( !mIsExpanded && !mIsAnimating && pChild->isVisible() )
{ {
pChild->setVisible( false ); pChild->setVisible( false );
} }
else if ( (mIsExpanded || mIsAnimating) && !pChild->isVisible() ) else if ( (mIsExpanded || mIsAnimating) && !pChild->isVisible() )
{ {
pChild->setVisible( true ); pChild->setVisible( true );
} }
} }
renderChildControls( offset, updateRect ); renderChildControls( offset, updateRect );
@ -614,7 +614,7 @@ DefineEngineMethod( GuiRolloutCtrl, toggleCollapse, void, (),,
if( object->isExpanded() ) if( object->isExpanded() )
object->collapse(); object->collapse();
else else
object->expand(); object->expand();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -231,7 +231,7 @@ void GuiWindowCtrl::moveFromCollapseGroup()
parent->mCollapseGroupVec[groupVec].first()->mCollapseGroupNum = -1; parent->mCollapseGroupVec[groupVec].first()->mCollapseGroupNum = -1;
parent->mCollapseGroupVec[groupVec].erase(U32(0)); parent->mCollapseGroupVec[groupVec].erase(U32(0));
parent->mCollapseGroupVec[groupVec].setSize(groupVecCount - 1); parent->mCollapseGroupVec[groupVec].setSize(groupVecCount - 1);
parent->mCollapseGroupVec.erase(groupVec); parent->mCollapseGroupVec.erase(groupVec);
} }
} }
@ -381,7 +381,7 @@ void GuiWindowCtrl::refreshCollapseGroups()
if( !parent ) if( !parent )
return; return;
CollapseGroupNumVec collapseGroupNumVec; CollapseGroupNumVec collapseGroupNumVec;
// iterate through the collided array, renumbering the windows pointers // iterate through the collided array, renumbering the windows pointers
S32 assignGroupNum = 0; S32 assignGroupNum = 0;
@ -463,7 +463,7 @@ void GuiWindowCtrl::handleCollapseGroup()
if( !parent ) if( !parent )
return; return;
CollapseGroupNumVec collapseGroupNumVec; CollapseGroupNumVec collapseGroupNumVec;
if( mIsCollapsed ) // minimize window up to its header bar if( mIsCollapsed ) // minimize window up to its header bar
{ {
@ -529,7 +529,7 @@ void GuiWindowCtrl::handleCollapseGroup()
if((*iter)->mCollapseGroupNum > mCollapseGroupNum) if((*iter)->mCollapseGroupNum > mCollapseGroupNum)
{ {
Point2I newChildPosition = (*iter)->getPosition(); Point2I newChildPosition = (*iter)->getPosition();
newChildPosition.y += moveChildYBy; newChildPosition.y += moveChildYBy;
(*iter)->resize(newChildPosition, (*iter)->getExtent()); (*iter)->resize(newChildPosition, (*iter)->getExtent());
} }
} }
@ -547,7 +547,7 @@ bool GuiWindowCtrl::resizeCollapseGroup(bool resizeX, bool resizeY, Point2I resi
if( !parent ) if( !parent )
return false; return false;
CollapseGroupNumVec collapseGroupNumVec; CollapseGroupNumVec collapseGroupNumVec;
bool canResize = true; bool canResize = true;
CollapseGroupNumVec::iterator iter = parent->mCollapseGroupVec[mCollapseGroup].begin(); CollapseGroupNumVec::iterator iter = parent->mCollapseGroupVec[mCollapseGroup].begin();
@ -980,7 +980,7 @@ void GuiWindowCtrl::onMouseDragged(const GuiEvent &event)
moveWithCollapseGroup(newPosition); moveWithCollapseGroup(newPosition);
if(mCanCollapse && mCollapseGroup >= 0 && mResizeWindow == true ) if(mCanCollapse && mCollapseGroup >= 0 && mResizeWindow == true )
{ {
// Resize the window if allowed // Resize the window if allowed
if( newExtent.y >= getMinExtent().y && newExtent.x >= getMinExtent().x) if( newExtent.y >= getMinExtent().y && newExtent.x >= getMinExtent().x)
{ {
@ -1212,7 +1212,7 @@ void GuiWindowCtrl::onMouseUp(const GuiEvent &event)
// We're either moving out of a collapse group or moving to another one // We're either moving out of a collapse group or moving to another one
// Not valid for windows not previously in a group // Not valid for windows not previously in a group
if( mCollapseGroup >= 0 && if( mCollapseGroup >= 0 &&
(snapType == -1 || (hitWindow && snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup))) (snapType == -1 || (hitWindow && snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup)))
moveFromCollapseGroup(); moveFromCollapseGroup();
// No window to connect to // No window to connect to
@ -1512,7 +1512,7 @@ void GuiWindowCtrl::setCloseCommand(const char *newCmd)
if (newCmd) if (newCmd)
mCloseCommand = StringTable->insert(newCmd); mCloseCommand = StringTable->insert(newCmd);
else else
mCloseCommand = StringTable->insert(""); mCloseCommand = StringTable->EmptyString();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1830,7 +1830,7 @@ void GuiWindowCtrl::parentResized(const RectI &oldParentRect, const RectI &newPa
// Only for collpasing groups, if were not, then do it like normal windows // Only for collpasing groups, if were not, then do it like normal windows
if( mCanCollapse && mCollapseGroup >= 0 ) if( mCanCollapse && mCollapseGroup >= 0 )
{ {
bool resizeMe = false; bool resizeMe = false;
// Only the group window should control positioning // Only the group window should control positioning

View file

@ -38,7 +38,7 @@ GuiGameListMenuCtrl::GuiGameListMenuCtrl()
VECTOR_SET_ASSOCIATION(mRows); VECTOR_SET_ASSOCIATION(mRows);
// initialize the control callbacks // initialize the control callbacks
mCallbackOnA = StringTable->insert(""); mCallbackOnA = StringTable->EmptyString();
mCallbackOnB = mCallbackOnA; mCallbackOnB = mCallbackOnA;
mCallbackOnX = mCallbackOnA; mCallbackOnX = mCallbackOnA;
mCallbackOnY = mCallbackOnA; mCallbackOnY = mCallbackOnA;
@ -572,7 +572,7 @@ StringTableEntry GuiGameListMenuCtrl::getRowLabel(S32 rowIndex) const
if (! isValidRowIndex(rowIndex)) if (! isValidRowIndex(rowIndex))
{ {
// not a valid row index, don't do anything // not a valid row index, don't do anything
return StringTable->insert(""); return StringTable->EmptyString();
} }
return mRows[rowIndex]->mLabel; return mRows[rowIndex]->mLabel;
} }

View file

@ -52,9 +52,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onMouseDragged, void, (),(),
"@tsexample\n" "@tsexample\n"
"// Mouse is dragged across the control, causing the callback to occur.\n" "// Mouse is dragged across the control, causing the callback to occur.\n"
"GuiListBoxCtrl::onMouseDragged(%this)\n" "GuiListBoxCtrl::onMouseDragged(%this)\n"
" {\n" " {\n"
" // Code to run whenever the mouse is dragged across the control\n" " // Code to run whenever the mouse is dragged across the control\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -64,9 +64,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onClearSelection, void, (),(),
"@tsexample\n" "@tsexample\n"
"// A selected item is cleared, causing the callback to occur.\n" "// A selected item is cleared, causing the callback to occur.\n"
"GuiListBoxCtrl::onClearSelection(%this)\n" "GuiListBoxCtrl::onClearSelection(%this)\n"
" {\n" " {\n"
" // Code to run whenever a selected item is cleared\n" " // Code to run whenever a selected item is cleared\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -78,9 +78,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onUnSelect, void, ( S32 index, const char* i
"@tsexample\n" "@tsexample\n"
"// A selected item is unselected, causing the callback to occur\n" "// A selected item is unselected, causing the callback to occur\n"
"GuiListBoxCtrl::onUnSelect(%this, %indexId, %itemText)\n" "GuiListBoxCtrl::onUnSelect(%this, %indexId, %itemText)\n"
" {\n" " {\n"
" // Code to run whenever a selected list item is unselected\n" " // Code to run whenever a selected list item is unselected\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -92,9 +92,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onSelect, void, ( S32 index , const char* it
"@tsexample\n" "@tsexample\n"
"// An item in the list is selected, causing the callback to occur\n" "// An item in the list is selected, causing the callback to occur\n"
"GuiListBoxCtrl::onSelect(%this, %index, %itemText)\n" "GuiListBoxCtrl::onSelect(%this, %index, %itemText)\n"
" {\n" " {\n"
" // Code to run whenever an item in the list is selected\n" " // Code to run whenever an item in the list is selected\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -104,9 +104,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onDoubleClick, void, (),(),
"@tsexample\n" "@tsexample\n"
"// An item in the list is double clicked, causing the callback to occur.\n" "// An item in the list is double clicked, causing the callback to occur.\n"
"GuiListBoxCtrl::onDoubleClick(%this)\n" "GuiListBoxCtrl::onDoubleClick(%this)\n"
" {\n" " {\n"
" // Code to run whenever an item in the control has been double clicked\n" " // Code to run whenever an item in the control has been double clicked\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -121,9 +121,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onMouseUp, void, ( S32 itemHit, S32 mouseCli
"@tsexample\n" "@tsexample\n"
"// Mouse was previously clicked down, and now has been released, causing the callback to occur.\n" "// Mouse was previously clicked down, and now has been released, causing the callback to occur.\n"
"GuiListBoxCtrl::onMouseUp(%this, %itemHit, %mouseClickCount)\n" "GuiListBoxCtrl::onMouseUp(%this, %itemHit, %mouseClickCount)\n"
" {\n" " {\n"
" // Code to call whenever the mouse has been clicked and released on the control\n" " // Code to call whenever the mouse has been clicked and released on the control\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -133,9 +133,9 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, onDeleteKey, void, (),(),
"@tsexample\n" "@tsexample\n"
"// The delete key on the keyboard has been pressed while this control is in focus, causing the callback to occur.\n" "// The delete key on the keyboard has been pressed while this control is in focus, causing the callback to occur.\n"
"GuiListBoxCtrl::onDeleteKey(%this)\n" "GuiListBoxCtrl::onDeleteKey(%this)\n"
" {\n" " {\n"
" // Code to call whenever the delete key is pressed\n" " // Code to call whenever the delete key is pressed\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -146,10 +146,10 @@ IMPLEMENT_CALLBACK( GuiListBoxCtrl, isObjectMirrored, bool, ( const char* indexI
"@tsexample\n" "@tsexample\n"
"// Engine has requested of the script level to determine if a list entry is mirrored or not.\n" "// Engine has requested of the script level to determine if a list entry is mirrored or not.\n"
"GuiListBoxCtrl::isObjectMirrored(%this, %indexIdString)\n" "GuiListBoxCtrl::isObjectMirrored(%this, %indexIdString)\n"
" {\n" " {\n"
" // Perform code required to check and see if the list item at the index id is mirrored or not.\n" " // Perform code required to check and see if the list item at the index id is mirrored or not.\n"
" return %isMirrored;\n" " return %isMirrored;\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@return A boolean value on if the list item is mirrored or not.\n\n" "@return A boolean value on if the list item is mirrored or not.\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
@ -234,7 +234,7 @@ void GuiListBoxCtrl::clearItems()
// Free our vector lists // Free our vector lists
mItems.clear(); mItems.clear();
mSelectedItems.clear(); mSelectedItems.clear();
mFilteredItems.clear(); mFilteredItems.clear();
} }
DefineEngineMethod( GuiListBoxCtrl, clearSelection, void, (),, DefineEngineMethod( GuiListBoxCtrl, clearSelection, void, (),,
@ -1511,8 +1511,8 @@ void GuiListBoxCtrl::_mirror()
break; break;
} }
} }
for ( U32 j = 0; j < mFilteredItems.size(); j++ ) for ( U32 j = 0; j < mFilteredItems.size(); j++ )
{ {
if ( (SimObjectId)(uintptr_t)(mFilteredItems[j]->itemData) == curId ) if ( (SimObjectId)(uintptr_t)(mFilteredItems[j]->itemData) == curId )
{ {
@ -1530,7 +1530,7 @@ void GuiListBoxCtrl::_mirror()
StringTableEntry GuiListBoxCtrl::_makeMirrorItemName( SimObject *inObj ) StringTableEntry GuiListBoxCtrl::_makeMirrorItemName( SimObject *inObj )
{ {
StringTableEntry outName = StringTable->insert(""); StringTableEntry outName = StringTable->EmptyString();
if ( mMakeNameCallback.isNotEmpty() ) if ( mMakeNameCallback.isNotEmpty() )
{ {
@ -1571,37 +1571,37 @@ DefineEngineMethod( GuiListBoxCtrl, addFilteredItem, void, (const char* newItem)
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl") "@see GuiControl")
{ {
String item(newItem); String item(newItem);
if( item == String::EmptyString ) if( item == String::EmptyString )
return; return;
object->addFilteredItem( item ); object->addFilteredItem( item );
} }
void GuiListBoxCtrl::addFilteredItem( String item ) void GuiListBoxCtrl::addFilteredItem( String item )
{ {
// Delete from selected items list // Delete from selected items list
for ( S32 i = 0; i < mSelectedItems.size(); i++ ) for ( S32 i = 0; i < mSelectedItems.size(); i++ )
{ {
String itemText = mSelectedItems[i]->itemText; String itemText = mSelectedItems[i]->itemText;
if ( dStrcmp( itemText.c_str(), item.c_str() ) == 0 ) if ( dStrcmp( itemText.c_str(), item.c_str() ) == 0 )
{ {
mSelectedItems.erase_fast( i ); mSelectedItems.erase_fast( i );
break; break;
} }
} }
for ( S32 i = 0; i < mItems.size(); i++ ) for ( S32 i = 0; i < mItems.size(); i++ )
{ {
String itemText = mItems[i]->itemText; String itemText = mItems[i]->itemText;
if( dStrcmp( itemText.c_str(), item.c_str() ) == 0 ) if( dStrcmp( itemText.c_str(), item.c_str() ) == 0 )
{ {
mItems[i]->isSelected = false; mItems[i]->isSelected = false;
mFilteredItems.push_front( mItems[i] ); mFilteredItems.push_front( mItems[i] );
mItems.erase( &mItems[i] ); mItems.erase( &mItems[i] );
break; break;
} }
} }
} }
DefineEngineMethod( GuiListBoxCtrl, removeFilteredItem, void, ( const char* itemName ),, DefineEngineMethod( GuiListBoxCtrl, removeFilteredItem, void, ( const char* itemName ),,
@ -1615,23 +1615,23 @@ DefineEngineMethod( GuiListBoxCtrl, removeFilteredItem, void, ( const char* item
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl") "@see GuiControl")
{ {
String item(itemName); String item(itemName);
if( item == String::EmptyString ) if( item == String::EmptyString )
return; return;
object->removeFilteredItem( item ); object->removeFilteredItem( item );
} }
void GuiListBoxCtrl::removeFilteredItem( String item ) void GuiListBoxCtrl::removeFilteredItem( String item )
{ {
for ( S32 i = 0; i < mFilteredItems.size(); i++ ) for ( S32 i = 0; i < mFilteredItems.size(); i++ )
{ {
String itemText = mFilteredItems[i]->itemText; String itemText = mFilteredItems[i]->itemText;
if( dStrcmp( itemText.c_str(), item.c_str() ) == 0 ) if( dStrcmp( itemText.c_str(), item.c_str() ) == 0 )
{ {
mItems.push_front( mFilteredItems[i] ); mItems.push_front( mFilteredItems[i] );
mFilteredItems.erase( &mFilteredItems[i] ); mFilteredItems.erase( &mFilteredItems[i] );
break; break;
} }
} }
} }

View file

@ -66,9 +66,9 @@ IMPLEMENT_CALLBACK( GuiMLTextCtrl, onURL, void, ( const char* url ),( url ),
"@tsexample\n" "@tsexample\n"
"// A URL address was clicked on in the control, causing the callback to occur.\n" "// A URL address was clicked on in the control, causing the callback to occur.\n"
"GuiMLTextCtrl::onUrl(%this,%url)\n" "GuiMLTextCtrl::onUrl(%this,%url)\n"
" {\n" " {\n"
" // Code to run whenever a URL was clicked on\n" " // Code to run whenever a URL was clicked on\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -80,9 +80,9 @@ IMPLEMENT_CALLBACK( GuiMLTextCtrl, onResize, void, ( S32 width, S32 maxY ),( wid
"@tsexample\n" "@tsexample\n"
"// Control size changed, causing the callback to occur.\n" "// Control size changed, causing the callback to occur.\n"
"GuiMLTextCtrl::onResize(%this,%width,%maxY)\n" "GuiMLTextCtrl::onResize(%this,%width,%maxY)\n"
" {\n" " {\n"
" // Code to call when the control size changes\n" " // Code to call when the control size changes\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
); );
@ -191,17 +191,17 @@ DefineEngineMethod( GuiMLTextCtrl, scrollToBottom, void, (),,
} }
DefineEngineFunction(StripMLControlChars, const char*, (const char* inString),, DefineEngineFunction(StripMLControlChars, const char*, (const char* inString),,
"@brief Strip TorqueML control characters from the specified string, returning a 'clean' version.\n\n" "@brief Strip TorqueML control characters from the specified string, returning a 'clean' version.\n\n"
"@param inString String to strip TorqueML control characters from.\n" "@param inString String to strip TorqueML control characters from.\n"
"@tsexample\n" "@tsexample\n"
"// Define the string to strip TorqueML control characters from\n" "// Define the string to strip TorqueML control characters from\n"
"%string = \"<font:Arial:24>How Now <color:c43c12>Brown <color:000000>Cow\";\n\n" "%string = \"<font:Arial:24>How Now <color:c43c12>Brown <color:000000>Cow\";\n\n"
"// Request the stripped version of the string\n" "// Request the stripped version of the string\n"
"%strippedString = StripMLControlChars(%string);\n" "%strippedString = StripMLControlChars(%string);\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@return Version of the inputted string with all TorqueML characters removed.\n\n" "@return Version of the inputted string with all TorqueML characters removed.\n\n"
"@see References\n\n" "@see References\n\n"
"@ingroup GuiCore") "@ingroup GuiCore")
{ {
return GuiMLTextCtrl::stripControlChars(inString); return GuiMLTextCtrl::stripControlChars(inString);
} }
@ -251,7 +251,7 @@ GuiMLTextCtrl::GuiMLTextCtrl()
mIsEditCtrl( false ), mIsEditCtrl( false ),
mCursorPosition( false ), mCursorPosition( false ),
mMaxBufferSize( -1 ), mMaxBufferSize( -1 ),
mInitialText( StringTable->insert("") ), mInitialText( StringTable->EmptyString() ),
mSelectionActive( false ), mSelectionActive( false ),
mSelectionStart( 0 ), mSelectionStart( 0 ),
mSelectionEnd( 0 ), mSelectionEnd( 0 ),
@ -267,7 +267,7 @@ GuiMLTextCtrl::GuiMLTextCtrl()
mFontList( NULL ) mFontList( NULL )
{ {
mActive = true; mActive = true;
//mInitialText = StringTable->insert(""); //mInitialText = StringTable->EmptyString();
Sim::findObject("InputDeniedSound", mDeniedSound); Sim::findObject("InputDeniedSound", mDeniedSound);
} }
@ -293,7 +293,7 @@ void GuiMLTextCtrl::initPersistFields()
addField("deniedSound", TypeSFXTrackName, Offset(mDeniedSound, GuiMLTextCtrl), "If the text will not fit in the control, the deniedSound is played."); addField("deniedSound", TypeSFXTrackName, Offset(mDeniedSound, GuiMLTextCtrl), "If the text will not fit in the control, the deniedSound is played.");
addField("text", TypeCaseString, Offset( mInitialText, GuiMLTextCtrl ), "Text to display in this control."); addField("text", TypeCaseString, Offset( mInitialText, GuiMLTextCtrl ), "Text to display in this control.");
addField("useURLMouseCursor", TypeBool, Offset(mUseURLMouseCursor, GuiMLTextCtrl), "If true, the mouse cursor will turn into a hand cursor while over a link in the text.\n" addField("useURLMouseCursor", TypeBool, Offset(mUseURLMouseCursor, GuiMLTextCtrl), "If true, the mouse cursor will turn into a hand cursor while over a link in the text.\n"
"This is dependant on the markup language used by the GuiMLTextCtrl\n"); "This is dependant on the markup language used by the GuiMLTextCtrl\n");
endGroup( "Text" ); endGroup( "Text" );
@ -649,9 +649,9 @@ void GuiMLTextCtrl::ensureCursorOnScreen()
// If our parent isn't a scroll control, or we're not the only control // If our parent isn't a scroll control, or we're not the only control
// in the content region, bail... // in the content region, bail...
GuiControl* pParent = getParent(); GuiControl* pParent = getParent();
GuiScrollCtrl *sc = dynamic_cast<GuiScrollCtrl*>(pParent); GuiScrollCtrl *sc = dynamic_cast<GuiScrollCtrl*>(pParent);
if(!sc) if(!sc)
return; return;
// Ok. Now we know that our parent is a scroll control. Let's find the // Ok. Now we know that our parent is a scroll control. Let's find the
// top of the cursor, and it's bottom. We can then scroll the parent control // top of the cursor, and it's bottom. We can then scroll the parent control
@ -661,7 +661,7 @@ void GuiMLTextCtrl::ensureCursorOnScreen()
ColorI color; ColorI color;
getCursorPositionAndColor(cursorTopP, cursorBottomP, color); getCursorPositionAndColor(cursorTopP, cursorBottomP, color);
sc->scrollRectVisible(RectI(cursorTopP.x, cursorTopP.y, 1, cursorBottomP.y - cursorTopP.y)); sc->scrollRectVisible(RectI(cursorTopP.x, cursorTopP.y, 1, cursorBottomP.y - cursorTopP.y));
} }
//-------------------------------------- //--------------------------------------
@ -840,7 +840,7 @@ void GuiMLTextCtrl::onMouseUp(const GuiEvent& event)
// Convert URL from UTF16 to UTF8. // Convert URL from UTF16 to UTF8.
UTF8* url = mTextBuffer.createSubstring8(mHitURL->textStart, mHitURL->len); UTF8* url = mTextBuffer.createSubstring8(mHitURL->textStart, mHitURL->len);
onURL_callback(url); onURL_callback(url);
delete[] url; delete[] url;
mHitURL = NULL; mHitURL = NULL;
@ -1018,7 +1018,7 @@ void GuiMLTextCtrl::scrollToTag( U32 id )
Con::warnf( ConsoleLogEntry::General, "GuiMLTextCtrl::scrollToTag - tag id %d not found!", id ); Con::warnf( ConsoleLogEntry::General, "GuiMLTextCtrl::scrollToTag - tag id %d not found!", id );
return; return;
} }
pappy->scrollRectVisible(RectI(0, tag->y, 1, 1)); pappy->scrollRectVisible(RectI(0, tag->y, 1, 1));
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -1028,7 +1028,7 @@ void GuiMLTextCtrl::scrollToTop()
GuiScrollCtrl *pappy = dynamic_cast<GuiScrollCtrl*>(getParent()); GuiScrollCtrl *pappy = dynamic_cast<GuiScrollCtrl*>(getParent());
if ( !pappy ) if ( !pappy )
return; return;
pappy->scrollRectVisible(RectI(0,0,0,0)); pappy->scrollRectVisible(RectI(0,0,0,0));
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -2134,7 +2134,7 @@ textemit:
emitNewLine(mScanPos); emitNewLine(mScanPos);
setHeight( mMaxY ); setHeight( mMaxY );
onResize_callback( getWidth(), mMaxY ); onResize_callback( getWidth(), mMaxY );
//make sure the cursor is still visible - this handles if we're a child of a scroll ctrl... //make sure the cursor is still visible - this handles if we're a child of a scroll ctrl...
ensureCursorOnScreen(); ensureCursorOnScreen();
} }

View file

@ -233,31 +233,31 @@ void GuiPopupTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selec
IMPLEMENT_CONOBJECT(GuiPopUpMenuCtrl); IMPLEMENT_CONOBJECT(GuiPopUpMenuCtrl);
ConsoleDocClass( GuiPopUpMenuCtrl, ConsoleDocClass( GuiPopUpMenuCtrl,
"@brief A control that allows to select a value from a drop-down list.\n\n" "@brief A control that allows to select a value from a drop-down list.\n\n"
"For a nearly identical GUI with additional features, use GuiPopUpMenuCtrlEx.\n\n" "For a nearly identical GUI with additional features, use GuiPopUpMenuCtrlEx.\n\n"
"@tsexample\n" "@tsexample\n"
"new GuiPopUpMenuCtrl()\n" "new GuiPopUpMenuCtrl()\n"
"{\n" "{\n"
" maxPopupHeight = \"200\";\n" " maxPopupHeight = \"200\";\n"
" sbUsesNAColor = \"0\";\n" " sbUsesNAColor = \"0\";\n"
" reverseTextList = \"0\";\n" " reverseTextList = \"0\";\n"
" bitmapBounds = \"16 16\";\n" " bitmapBounds = \"16 16\";\n"
" maxLength = \"1024\";\n" " maxLength = \"1024\";\n"
" position = \"56 31\";\n" " position = \"56 31\";\n"
" extent = \"64 64\";\n" " extent = \"64 64\";\n"
" minExtent = \"8 2\";\n" " minExtent = \"8 2\";\n"
" profile = \"GuiPopUpMenuProfile\";\n" " profile = \"GuiPopUpMenuProfile\";\n"
" tooltipProfile = \"GuiToolTipProfile\";\n" " tooltipProfile = \"GuiToolTipProfile\";\n"
"};\n" "};\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@note This is definitely going to be deprecated soon.\n\n" "@note This is definitely going to be deprecated soon.\n\n"
"@see GuiPopUpMenuCtrlEx for more features and better explanations.\n" "@see GuiPopUpMenuCtrlEx for more features and better explanations.\n"
"@ingroup GuiControls\n"); "@ingroup GuiControls\n");
GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void) GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void)
{ {
@ -277,9 +277,9 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void)
mRenderScrollInNA = false; // Added mRenderScrollInNA = false; // Added
mBackgroundCancel = false; // Added mBackgroundCancel = false; // Added
mReverseTextList = false; // Added - Don't reverse text list if displaying up mReverseTextList = false; // Added - Don't reverse text list if displaying up
mBitmapName = StringTable->insert(""); // Added mBitmapName = StringTable->EmptyString(); // Added
mBitmapBounds.set(16, 16); // Added mBitmapBounds.set(16, 16); // Added
mIdMax = -1; mIdMax = -1;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -302,11 +302,11 @@ void GuiPopUpMenuCtrl::initPersistFields(void)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrl, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)") DefineConsoleMethod( GuiPopUpMenuCtrl, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
{ {
object->addEntry(name, idNum, scheme); object->addEntry(name, idNum, scheme);
} }
DefineConsoleMethod( GuiPopUpMenuCtrl, addScheme, void, (U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL), , DefineConsoleMethod( GuiPopUpMenuCtrl, addScheme, void, (U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL), ,
"(int id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL)") "(int id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL)")
{ {
object->addScheme( id, fontColor, fontColorHL, fontColorSEL ); object->addScheme( id, fontColor, fontColorHL, fontColorSEL );
@ -492,43 +492,43 @@ void GuiPopUpMenuCtrl::clear()
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
mRevNum = 0; mRevNum = 0;
mIdMax = -1; mIdMax = -1;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void GuiPopUpMenuCtrl::clearEntry( S32 entry ) void GuiPopUpMenuCtrl::clearEntry( S32 entry )
{ {
if( entry == -1 ) if( entry == -1 )
return; return;
U32 i = 0; U32 i = 0;
for ( ; i < mEntries.size(); i++ ) for ( ; i < mEntries.size(); i++ )
{ {
if ( mEntries[i].id == entry ) if ( mEntries[i].id == entry )
break; break;
} }
mEntries.erase( i ); mEntries.erase( i );
if( mEntries.size() <= 0 ) if( mEntries.size() <= 0 )
{ {
mEntries.setSize(0); mEntries.setSize(0);
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
mRevNum = 0; mRevNum = 0;
} }
else else
{ {
if (entry < mSelIndex) if (entry < mSelIndex)
{ {
mSelIndex--; mSelIndex--;
} }
else if( entry == mSelIndex ) else if( entry == mSelIndex )
{ {
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
} }
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -620,21 +620,21 @@ void GuiPopUpMenuCtrl::addEntry( const char *buf, S32 id, U32 scheme )
//Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" ); //Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" );
return; return;
} }
// Ensure that there are no other entries with exactly the same name // Ensure that there are no other entries with exactly the same name
for ( U32 i = 0; i < mEntries.size(); i++ ) for ( U32 i = 0; i < mEntries.size(); i++ )
{ {
if ( dStrcmp( mEntries[i].buf, buf ) == 0 ) if ( dStrcmp( mEntries[i].buf, buf ) == 0 )
return; return;
} }
// If we don't give an id, create one from mIdMax // If we don't give an id, create one from mIdMax
if( id == -1 ) if( id == -1 )
id = mIdMax + 1; id = mIdMax + 1;
// Increase mIdMax when an id is greater than it // Increase mIdMax when an id is greater than it
if( id > mIdMax ) if( id > mIdMax )
mIdMax = id; mIdMax = id;
Entry e; Entry e;
dStrcpy( e.buf, buf ); dStrcpy( e.buf, buf );
@ -802,28 +802,28 @@ void GuiPopUpMenuCtrl::setFirstSelected( bool bNotifyScript )
setText( mEntries[0].buf ); setText( mEntries[0].buf );
} }
// Execute the popup console command: // Execute the popup console command:
if( bNotifyScript ) if( bNotifyScript )
{ {
if ( isMethod( "onSelect" ) ) if ( isMethod( "onSelect" ) )
Con::executef( this, "onSelect", Con::getIntArg( mEntries[ mSelIndex ].id ), mEntries[mSelIndex].buf ); Con::executef( this, "onSelect", Con::getIntArg( mEntries[ mSelIndex ].id ), mEntries[mSelIndex].buf );
execConsoleCallback();
}
}
else
{
if ( mReplaceText ) // Only change the displayed text if appropriate.
setText("");
mSelIndex = -1;
if( bNotifyScript )
{
Con::executef( this, "onCancel" );
execConsoleCallback(); execConsoleCallback();
} }
} }
else
{
if ( mReplaceText ) // Only change the displayed text if appropriate.
setText("");
mSelIndex = -1;
if( bNotifyScript )
{
Con::executef( this, "onCancel" );
execConsoleCallback();
}
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -1278,11 +1278,11 @@ void GuiPopUpMenuCtrl::onAction()
if ( setScroll ) if ( setScroll )
{ {
// Resize the text list // Resize the text list
Point2I cellSize; Point2I cellSize;
mTl->getCellSize( cellSize ); mTl->getCellSize( cellSize );
cellSize.x = width - mSc->scrollBarThickness() - sbBorder; cellSize.x = width - mSc->scrollBarThickness() - sbBorder;
mTl->setCellSize( cellSize ); mTl->setCellSize( cellSize );
mTl->setWidth( cellSize.x ); mTl->setWidth( cellSize.x );
if ( mSelIndex ) if ( mSelIndex )
mTl->scrollCellVisible( Point2I( 0, mSelIndex ) ); mTl->scrollCellVisible( Point2I( 0, mSelIndex ) );
@ -1315,7 +1315,7 @@ void GuiPopUpMenuCtrl::addChildren()
else else
{ {
// Use the children's profile rather than the parent's profile, if it exists. // Use the children's profile rather than the parent's profile, if it exists.
mSc->setControlProfile( mProfile->getChildrenProfile() ? mProfile->getChildrenProfile() : mProfile ); mSc->setControlProfile( mProfile->getChildrenProfile() ? mProfile->getChildrenProfile() : mProfile );
} }
mSc->setField( "hScrollBar", "AlwaysOff" ); mSc->setField( "hScrollBar", "AlwaysOff" );

View file

@ -30,27 +30,27 @@
#include "console/engineAPI.h" #include "console/engineAPI.h"
ConsoleDocClass( GuiPopUpMenuCtrlEx, ConsoleDocClass( GuiPopUpMenuCtrlEx,
"@brief A control that allows to select a value from a drop-down list.\n\n" "@brief A control that allows to select a value from a drop-down list.\n\n"
"This is essentially a GuiPopUpMenuCtrl, but with quite a few more features.\n\n" "This is essentially a GuiPopUpMenuCtrl, but with quite a few more features.\n\n"
"@tsexample\n" "@tsexample\n"
"new GuiPopUpMenuCtrlEx()\n" "new GuiPopUpMenuCtrlEx()\n"
"{\n" "{\n"
" maxPopupHeight = \"200\";\n" " maxPopupHeight = \"200\";\n"
" sbUsesNAColor = \"0\";\n" " sbUsesNAColor = \"0\";\n"
" reverseTextList = \"0\";\n" " reverseTextList = \"0\";\n"
" bitmapBounds = \"16 16\";\n" " bitmapBounds = \"16 16\";\n"
" hotTrackCallback = \"0\";\n" " hotTrackCallback = \"0\";\n"
" extent = \"64 64\";\n" " extent = \"64 64\";\n"
" profile = \"GuiDefaultProfile\";\n" " profile = \"GuiDefaultProfile\";\n"
" tooltipProfile = \"GuiToolTipProfile\";\n" " tooltipProfile = \"GuiToolTipProfile\";\n"
"};\n" "};\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiPopUpMenuCtrl\n" "@see GuiPopUpMenuCtrl\n"
"@ingroup GuiControls\n"); "@ingroup GuiControls\n");
static ColorI colorWhite(255,255,255); // Added static ColorI colorWhite(255,255,255); // Added
@ -328,10 +328,10 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void)
mRenderScrollInNA = false; // Added mRenderScrollInNA = false; // Added
mBackgroundCancel = false; // Added mBackgroundCancel = false; // Added
mReverseTextList = false; // Added - Don't reverse text list if displaying up mReverseTextList = false; // Added - Don't reverse text list if displaying up
mBitmapName = StringTable->insert(""); // Added mBitmapName = StringTable->EmptyString(); // Added
mBitmapBounds.set(16, 16); // Added mBitmapBounds.set(16, 16); // Added
mHotTrackItems = false; mHotTrackItems = false;
mIdMax = -1; mIdMax = -1;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -355,13 +355,13 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ConsoleDocFragment _GuiPopUpMenuCtrlExAdd( ConsoleDocFragment _GuiPopUpMenuCtrlExAdd(
"@brief Adds an entry to the list\n\n" "@brief Adds an entry to the list\n\n"
"@param name String containing the name of the entry\n" "@param name String containing the name of the entry\n"
"@param idNum Numerical value assigned to the name\n" "@param idNum Numerical value assigned to the name\n"
"@param scheme Optional ID associated with a scheme " "@param scheme Optional ID associated with a scheme "
"for font coloring, highlight coloring, and selection coloring\n\n", "for font coloring, highlight coloring, and selection coloring\n\n",
"GuiPopUpMenuCtrlEx", "GuiPopUpMenuCtrlEx",
"void add(string name, S32 idNum, S32 scheme=0);" "void add(string name, S32 idNum, S32 scheme=0);"
); );
DefineConsoleMethod( GuiPopUpMenuCtrlEx, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)") DefineConsoleMethod( GuiPopUpMenuCtrlEx, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
@ -370,23 +370,23 @@ DefineConsoleMethod( GuiPopUpMenuCtrlEx, add, void, (const char * name, S32 idNu
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, addCategory, void, (const char* text),, DefineEngineMethod( GuiPopUpMenuCtrlEx, addCategory, void, (const char* text),,
"@brief Add a category to the list.\n\n" "@brief Add a category to the list.\n\n"
"Acts as a separator between entries, allowing for sub-lists\n\n" "Acts as a separator between entries, allowing for sub-lists\n\n"
"@param text Name of the new category\n\n") "@param text Name of the new category\n\n")
{ {
object->addEntry(text, -1, 0); object->addEntry(text, -1, 0);
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL),, DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL),,
"@brief Create a new scheme and add it to the list of choices for when a new text entry is added.\n\n" "@brief Create a new scheme and add it to the list of choices for when a new text entry is added.\n\n"
"@param id Numerical id associated with this scheme\n" "@param id Numerical id associated with this scheme\n"
"@param fontColor The base text font color. Formatted as \"Red Green Blue\", each a numerical between 0 and 255.\n" "@param fontColor The base text font color. Formatted as \"Red Green Blue\", each a numerical between 0 and 255.\n"
"@param fontColorHL Color of text when being highlighted. Formatted as \"Red Green Blue\", each a numerical between 0 and 255.\n" "@param fontColorHL Color of text when being highlighted. Formatted as \"Red Green Blue\", each a numerical between 0 and 255.\n"
"@param fontColorSel Color of text when being selected. Formatted as \"Red Green Blue\", each a numerical between 0 and 255.\n") "@param fontColorSel Color of text when being selected. Formatted as \"Red Green Blue\", each a numerical between 0 and 255.\n")
{ {
/*ColorI fontColor, fontColorHL, fontColorSEL; /*ColorI fontColor, fontColorHL, fontColorSEL;
U32 r, g, b; U32 r, g, b;
char buf[64]; char buf[64];
@ -457,127 +457,127 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
//} //}
DefineEngineMethod( GuiPopUpMenuCtrlEx, setText, void, ( const char* text),, DefineEngineMethod( GuiPopUpMenuCtrlEx, setText, void, ( const char* text),,
"@brief Set the current text to a specified value.\n\n" "@brief Set the current text to a specified value.\n\n"
"@param text String containing new text to set\n\n") "@param text String containing new text to set\n\n")
{ {
object->setText(text); object->setText(text);
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, getText, const char*, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, getText, const char*, (),,
"@brief Get the.\n\n" "@brief Get the.\n\n"
"Detailed description\n\n" "Detailed description\n\n"
"@param param Description\n\n" "@param param Description\n\n"
"@tsexample\n" "@tsexample\n"
"// Comment\n" "// Comment\n"
"code();\n" "code();\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@return Returns current text in string format") "@return Returns current text in string format")
{ {
return object->getText(); return object->getText();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, clear, void, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, clear, void, (),,
"@brief Clear the popup list.\n\n") "@brief Clear the popup list.\n\n")
{ {
object->clear(); object->clear();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, sort, void, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, sort, void, (),,
"@brief Sort the list alphabetically.\n\n") "@brief Sort the list alphabetically.\n\n")
{ {
object->sort(); object->sort();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, sortID, void, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, sortID, void, (),,
"@brief Sort the list by ID.\n\n") "@brief Sort the list by ID.\n\n")
{ {
object->sortID(); object->sortID();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, forceOnAction, void, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, forceOnAction, void, (),,
"@brief Manually for the onAction function, which updates everything in this control.\n\n") "@brief Manually for the onAction function, which updates everything in this control.\n\n")
{ {
object->onAction(); object->onAction();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, forceClose, void, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, forceClose, void, (),,
"@brief Manually force this control to collapse and close.\n\n") "@brief Manually force this control to collapse and close.\n\n")
{ {
object->closePopUp(); object->closePopUp();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, getSelected, S32, (),, DefineEngineMethod( GuiPopUpMenuCtrlEx, getSelected, S32, (),,
"@brief Get the current selection of the menu.\n\n" "@brief Get the current selection of the menu.\n\n"
"@return Returns the ID of the currently selected entry") "@return Returns the ID of the currently selected entry")
{ {
return object->getSelected(); return object->getSelected();
} }
ConsoleDocFragment _GuiPopUpMenuCtrlExsetSelected( ConsoleDocFragment _GuiPopUpMenuCtrlExsetSelected(
"brief Manually set an entry as selected int his control\n\n" "brief Manually set an entry as selected int his control\n\n"
"@param id The ID of the entry to select\n" "@param id The ID of the entry to select\n"
"@param scripCallback Optional boolean that forces the script callback if true\n", "@param scripCallback Optional boolean that forces the script callback if true\n",
"GuiPopUpMenuCtrlEx", "GuiPopUpMenuCtrlEx",
"setSelected(int id, bool scriptCallback=true);" "setSelected(int id, bool scriptCallback=true);"
); );
DefineConsoleMethod( GuiPopUpMenuCtrlEx, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])" DefineConsoleMethod( GuiPopUpMenuCtrlEx, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])"
"@hide") "@hide")
{ {
object->setSelected( id, scriptCallback ); object->setSelected( id, scriptCallback );
} }
ConsoleDocFragment _GuiPopUpMenuCtrlExsetFirstSelected( ConsoleDocFragment _GuiPopUpMenuCtrlExsetFirstSelected(
"brief Manually set the selection to the first entry\n\n" "brief Manually set the selection to the first entry\n\n"
"@param scripCallback Optional boolean that forces the script callback if true\n", "@param scripCallback Optional boolean that forces the script callback if true\n",
"GuiPopUpMenuCtrlEx", "GuiPopUpMenuCtrlEx",
"setSelected(bool scriptCallback=true);" "setSelected(bool scriptCallback=true);"
); );
DefineConsoleMethod( GuiPopUpMenuCtrlEx, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])" DefineConsoleMethod( GuiPopUpMenuCtrlEx, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])"
"@hide") "@hide")
{ {
object->setFirstSelected( scriptCallback ); object->setFirstSelected( scriptCallback );
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, setNoneSelected, void, ( S32 param),, DefineEngineMethod( GuiPopUpMenuCtrlEx, setNoneSelected, void, ( S32 param),,
"@brief Clears selection in the menu.\n\n") "@brief Clears selection in the menu.\n\n")
{ {
object->setNoneSelected(); object->setNoneSelected();
} }
DefineEngineMethod( GuiPopUpMenuCtrlEx, getTextById, const char*, (S32 id),, DefineEngineMethod( GuiPopUpMenuCtrlEx, getTextById, const char*, (S32 id),,
"@brief Get the text of an entry based on an ID.\n\n" "@brief Get the text of an entry based on an ID.\n\n"
"@param id The ID assigned to the entry being queried\n\n" "@param id The ID assigned to the entry being queried\n\n"
"@return String contained by the specified entry, NULL if empty or bad ID") "@return String contained by the specified entry, NULL if empty or bad ID")
{ {
return(object->getTextById(id)); return(object->getTextById(id));
} }
DefineConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, ColorI, (S32 id), , DefineConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, ColorI, (S32 id), ,
"@brief Get color of an entry's box\n\n" "@brief Get color of an entry's box\n\n"
"@param id ID number of entry to query\n\n" "@param id ID number of entry to query\n\n"
"@return ColorI in the format of \"Red Green Blue Alpha\", each of with is a value between 0 - 255") "@return ColorI in the format of \"Red Green Blue Alpha\", each of with is a value between 0 - 255")
{ {
ColorI color; ColorI color;
object->getColoredBox(color, id); object->getColoredBox(color, id);
return color; return color;
} }
DefineConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * className, const char * enumName ), , DefineConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * className, const char * enumName ), ,
"@brief This fills the popup with a classrep's field enumeration type info.\n\n" "@brief This fills the popup with a classrep's field enumeration type info.\n\n"
"More of a helper function than anything. If console access to the field list is added, " "More of a helper function than anything. If console access to the field list is added, "
"at least for the enumerated types, then this should go away.\n\n" "at least for the enumerated types, then this should go away.\n\n"
"@param class Name of the class containing the enum\n" "@param class Name of the class containing the enum\n"
"@param enum Name of the enum value to acces\n") "@param enum Name of the enum value to acces\n")
{ {
AbstractClassRep * classRep = AbstractClassRep::getClassList(); AbstractClassRep * classRep = AbstractClassRep::getClassList();
@ -630,24 +630,24 @@ DefineConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * cl
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, findText, S32, (const char * text), , "(string text)" DefineConsoleMethod( GuiPopUpMenuCtrlEx, findText, S32, (const char * text), , "(string text)"
"Returns the id of the first entry containing the specified text or -1 if not found." "Returns the id of the first entry containing the specified text or -1 if not found."
"@param text String value used for the query\n\n" "@param text String value used for the query\n\n"
"@return Numerical ID of entry containing the text.") "@return Numerical ID of entry containing the text.")
{ {
return( object->findText( text ) ); return( object->findText( text ) );
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, (), , DefineConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, (), ,
"@brief Get the size of the menu\n\n" "@brief Get the size of the menu\n\n"
"@return Number of entries in the menu\n") "@return Number of entries in the menu\n")
{ {
return( object->getNumEntries() ); return( object->getNumEntries() );
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, replaceText, void, (S32 boolVal), , DefineConsoleMethod( GuiPopUpMenuCtrlEx, replaceText, void, (S32 boolVal), ,
"@brief Flag that causes each new text addition to replace the current entry\n\n" "@brief Flag that causes each new text addition to replace the current entry\n\n"
"@param True to turn on replacing, false to disable it") "@param True to turn on replacing, false to disable it")
{ {
object->replaceText(boolVal); object->replaceText(boolVal);
} }
@ -697,43 +697,43 @@ void GuiPopUpMenuCtrlEx::clear()
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
mRevNum = 0; mRevNum = 0;
mIdMax = -1; mIdMax = -1;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void GuiPopUpMenuCtrlEx::clearEntry( S32 entry ) void GuiPopUpMenuCtrlEx::clearEntry( S32 entry )
{ {
if( entry == -1 ) if( entry == -1 )
return; return;
U32 i = 0; U32 i = 0;
for ( ; i < mEntries.size(); i++ ) for ( ; i < mEntries.size(); i++ )
{ {
if ( mEntries[i].id == entry ) if ( mEntries[i].id == entry )
break; break;
} }
mEntries.erase( i ); mEntries.erase( i );
if( mEntries.size() <= 0 ) if( mEntries.size() <= 0 )
{ {
mEntries.setSize(0); mEntries.setSize(0);
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
mRevNum = 0; mRevNum = 0;
} }
else else
{ {
if( entry == mSelIndex ) if( entry == mSelIndex )
{ {
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
} }
else else
{ {
mSelIndex--; mSelIndex--;
} }
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -797,9 +797,9 @@ void GuiPopUpMenuCtrlEx::sort()
if( size > 0 ) if( size > 0 )
dQsort( mEntries.address(), size, sizeof(Entry), textCompare); dQsort( mEntries.address(), size, sizeof(Entry), textCompare);
// Entries need to re-Id themselves // Entries need to re-Id themselves
for( U32 i = 0; i < mEntries.size(); i++ ) for( U32 i = 0; i < mEntries.size(); i++ )
mEntries[i].id = i; mEntries[i].id = i;
} }
// Added to sort by entry ID // Added to sort by entry ID
@ -810,9 +810,9 @@ void GuiPopUpMenuCtrlEx::sortID()
if( size > 0 ) if( size > 0 )
dQsort( mEntries.address(), size, sizeof(Entry), idCompare); dQsort( mEntries.address(), size, sizeof(Entry), idCompare);
// Entries need to re-Id themselves // Entries need to re-Id themselves
for( U32 i = 0; i < mEntries.size(); i++ ) for( U32 i = 0; i < mEntries.size(); i++ )
mEntries[i].id = i; mEntries[i].id = i;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -823,21 +823,21 @@ void GuiPopUpMenuCtrlEx::addEntry(const char *buf, S32 id, U32 scheme)
//Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" ); //Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" );
return; return;
} }
// Ensure that there are no other entries with exactly the same name // Ensure that there are no other entries with exactly the same name
for ( U32 i = 0; i < mEntries.size(); i++ ) for ( U32 i = 0; i < mEntries.size(); i++ )
{ {
if ( dStrcmp( mEntries[i].buf, buf ) == 0 ) if ( dStrcmp( mEntries[i].buf, buf ) == 0 )
return; return;
} }
// If we don't give an id, create one from mIdMax // If we don't give an id, create one from mIdMax
if( id == -1 ) if( id == -1 )
id = mIdMax + 1; id = mIdMax + 1;
// Increase mIdMax when an id is greater than it // Increase mIdMax when an id is greater than it
if( id > mIdMax ) if( id > mIdMax )
mIdMax = id; mIdMax = id;
Entry e; Entry e;
dStrcpy( e.buf, buf ); dStrcpy( e.buf, buf );
@ -992,20 +992,20 @@ void GuiPopUpMenuCtrlEx::setFirstSelected( bool bNotifyScript )
if ( isMethod( "onSelect" ) ) if ( isMethod( "onSelect" ) )
Con::executef( this, "onSelect", idval, mEntries[mSelIndex].buf ); Con::executef( this, "onSelect", idval, mEntries[mSelIndex].buf );
// Execute the popup console command: // Execute the popup console command:
if ( bNotifyScript ) if ( bNotifyScript )
execConsoleCallback(); execConsoleCallback();
} }
else else
{ {
if ( mReplaceText ) // Only change the displayed text if appropriate. if ( mReplaceText ) // Only change the displayed text if appropriate.
setText(""); setText("");
mSelIndex = -1; mSelIndex = -1;
if ( bNotifyScript ) if ( bNotifyScript )
Con::executef( this, "onCancel" ); Con::executef( this, "onCancel" );
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -1500,11 +1500,11 @@ void GuiPopUpMenuCtrlEx::onAction()
if ( setScroll ) if ( setScroll )
{ {
// Resize the text list // Resize the text list
Point2I cellSize; Point2I cellSize;
mTl->getCellSize( cellSize ); mTl->getCellSize( cellSize );
cellSize.x = width - mSc->scrollBarThickness() - sbBorder; cellSize.x = width - mSc->scrollBarThickness() - sbBorder;
mTl->setCellSize( cellSize ); mTl->setCellSize( cellSize );
mTl->setWidth( cellSize.x ); mTl->setWidth( cellSize.x );
if ( mSelIndex ) if ( mSelIndex )
mTl->scrollCellVisible( Point2I( 0, mSelIndex ) ); mTl->scrollCellVisible( Point2I( 0, mSelIndex ) );
@ -1536,7 +1536,7 @@ void GuiPopUpMenuCtrlEx::addChildren()
else else
{ {
// Use the children's profile rather than the parent's profile, if it exists. // Use the children's profile rather than the parent's profile, if it exists.
mSc->setControlProfile( mProfile->getChildrenProfile() ? mProfile->getChildrenProfile() : mProfile ); mSc->setControlProfile( mProfile->getChildrenProfile() ? mProfile->getChildrenProfile() : mProfile );
} }
mSc->setField( "hScrollBar", "AlwaysOff" ); mSc->setField( "hScrollBar", "AlwaysOff" );
mSc->setField( "vScrollBar", "dynamic" ); mSc->setField( "vScrollBar", "dynamic" );

View file

@ -37,13 +37,13 @@ ConsoleDocClass( GuiTextCtrl,
"@brief GUI control object this displays a single line of text, without TorqueML.\n\n" "@brief GUI control object this displays a single line of text, without TorqueML.\n\n"
"@tsexample\n" "@tsexample\n"
" new GuiTextCtrl()\n" " new GuiTextCtrl()\n"
" {\n" " {\n"
" text = \"Hello World\";\n" " text = \"Hello World\";\n"
" textID = \"\"STR_HELLO\"\";\n" " textID = \"\"STR_HELLO\"\";\n"
" maxlength = \"1024\";\n" " maxlength = \"1024\";\n"
" //Properties not specific to this control have been omitted from this example.\n" " //Properties not specific to this control have been omitted from this example.\n"
" };\n" " };\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiControl\n" "@see GuiControl\n"
@ -54,8 +54,8 @@ ConsoleDocClass( GuiTextCtrl,
GuiTextCtrl::GuiTextCtrl() GuiTextCtrl::GuiTextCtrl()
{ {
//default fonts //default fonts
mInitialText = StringTable->insert(""); mInitialText = StringTable->EmptyString();
mInitialTextID = StringTable->insert(""); mInitialTextID = StringTable->EmptyString();
mText[0] = '\0'; mText[0] = '\0';
mMaxStrLen = GuiTextCtrl::MAX_STRING_LENGTH; mMaxStrLen = GuiTextCtrl::MAX_STRING_LENGTH;
} }
@ -84,7 +84,7 @@ DefineEngineMethod( GuiTextCtrl, setTextID, void, (const char* textID),,
"@see GuiControl" "@see GuiControl"
"@see Localization") "@see Localization")
{ {
object->setTextID( textID ); object->setTextID( textID );
} }
void GuiTextCtrl::initPersistFields() void GuiTextCtrl::initPersistFields()
@ -117,7 +117,7 @@ void GuiTextCtrl::inspectPostApply()
{ {
Parent::inspectPostApply(); Parent::inspectPostApply();
if(mInitialTextID && *mInitialTextID != 0) if(mInitialTextID && *mInitialTextID != 0)
setTextID(mInitialTextID); setTextID(mInitialTextID);
else if( mConsoleVariable[ 0 ] ) else if( mConsoleVariable[ 0 ] )
setText( getVariable() ); setText( getVariable() );
else else
@ -135,7 +135,7 @@ bool GuiTextCtrl::onWake()
return false; return false;
} }
if(mInitialTextID && *mInitialTextID != 0) if(mInitialTextID && *mInitialTextID != 0)
setTextID(mInitialTextID); setTextID(mInitialTextID);
if ( mConsoleVariable[0] ) if ( mConsoleVariable[0] )
{ {
@ -202,19 +202,19 @@ void GuiTextCtrl::setText(const char *txt)
void GuiTextCtrl::setTextID(const char *id) void GuiTextCtrl::setTextID(const char *id)
{ {
S32 n = Con::getIntVariable(id, -1); S32 n = Con::getIntVariable(id, -1);
if(n != -1) if(n != -1)
{ {
mInitialTextID = StringTable->insert(id); mInitialTextID = StringTable->insert(id);
setTextID(n); setTextID(n);
} }
} }
void GuiTextCtrl::setTextID(S32 id) void GuiTextCtrl::setTextID(S32 id)
{ {
const UTF8 *str = getGUIString(id); const UTF8 *str = getGUIString(id);
if(str) if(str)
setText((const char*)str); setText((const char*)str);
//mInitialTextID = id; //mInitialTextID = id;
} }
void GuiTextCtrl::onPreRender() void GuiTextCtrl::onPreRender()

View file

@ -46,17 +46,17 @@ ConsoleDocClass( GuiTextEditCtrl,
"@tsexample\n" "@tsexample\n"
" new GuiTextEditCtrl(MessageHud_Edit)\n" " new GuiTextEditCtrl(MessageHud_Edit)\n"
" {\n" " {\n"
" text = \"Hello World\";\n" " text = \"Hello World\";\n"
" validate = \"validateCommand();\"\n" " validate = \"validateCommand();\"\n"
" escapeCommand = \"escapeCommand();\";\n" " escapeCommand = \"escapeCommand();\";\n"
" historySize = \"5\";\n" " historySize = \"5\";\n"
" tabComplete = \"true\";\n" " tabComplete = \"true\";\n"
" deniedSound = \"DeniedSoundProfile\";\n" " deniedSound = \"DeniedSoundProfile\";\n"
" sinkAllKeyEvents = \"true\";\n" " sinkAllKeyEvents = \"true\";\n"
" password = \"true\";\n" " password = \"true\";\n"
" passwordMask = \"*\";\n" " passwordMask = \"*\";\n"
" //Properties not specific to this control have been omitted from this example.\n" " //Properties not specific to this control have been omitted from this example.\n"
" };\n" " };\n"
"@endtsexample\n\n" "@endtsexample\n\n"
@ -72,9 +72,9 @@ IMPLEMENT_CALLBACK( GuiTextEditCtrl, onTabComplete, void, (const char* val),( va
"@tsexample\n" "@tsexample\n"
"// Tab key has been pressed, causing the callback to occur.\n" "// Tab key has been pressed, causing the callback to occur.\n"
"GuiTextEditCtrl::onTabComplete(%this,%val)\n" "GuiTextEditCtrl::onTabComplete(%this,%val)\n"
" {\n" " {\n"
" //Code to run when the onTabComplete callback occurs\n" " //Code to run when the onTabComplete callback occurs\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiTextCtrl\n" "@see GuiTextCtrl\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
@ -85,9 +85,9 @@ IMPLEMENT_CALLBACK( GuiTextEditCtrl, onReturn, void, (),(),
"@tsexample\n" "@tsexample\n"
"// Return or Enter key was pressed, causing the callback to occur.\n" "// Return or Enter key was pressed, causing the callback to occur.\n"
"GuiTextEditCtrl::onReturn(%this)\n" "GuiTextEditCtrl::onReturn(%this)\n"
" {\n" " {\n"
" // Code to run when the onReturn callback occurs\n" " // Code to run when the onReturn callback occurs\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiTextCtrl\n" "@see GuiTextCtrl\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
@ -98,9 +98,9 @@ IMPLEMENT_CALLBACK( GuiTextEditCtrl, onValidate, void, (),(),
"@tsexample\n" "@tsexample\n"
"// The control gets validated, causing the callback to occur\n" "// The control gets validated, causing the callback to occur\n"
"GuiTextEditCtrl::onValidated(%this)\n" "GuiTextEditCtrl::onValidated(%this)\n"
" {\n" " {\n"
" // Code to run when the control is validated\n" " // Code to run when the control is validated\n"
" }\n" " }\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@see GuiTextCtrl\n" "@see GuiTextCtrl\n"
"@see GuiControl\n\n" "@see GuiControl\n\n"
@ -139,7 +139,7 @@ GuiTextEditCtrl::GuiTextEditCtrl()
mHistoryBuf = NULL; mHistoryBuf = NULL;
#if defined(__MACOSX__) #if defined(__MACOSX__)
UTF8 bullet[4] = { 0xE2, 0x80, 0xA2, 0 }; UTF8 bullet[4] = { 0xE2, 0x80, 0xA2, 0 };
mPasswordMask = StringTable->insert( bullet ); mPasswordMask = StringTable->insert( bullet );
#else #else
@ -710,10 +710,10 @@ bool GuiTextEditCtrl::onKeyDown(const GuiEvent &event)
case KEY_TAB: case KEY_TAB:
if ( mTabComplete ) if ( mTabComplete )
{ {
onTabComplete_callback("1"); onTabComplete_callback("1");
return true; return true;
} }
break; // We don't want to fall through if we don't handle the TAB here. break; // We don't want to fall through if we don't handle the TAB here.
case KEY_HOME: case KEY_HOME:
mBlockStart = 0; mBlockStart = 0;
@ -779,10 +779,10 @@ bool GuiTextEditCtrl::onKeyDown(const GuiEvent &event)
} }
return true; return true;
case KEY_RETURN: case KEY_RETURN:
case KEY_NUMPADENTER: case KEY_NUMPADENTER:
return dealWithEnter(false); return dealWithEnter(false);
default: default:
break; break;
@ -998,7 +998,7 @@ bool GuiTextEditCtrl::onKeyDown(const GuiEvent &event)
case KEY_RETURN: case KEY_RETURN:
case KEY_NUMPADENTER: case KEY_NUMPADENTER:
return dealWithEnter(true); return dealWithEnter(true);
case KEY_UP: case KEY_UP:
{ {
@ -1155,7 +1155,7 @@ dealWithBackspace:
case KEY_TAB: case KEY_TAB:
if ( mTabComplete ) if ( mTabComplete )
{ {
onTabComplete_callback("0"); onTabComplete_callback("0");
return( true ); return( true );
} }
case KEY_UP: case KEY_UP:
@ -1208,9 +1208,9 @@ bool GuiTextEditCtrl::dealWithEnter( bool clearResponder )
return true; return true;
} }
} }
if( clearResponder ) if( clearResponder )
clearFirstResponder(); clearFirstResponder();
return true; return true;
} }
@ -1222,13 +1222,13 @@ void GuiTextEditCtrl::setFirstResponder()
GuiCanvas *root = getRoot(); GuiCanvas *root = getRoot();
if (root != NULL) if (root != NULL)
{ {
root->enableKeyboardTranslation(); root->enableKeyboardTranslation();
// If the native OS accelerator keys are not disabled // If the native OS accelerator keys are not disabled
// then some key events like Delete, ctrl+V, etc may // then some key events like Delete, ctrl+V, etc may
// not make it down to us. // not make it down to us.
root->setNativeAcceleratorsEnabled( false ); root->setNativeAcceleratorsEnabled( false );
} }
} }
@ -1237,8 +1237,8 @@ void GuiTextEditCtrl::onLoseFirstResponder()
GuiCanvas *root = getRoot(); GuiCanvas *root = getRoot();
if( root ) if( root )
{ {
root->setNativeAcceleratorsEnabled( true ); root->setNativeAcceleratorsEnabled( true );
root->disableKeyboardTranslation(); root->disableKeyboardTranslation();
} }
//execute the validate command //execute the validate command
@ -1546,29 +1546,29 @@ void GuiTextEditCtrl::handleCharInput( U16 ascii )
//see if it's a number field //see if it's a number field
if ( mProfile->mNumbersOnly ) if ( mProfile->mNumbersOnly )
{ {
if (ascii == '-') if (ascii == '-')
{ {
//a minus sign only exists at the beginning, and only a single minus sign //a minus sign only exists at the beginning, and only a single minus sign
if (mCursorPos != 0 && !isAllTextSelected()) if (mCursorPos != 0 && !isAllTextSelected())
{ {
invalidText(); invalidText();
return; return;
} }
if (mInsertOn && (mTextBuffer.getChar(0) == '-')) if (mInsertOn && (mTextBuffer.getChar(0) == '-'))
{ {
invalidText(); invalidText();
return; return;
} }
} }
// BJTODO: This is probably not unicode safe. // BJTODO: This is probably not unicode safe.
else if (ascii != '.' && (ascii < '0' || ascii > '9')) else if (ascii != '.' && (ascii < '0' || ascii > '9'))
{ {
invalidText(); invalidText();
return; return;
} }
else else
validText(); validText();
} }
//save the current state //save the current state
@ -1684,7 +1684,7 @@ DefineEngineMethod( GuiTextEditCtrl, getText, const char*, (),,
"@see GuiControl") "@see GuiControl")
{ {
if( !object->hasText() ) if( !object->hasText() )
return StringTable->insert(""); return StringTable->EmptyString();
char *retBuffer = Con::getReturnBuffer( GuiTextEditCtrl::MAX_STRING_LENGTH ); char *retBuffer = Con::getReturnBuffer( GuiTextEditCtrl::MAX_STRING_LENGTH );
object->getText( retBuffer ); object->getText( retBuffer );
@ -1778,22 +1778,22 @@ DefineEngineMethod( GuiTextEditCtrl, forceValidateText, void, (),,
} }
DefineEngineMethod(GuiTextEditCtrl, invalidText, void, (bool playSound), (true), DefineEngineMethod(GuiTextEditCtrl, invalidText, void, (bool playSound), (true),
"@brief Trigger the invalid sound and make the box red.nn" "@brief Trigger the invalid sound and make the box red.nn"
"@param playSound Play the invalid text sound or not.n") "@param playSound Play the invalid text sound or not.n")
{ {
object->invalidText(playSound); object->invalidText(playSound);
} }
DefineEngineMethod(GuiTextEditCtrl, validText, void, (), , DefineEngineMethod(GuiTextEditCtrl, validText, void, (), ,
"@brief Restores the box to normal color.nn") "@brief Restores the box to normal color.nn")
{ {
object->validText(); object->validText();
} }
DefineEngineMethod(GuiTextEditCtrl, isValidText, bool, (), , DefineEngineMethod(GuiTextEditCtrl, isValidText, bool, (), ,
"@brief Returns if the text is set to valid or not.n" "@brief Returns if the text is set to valid or not.n"
"@Return true if text is set to valid, false if not.nn") "@Return true if text is set to valid, false if not.nn")
{ {
return object->isValidText(); return object->isValidText();
} }

View file

@ -43,9 +43,9 @@
IMPLEMENT_CONOBJECT(GuiTreeViewCtrl); IMPLEMENT_CONOBJECT(GuiTreeViewCtrl);
ConsoleDocClass( GuiTreeViewCtrl, ConsoleDocClass( GuiTreeViewCtrl,
"@brief Hierarchical list of text items with optional icons.\n\n" "@brief Hierarchical list of text items with optional icons.\n\n"
"Can also be used to inspect SimObject hierarchies, primarily within editors.\n\n" "Can also be used to inspect SimObject hierarchies, primarily within editors.\n\n"
"GuiTreeViewCtrls can either display arbitrary user-defined trees or can be used to display SimObject hierarchies where " "GuiTreeViewCtrls can either display arbitrary user-defined trees or can be used to display SimObject hierarchies where "
"each parent node in the tree is a SimSet or SimGroup and each leaf node is a SimObject.\n\n" "each parent node in the tree is a SimSet or SimGroup and each leaf node is a SimObject.\n\n"
@ -59,30 +59,30 @@ ConsoleDocClass( GuiTreeViewCtrl,
"Each item in the tree has a distinct numeric ID that is unique within its tree. The ID of the root item, which is always " "Each item in the tree has a distinct numeric ID that is unique within its tree. The ID of the root item, which is always "
"present on a tree, is 0.\n\n" "present on a tree, is 0.\n\n"
"@tsexample\n" "@tsexample\n"
"new GuiTreeViewCtrl(DatablockEditorTree)\n" "new GuiTreeViewCtrl(DatablockEditorTree)\n"
"{\n" "{\n"
" tabSize = \"16\";\n" " tabSize = \"16\";\n"
" textOffset = \"2\";\n" " textOffset = \"2\";\n"
" fullRowSelect = \"0\";\n" " fullRowSelect = \"0\";\n"
" itemHeight = \"21\";\n" " itemHeight = \"21\";\n"
" destroyTreeOnSleep = \"0\";\n" " destroyTreeOnSleep = \"0\";\n"
" MouseDragging = \"0\";\n" " MouseDragging = \"0\";\n"
" MultipleSelections = \"1\";\n" " MultipleSelections = \"1\";\n"
" DeleteObjectAllowed = \"1\";\n" " DeleteObjectAllowed = \"1\";\n"
" DragToItemAllowed = \"0\";\n" " DragToItemAllowed = \"0\";\n"
" ClearAllOnSingleSelection = \"1\";\n" " ClearAllOnSingleSelection = \"1\";\n"
" showRoot = \"1\";\n" " showRoot = \"1\";\n"
" internalNamesOnly = \"0\";\n" " internalNamesOnly = \"0\";\n"
" objectNamesOnly = \"0\";\n" " objectNamesOnly = \"0\";\n"
" compareToObjectID = \"0\";\n" " compareToObjectID = \"0\";\n"
" Profile = \"GuiTreeViewProfile\";\n" " Profile = \"GuiTreeViewProfile\";\n"
" tooltipprofile = \"GuiToolTipProfile\";\n" " tooltipprofile = \"GuiToolTipProfile\";\n"
" hovertime = \"1000\";\n" " hovertime = \"1000\";\n"
"};\n" "};\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@ingroup GuiContainers\n"); "@ingroup GuiContainers\n");
IMPLEMENT_CALLBACK( GuiTreeViewCtrl, onDeleteObject, bool, ( SimObject* object ), ( object ), "" ); IMPLEMENT_CALLBACK( GuiTreeViewCtrl, onDeleteObject, bool, ( SimObject* object ), ( object ), "" );
IMPLEMENT_CALLBACK( GuiTreeViewCtrl, isValidDragTarget, bool, ( S32 id, const char* value ), ( id, value ), "" ); IMPLEMENT_CALLBACK( GuiTreeViewCtrl, isValidDragTarget, bool, ( S32 id, const char* value ), ( id, value ), "" );
@ -511,7 +511,7 @@ void GuiTreeViewCtrl::Item::getDisplayText(U32 bufLen, char *buf)
if( showInternalNameOnly() ) if( showInternalNameOnly() )
dSprintf( buf, bufLen, "%s", hasInternalName ? pInternalName : "(none)" ); dSprintf( buf, bufLen, "%s", hasInternalName ? pInternalName : "(none)" );
else if( showObjectNameOnly() ) else if( showObjectNameOnly() )
{ {
if( !hasObjectName && mState.test( ShowClassNameForUnnamed ) ) if( !hasObjectName && mState.test( ShowClassNameForUnnamed ) )
dSprintf( buf, bufLen, "%s", pClassName ); dSprintf( buf, bufLen, "%s", pClassName );
@ -801,7 +801,7 @@ GuiTreeViewCtrl::GuiTreeViewCtrl()
mStart = 0; mStart = 0;
mPossibleRenameItem = NULL; mPossibleRenameItem = NULL;
mRenamingItem = NULL; mRenamingItem = NULL;
mTempItem = NULL; mTempItem = NULL;
mRenameCtrl = NULL; mRenameCtrl = NULL;
mDraggedToItem = 0; mDraggedToItem = 0;
@ -845,7 +845,7 @@ GuiTreeViewCtrl::GuiTreeViewCtrl()
mClearAllOnSingleSelection = true; mClearAllOnSingleSelection = true;
mBitmapBase = StringTable->insert(""); mBitmapBase = StringTable->EmptyString();
mTexRollover = NULL; mTexRollover = NULL;
mTexSelected = NULL; mTexSelected = NULL;
@ -1902,7 +1902,7 @@ void GuiTreeViewCtrl::onPreRender()
if(mFlags.test(RebuildVisible)) if(mFlags.test(RebuildVisible))
{ {
buildVisibleTree(); buildVisibleTree();
mFlags.clear(RebuildVisible); mFlags.clear(RebuildVisible);
} }
} }
@ -2084,39 +2084,39 @@ void GuiTreeViewCtrl::syncSelection()
} }
else if (mVisibleItems[i]->isInspectorData()) else if (mVisibleItems[i]->isInspectorData())
{ {
if(mCompareToObjectID) if(mCompareToObjectID)
{ {
if (mVisibleItems[i]->getObject() && mVisibleItems[i]->getObject()->getId() == mSelected[j]) if (mVisibleItems[i]->getObject() && mVisibleItems[i]->getObject()->getId() == mSelected[j])
{ {
// check to see if it is on the visible items list. // check to see if it is on the visible items list.
bool addToSelectedItems = true; bool addToSelectedItems = true;
for (S32 k = 0; k < mSelectedItems.size(); k++) for (S32 k = 0; k < mSelectedItems.size(); k++)
{ {
if (mSelectedItems[k]->isInspectorData() && mSelectedItems[k]->getObject() ) if (mSelectedItems[k]->isInspectorData() && mSelectedItems[k]->getObject() )
{ {
if (mSelected[j] == mSelectedItems[k]->getObject()->getId()) if (mSelected[j] == mSelectedItems[k]->getObject()->getId())
{ {
// don't add it // don't add it
addToSelectedItems = false; addToSelectedItems = false;
} }
} }
else else
{ {
if (mSelected[j] == mSelectedItems[k]->mId) if (mSelected[j] == mSelectedItems[k]->mId)
{ {
// don't add it // don't add it
addToSelectedItems = false; addToSelectedItems = false;
} }
} }
} }
if (addToSelectedItems) if (addToSelectedItems)
{ {
mVisibleItems[i]->mState.set(Item::Selected, true); mVisibleItems[i]->mState.set(Item::Selected, true);
mSelectedItems.push_front(mVisibleItems[i]); mSelectedItems.push_front(mVisibleItems[i]);
break; break;
} }
} }
} }
} }
} }
@ -2200,14 +2200,14 @@ void GuiTreeViewCtrl::addSelection( S32 itemOrObjectId, bool update, bool isLast
} }
const S32 itemId = item->getID(); const S32 itemId = item->getID();
// Ok, we have an item to select which isn't already selected.... // Ok, we have an item to select which isn't already selected....
// Do we want to allow more than one selected item? // Do we want to allow more than one selected item?
if( !mMultipleSelections ) if( !mMultipleSelections )
clearSelection(); clearSelection();
// Add this object id to the vector of selected objectIds // Add this object id to the vector of selected objectIds
// if it is not already. // if it is not already.
bool foundMatch = false; bool foundMatch = false;
for ( S32 i = 0; i < mSelected.size(); i++) for ( S32 i = 0; i < mSelected.size(); i++)
@ -2228,21 +2228,21 @@ void GuiTreeViewCtrl::addSelection( S32 itemOrObjectId, bool update, bool isLast
// Callback Start // Callback Start
// Set and add the selection to the selected items group // Set and add the selection to the selected items group
item->mState.set(Item::Selected, true); item->mState.set(Item::Selected, true);
mSelectedItems.push_front(item); mSelectedItems.push_front(item);
if ( item->isInspectorData() && if ( item->isInspectorData() &&
item->getObject() ) item->getObject() )
{ {
SimObject *obj = item->getObject(); SimObject *obj = item->getObject();
onAddSelection_callback( obj->getId(), isLastSelection ); onAddSelection_callback( obj->getId(), isLastSelection );
} }
else else
{ {
onAddSelection_callback( item->mId, isLastSelection ); onAddSelection_callback( item->mId, isLastSelection );
} }
// Callback end // Callback end
mFlags.set( RebuildVisible ); mFlags.set( RebuildVisible );
if( update ) if( update )
@ -2262,7 +2262,7 @@ void GuiTreeViewCtrl::onItemSelected( Item *item )
if (item->isInspectorData()) if (item->isInspectorData())
{ {
SimObject* object = item->getObject(); SimObject* object = item->getObject();
if( object ) if( object )
onSelect_callback( object->getId() ); onSelect_callback( object->getId() );
if( !item->isParent() && object ) if( !item->isParent() && object )
onInspect_callback( object->getId() ); onInspect_callback( object->getId() );
@ -2590,9 +2590,9 @@ void GuiTreeViewCtrl::deleteSelection()
} }
else else
{ {
Vector<Item*> delSelection; Vector<Item*> delSelection;
delSelection = mSelectedItems; delSelection = mSelectedItems;
mSelectedItems.clear(); mSelectedItems.clear();
while (!delSelection.empty()) while (!delSelection.empty())
{ {
Item * item = delSelection.front(); Item * item = delSelection.front();
@ -2600,7 +2600,7 @@ void GuiTreeViewCtrl::deleteSelection()
if ( item->mParent ) if ( item->mParent )
_deleteItem( item ); _deleteItem( item );
delSelection.pop_front(); delSelection.pop_front();
} }
} }
@ -2642,7 +2642,7 @@ bool GuiTreeViewCtrl::onKeyDown( const GuiEvent& event )
return true; return true;
} }
//call a generic bit of script that will let the subclass know that a key was pressed //call a generic bit of script that will let the subclass know that a key was pressed
onKeyDown_callback( event.modifier, event.keyCode ); onKeyDown_callback( event.modifier, event.keyCode );
} }
@ -3028,29 +3028,29 @@ void GuiTreeViewCtrl::onMouseUp(const GuiEvent &event)
return; return;
} }
BitSet32 hitFlags = 0; BitSet32 hitFlags = 0;
Item *item; Item *item;
bool hitCheck = _hitTest( event.mousePoint, item, hitFlags ); bool hitCheck = _hitTest( event.mousePoint, item, hitFlags );
mRenamingItem = NULL; mRenamingItem = NULL;
if( hitCheck ) if( hitCheck )
{ {
if ( event.mouseClickCount == 1 && !mMouseDragged && mPossibleRenameItem != NULL ) if ( event.mouseClickCount == 1 && !mMouseDragged && mPossibleRenameItem != NULL )
{ {
if ( item == mPossibleRenameItem ) if ( item == mPossibleRenameItem )
showItemRenameCtrl( item ); showItemRenameCtrl( item );
} }
else // If mouseUp occurs on the same item as mouse down else // If mouseUp occurs on the same item as mouse down
{ {
bool wasSelected = isSelected( item ); bool wasSelected = isSelected( item );
bool multiSelect = getSelectedItemsCount() > 1; bool multiSelect = getSelectedItemsCount() > 1;
if( wasSelected && multiSelect && item == mTempItem ) if( wasSelected && multiSelect && item == mTempItem )
{ {
clearSelection(); clearSelection();
addSelection( item->mId ); addSelection( item->mId );
} }
} }
} }
mPossibleRenameItem = NULL; mPossibleRenameItem = NULL;
@ -3482,7 +3482,7 @@ void GuiTreeViewCtrl::onMouseDragged(const GuiEvent &event)
if( mDragStartInSelection ) if( mDragStartInSelection )
onMouseDragged_callback(); onMouseDragged_callback();
if(!mSupportMouseDragging) if(!mSupportMouseDragging)
return; return;
if( !mActive || !mAwake || !mVisible ) if( !mActive || !mAwake || !mVisible )
@ -3652,7 +3652,7 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
mPossibleRenameItem = NULL; mPossibleRenameItem = NULL;
mRenamingItem = NULL; mRenamingItem = NULL;
mTempItem = NULL; mTempItem = NULL;
// //
if( event.modifier & SI_MULTISELECT ) if( event.modifier & SI_MULTISELECT )
@ -3704,10 +3704,10 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
//select up //select up
for (S32 j = (mCurrentDragCell); j < firstSelectedIndex; j++) for (S32 j = (mCurrentDragCell); j < firstSelectedIndex; j++)
{ {
if( j != (firstSelectedIndex - 1) ) if( j != (firstSelectedIndex - 1) )
addSelection(mVisibleItems[j]->mId, false, false); addSelection(mVisibleItems[j]->mId, false, false);
else else
addSelection(mVisibleItems[j]->mId, false); addSelection(mVisibleItems[j]->mId, false);
} }
} }
else else
@ -3715,10 +3715,10 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
// select down // select down
for (S32 j = firstSelectedIndex+1; j < (mCurrentDragCell+1); j++) for (S32 j = firstSelectedIndex+1; j < (mCurrentDragCell+1); j++)
{ {
if( j != mCurrentDragCell ) if( j != mCurrentDragCell )
addSelection(mVisibleItems[j]->mId, false, false); addSelection(mVisibleItems[j]->mId, false, false);
else else
addSelection(mVisibleItems[j]->mId, false); addSelection(mVisibleItems[j]->mId, false);
} }
} }
@ -3736,39 +3736,39 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
} }
else if ( !hitFlags.test(OnImage) ) else if ( !hitFlags.test(OnImage) )
{ {
mTempItem = item; mTempItem = item;
bool wasSelected = isSelected( item ); bool wasSelected = isSelected( item );
bool multiSelect = getSelectedItemsCount() > 1; bool multiSelect = getSelectedItemsCount() > 1;
if( !wasSelected || !multiSelect ) if( !wasSelected || !multiSelect )
{ {
if ( mClearAllOnSingleSelection ) if ( mClearAllOnSingleSelection )
clearSelection(); clearSelection();
if ( !wasSelected || mClearAllOnSingleSelection ) if ( !wasSelected || mClearAllOnSingleSelection )
addSelection( item->mId ); addSelection( item->mId );
if ( wasSelected && if ( wasSelected &&
!multiSelect && !multiSelect &&
mCanRenameObjects && mCanRenameObjects &&
hitFlags.test(OnText) && hitFlags.test(OnText) &&
mFlags.test(IsEditable) && mFlags.test(IsEditable) &&
item->isInspectorData() && item->isInspectorData() &&
item->getObject() && item->getObject() &&
item->getObject()->isNameChangeAllowed() && item->getObject()->isNameChangeAllowed() &&
item != mRoot && item != mRoot &&
event.mouseClickCount == 1 ) event.mouseClickCount == 1 )
{ {
mPossibleRenameItem = item; mPossibleRenameItem = item;
if ( isMethod( "canRenameObject" ) ) if ( isMethod( "canRenameObject" ) )
{ {
if( canRenameObject_callback( item->getObject() ) ) if( canRenameObject_callback( item->getObject() ) )
mPossibleRenameItem = NULL; mPossibleRenameItem = NULL;
} }
} }
} }
} }
@ -4221,7 +4221,7 @@ void GuiTreeViewCtrl::onRenderCell(Point2I offset, Point2I cell, bool, bool )
if( item->mState.test(Item::MouseOverText) ) if( item->mState.test(Item::MouseOverText) )
{ {
fontColor = mProfile->mFontColorHL; fontColor = mProfile->mFontColorHL;
} }
drawer->setBitmapModulation( fontColor ); drawer->setBitmapModulation( fontColor );
@ -4551,9 +4551,9 @@ void GuiTreeViewCtrl::inspectorSearch(Item * item, Item * parent, SimSet * paren
bool GuiTreeViewCtrl::objectSearch( const SimObject *object, Item **item ) bool GuiTreeViewCtrl::objectSearch( const SimObject *object, Item **item )
{ {
for ( U32 i = 0; i < mItems.size(); i++ ) for ( U32 i = 0; i < mItems.size(); i++ )
{ {
Item *pItem = mItems[i]; Item *pItem = mItems[i];
if ( !pItem ) if ( !pItem )
continue; continue;
@ -4565,16 +4565,16 @@ bool GuiTreeViewCtrl::objectSearch( const SimObject *object, Item **item )
continue; continue;
#endif #endif
SimObject *pObj = pItem->getObject(); SimObject *pObj = pItem->getObject();
if ( pObj && pObj == object ) if ( pObj && pObj == object )
{ {
*item = pItem; *item = pItem;
return true; return true;
} }
} }
return false; return false;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -4592,7 +4592,7 @@ bool GuiTreeViewCtrl::onVirtualParentBuild(Item *item, bool bForceFullUpdate)
} }
// Skip the next stuff unless we're expanded... // Skip the next stuff unless we're expanded...
if(!item->isExpanded() && !bForceFullUpdate && !( item == mRoot && !mShowRoot ) ) if(!item->isExpanded() && !bForceFullUpdate && !( item == mRoot && !mShowRoot ) )
return true; return true;
// Verify that we have all the kids we should in here... // Verify that we have all the kids we should in here...
@ -4704,8 +4704,8 @@ S32 GuiTreeViewCtrl::findItemByName(const char *name)
{ {
if ( !mItems[i] ) if ( !mItems[i] )
continue; continue;
if( mItems[i]->mState.test( Item::InspectorData ) ) if( mItems[i]->mState.test( Item::InspectorData ) )
continue; continue;
if (mItems[i] && dStrcmp(mItems[i]->getText(),name) == 0) if (mItems[i] && dStrcmp(mItems[i]->getText(),name) == 0)
return mItems[i]->mId; return mItems[i]->mId;
} }
@ -4721,10 +4721,10 @@ S32 GuiTreeViewCtrl::findItemByValue(const char *name)
{ {
if (!mItems[i]) if (!mItems[i])
continue; continue;
if( mItems[i]->mState.test( Item::InspectorData ) ) if( mItems[i]->mState.test( Item::InspectorData ) )
continue; continue;
if (mItems[i] && dStrcmp(mItems[i]->getValue(),name) == 0) if (mItems[i] && dStrcmp(mItems[i]->getValue(),name) == 0)
return mItems[i]->mId; return mItems[i]->mId;
} }
return 0; return 0;
@ -4746,13 +4746,13 @@ StringTableEntry GuiTreeViewCtrl::getTextToRoot( S32 itemId, const char * delimi
if(!item) if(!item)
{ {
Con::errorf(ConsoleLogEntry::General, "GuiTreeViewCtrl::getTextToRoot: invalid start item id!"); Con::errorf(ConsoleLogEntry::General, "GuiTreeViewCtrl::getTextToRoot: invalid start item id!");
return StringTable->insert(""); return StringTable->EmptyString();
} }
if(item->isInspectorData()) if(item->isInspectorData())
{ {
Con::errorf(ConsoleLogEntry::General, "GuiTreeViewCtrl::getTextToRoot: cannot get text to root of inspector data items"); Con::errorf(ConsoleLogEntry::General, "GuiTreeViewCtrl::getTextToRoot: cannot get text to root of inspector data items");
return StringTable->insert(""); return StringTable->EmptyString();
} }
char bufferOne[1024]; char bufferOne[1024];
@ -4874,7 +4874,7 @@ DefineEngineMethod( GuiTreeViewCtrl, insertItem, S32, ( S32 parentId, const char
DefineEngineMethod( GuiTreeViewCtrl, insertObject, S32, ( S32 parentId, SimObject* obj, bool OKToEdit ), (false), "Inserts object as a child to the given parent." ) DefineEngineMethod( GuiTreeViewCtrl, insertObject, S32, ( S32 parentId, SimObject* obj, bool OKToEdit ), (false), "Inserts object as a child to the given parent." )
{ {
return object->insertObject(parentId, obj, OKToEdit); return object->insertObject(parentId, obj, OKToEdit);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -4967,10 +4967,10 @@ DefineEngineMethod( GuiTreeViewCtrl, removeChildSelectionByValue, void, ( S32 pa
if(parentItem) if(parentItem)
{ {
GuiTreeViewCtrl::Item* child = parentItem->findChildByValue(value); GuiTreeViewCtrl::Item* child = parentItem->findChildByValue(value);
if(child) if(child)
{ {
object->removeSelection(child->getID()); object->removeSelection(child->getID());
} }
} }
} }
@ -5038,7 +5038,7 @@ DefineEngineMethod( GuiTreeViewCtrl, open, void, ( const char * objName, bool ok
DefineEngineMethod( GuiTreeViewCtrl, setItemTooltip, bool, ( S32 itemId, const char* tooltip), , DefineEngineMethod( GuiTreeViewCtrl, setItemTooltip, bool, ( S32 itemId, const char* tooltip), ,
"Set the tooltip to show for the given item.\n\n" "Set the tooltip to show for the given item.\n\n"
"@param itemId TreeItemID of item to set the tooltip for.\n" "@param itemId TreeItemID of item to set the tooltip for.\n"
"@param tooltip String tooltip to set for the item." "@param tooltip String tooltip to set for the item."
"@return True if successfully found the item, false if not") "@return True if successfully found the item, false if not")
{ {
GuiTreeViewCtrl::Item* item = object->getItem( itemId ); GuiTreeViewCtrl::Item* item = object->getItem( itemId );
@ -5228,11 +5228,11 @@ const char* GuiTreeViewCtrl::getSelectedObjectList()
{ {
S32 id = item->getObject()->getId(); S32 id = item->getObject()->getId();
//get the current length of the buffer //get the current length of the buffer
U32 len = dStrlen(buff); U32 len = dStrlen(buff);
//the start of the buffer where we want to write //the start of the buffer where we want to write
char* buffPart = buff+len; char* buffPart = buff+len;
//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0) //the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
S32 size = bufSize-len-1; S32 size = bufSize-len-1;
//write it: //write it:
if(size < 1) if(size < 1)
{ {
@ -5283,7 +5283,7 @@ DefineEngineMethod( GuiTreeViewCtrl, getTextToRoot, const char*, (S32 itemId, co
"@param delimiter (Optional) delimiter to use between each branch concatenation." "@param delimiter (Optional) delimiter to use between each branch concatenation."
"@return text from the current node to the root.") "@return text from the current node to the root.")
{ {
if (!dStrcmp(delimiter, "" )) if (!dStrcmp(delimiter, "" ))
{ {
Con::warnf("GuiTreeViewCtrl::getTextToRoot - Invalid number of arguments!"); Con::warnf("GuiTreeViewCtrl::getTextToRoot - Invalid number of arguments!");
return (""); return ("");
@ -5296,31 +5296,31 @@ DefineEngineMethod( GuiTreeViewCtrl, getSelectedItemList, const char*, (), ,
"@return space separated list of selected item ids.") "@return space separated list of selected item ids.")
{ {
const U32 bufSize = 1024; const U32 bufSize = 1024;
char* buff = Con::getReturnBuffer(bufSize); char* buff = Con::getReturnBuffer(bufSize);
dSprintf(buff, bufSize, ""); dSprintf(buff, bufSize, "");
const Vector< S32 >& selected = object->getSelected(); const Vector< S32 >& selected = object->getSelected();
for(int i = 0; i < selected.size(); i++) for(int i = 0; i < selected.size(); i++)
{ {
S32 id = selected[i]; S32 id = selected[i];
//get the current length of the buffer //get the current length of the buffer
U32 len = dStrlen(buff); U32 len = dStrlen(buff);
//the start of the buffer where we want to write //the start of the buffer where we want to write
char* buffPart = buff+len; char* buffPart = buff+len;
//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0) //the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
S32 size = bufSize-len-1; S32 size = bufSize-len-1;
//write it: //write it:
if(size < 1) if(size < 1)
{ {
Con::errorf("GuiTreeViewCtrl::getSelectedItemList - Not enough room to return our object list"); Con::errorf("GuiTreeViewCtrl::getSelectedItemList - Not enough room to return our object list");
return buff; return buff;
} }
dSprintf(buffPart,size,"%d ", id); dSprintf(buffPart,size,"%d ", id);
} }
//mSelected //mSelected
return buff; return buff;
} }
S32 GuiTreeViewCtrl::findItemByObjectId(S32 iObjId) S32 GuiTreeViewCtrl::findItemByObjectId(S32 iObjId)
@ -5331,8 +5331,8 @@ S32 GuiTreeViewCtrl::findItemByObjectId(S32 iObjId)
continue; continue;
SimObject* pObj = mItems[i]->getObject(); SimObject* pObj = mItems[i]->getObject();
if( pObj && pObj->getId() == iObjId ) if( pObj && pObj->getId() == iObjId )
return mItems[i]->mId; return mItems[i]->mId;
} }
return -1; return -1;
@ -5341,7 +5341,7 @@ S32 GuiTreeViewCtrl::findItemByObjectId(S32 iObjId)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
DefineEngineMethod( GuiTreeViewCtrl, findItemByObjectId, S32, (S32 objectId), , DefineEngineMethod( GuiTreeViewCtrl, findItemByObjectId, S32, (S32 objectId), ,
"Find an item by its object id and returns the Tree Item ID for it.\n\n" "Find an item by its object id and returns the Tree Item ID for it.\n\n"
"@param objectId Object id you want the item id for." "@param objectId Object id you want the item id for."
"@return Tree Item Id for the given object ID.") "@return Tree Item Id for the given object ID.")
{ {
return(object->findItemByObjectId(objectId)); return(object->findItemByObjectId(objectId));
@ -5389,7 +5389,7 @@ bool GuiTreeViewCtrl::scrollVisibleByObjectId(S32 objID)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
DefineEngineMethod( GuiTreeViewCtrl, scrollVisibleByObjectId, S32, (S32 objectId), , DefineEngineMethod( GuiTreeViewCtrl, scrollVisibleByObjectId, S32, (S32 objectId), ,
"Show item by object id.\n\n" "Show item by object id.\n\n"
"@param objectId Object id you want to scroll to." "@param objectId Object id you want to scroll to."
"@return True if successful, false if not.") "@return True if successful, false if not.")
{ {
return(object->scrollVisibleByObjectId(objectId)); return(object->scrollVisibleByObjectId(objectId));
@ -5400,7 +5400,7 @@ DefineEngineMethod( GuiTreeViewCtrl, scrollVisibleByObjectId, S32, (S32 objectId
//FIXME: this clashes with SimSet.sort() //FIXME: this clashes with SimSet.sort()
DefineEngineMethod( GuiTreeViewCtrl, sort, void, (S32 parentId, bool traverseHierarchy, bool parentsFirst, bool caseSensitive), (0, false, false, true), DefineEngineMethod( GuiTreeViewCtrl, sort, void, (S32 parentId, bool traverseHierarchy, bool parentsFirst, bool caseSensitive), (0, false, false, true),
"Sorts all items of the given parent (or root). With 'hierarchy', traverses hierarchy." "Sorts all items of the given parent (or root). With 'hierarchy', traverses hierarchy."
"@param parentId TreeItemID of parent/root to sort all the items under. Use 0 to sort the entire tree." "@param parentId TreeItemID of parent/root to sort all the items under. Use 0 to sort the entire tree."
"@param traverseHierarchy True to traverse the hierarchy, false to not." "@param traverseHierarchy True to traverse the hierarchy, false to not."
"@param parentsFirst True to sort the parents first." "@param parentsFirst True to sort the parents first."
"@param caseSensitive True to pay attention to case, false to ignore it.") "@param caseSensitive True to pay attention to case, false to ignore it.")
@ -5531,7 +5531,7 @@ DefineEngineMethod( GuiTreeViewCtrl, isItemSelected, bool, ( S32 id ),,
"@return True if the given item/object is currently selected in the tree." ) "@return True if the given item/object is currently selected in the tree." )
{ {
const Vector< GuiTreeViewCtrl::Item* >& selectedItems = object->getSelectedItems(); const Vector< GuiTreeViewCtrl::Item* >& selectedItems = object->getSelectedItems();
for( S32 i = 0; i < selectedItems.size(); ++ i ) for( S32 i = 0; i < selectedItems.size(); ++ i )
if( selectedItems[ i ]->mId == id ) if( selectedItems[ i ]->mId == id )
return true; return true;

File diff suppressed because it is too large Load diff

View file

@ -65,10 +65,10 @@ ConsoleDocClass( GuiChunkedBitmapCtrl,
void GuiChunkedBitmapCtrl::initPersistFields() void GuiChunkedBitmapCtrl::initPersistFields()
{ {
addGroup("GuiChunkedBitmapCtrl"); addGroup("GuiChunkedBitmapCtrl");
addField( "bitmap", TypeFilename, Offset( mBitmapName, GuiChunkedBitmapCtrl ), "This is the bitmap to render to the control." ); addField( "bitmap", TypeFilename, Offset( mBitmapName, GuiChunkedBitmapCtrl ), "This is the bitmap to render to the control." );
addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file " addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file "
"or a bitmap stored in \"variable\""); "or a bitmap stored in \"variable\"");
addField( "tile", TypeBool, Offset( mTile, GuiChunkedBitmapCtrl ), "This is no longer in use"); addField( "tile", TypeBool, Offset( mTile, GuiChunkedBitmapCtrl ), "This is no longer in use");
endGroup("GuiChunkedBitmapCtrl"); endGroup("GuiChunkedBitmapCtrl");
Parent::initPersistFields(); Parent::initPersistFields();
@ -86,7 +86,7 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl() GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
{ {
mBitmapName = StringTable->insert(""); mBitmapName = StringTable->EmptyString();
mUseVariable = false; mUseVariable = false;
mTile = false; mTile = false;
} }

View file

@ -32,9 +32,9 @@
IMPLEMENT_CONOBJECT( MECreateUndoAction ); IMPLEMENT_CONOBJECT( MECreateUndoAction );
ConsoleDocClass( MECreateUndoAction, ConsoleDocClass( MECreateUndoAction,
"@brief Material Editor create undo instance\n\n" "@brief Material Editor create undo instance\n\n"
"Not intended for game development, for editors or internal use only.\n\n " "Not intended for game development, for editors or internal use only.\n\n "
"@internal"); "@internal");
MECreateUndoAction::MECreateUndoAction( const UTF8* actionName ) MECreateUndoAction::MECreateUndoAction( const UTF8* actionName )
: UndoAction( actionName ) : UndoAction( actionName )
@ -62,7 +62,7 @@ DefineEngineMethod( MECreateUndoAction, addObject, void, ( SimObject* obj),,
"Add the object being created to an undo action.\n" "Add the object being created to an undo action.\n"
"@param obj Object being created you want to create the undo for.") "@param obj Object being created you want to create the undo for.")
{ {
if (obj) if (obj)
object->addObject( obj ); object->addObject( obj );
} }
@ -117,9 +117,9 @@ void MECreateUndoAction::redo()
IMPLEMENT_CONOBJECT( MEDeleteUndoAction ); IMPLEMENT_CONOBJECT( MEDeleteUndoAction );
ConsoleDocClass( MEDeleteUndoAction, ConsoleDocClass( MEDeleteUndoAction,
"@brief Material Editor delete undo instance\n\n" "@brief Material Editor delete undo instance\n\n"
"Not intended for game development, for editors or internal use only.\n\n " "Not intended for game development, for editors or internal use only.\n\n "
"@internal"); "@internal");
MEDeleteUndoAction::MEDeleteUndoAction( const UTF8 *actionName ) MEDeleteUndoAction::MEDeleteUndoAction( const UTF8 *actionName )
: UndoAction( actionName ) : UndoAction( actionName )
@ -169,7 +169,7 @@ DefineEngineMethod( MEDeleteUndoAction, deleteObject, void, ( SimObject* obj),,
"Delete the object and add it to the undo action.\n" "Delete the object and add it to the undo action.\n"
"@param obj Object to delete and add to the undo action.") "@param obj Object to delete and add to the undo action.")
{ {
if (obj) if (obj)
object->deleteObject( obj ); object->deleteObject( obj );
} }
@ -210,16 +210,16 @@ void MEDeleteUndoAction::redo()
IMPLEMENT_CONOBJECT( InspectorFieldUndoAction ); IMPLEMENT_CONOBJECT( InspectorFieldUndoAction );
ConsoleDocClass( InspectorFieldUndoAction, ConsoleDocClass( InspectorFieldUndoAction,
"@brief Inspector Field undo action instance\n\n" "@brief Inspector Field undo action instance\n\n"
"Not intended for game development, for editors or internal use only.\n\n " "Not intended for game development, for editors or internal use only.\n\n "
"@internal"); "@internal");
InspectorFieldUndoAction::InspectorFieldUndoAction() InspectorFieldUndoAction::InspectorFieldUndoAction()
{ {
mObjId = 0; mObjId = 0;
mField = NULL; mField = NULL;
mSlotName = StringTable->insert(""); mSlotName = StringTable->EmptyString();
mArrayIdx = StringTable->insert(""); mArrayIdx = StringTable->EmptyString();
} }
InspectorFieldUndoAction::InspectorFieldUndoAction( const UTF8 *actionName ) InspectorFieldUndoAction::InspectorFieldUndoAction( const UTF8 *actionName )
@ -228,8 +228,8 @@ InspectorFieldUndoAction::InspectorFieldUndoAction( const UTF8 *actionName )
mInspector = NULL; mInspector = NULL;
mObjId = 0; mObjId = 0;
mField = NULL; mField = NULL;
mSlotName = StringTable->insert(""); mSlotName = StringTable->EmptyString();
mArrayIdx = StringTable->insert(""); mArrayIdx = StringTable->EmptyString();
} }
void InspectorFieldUndoAction::initPersistFields() void InspectorFieldUndoAction::initPersistFields()
@ -272,4 +272,4 @@ void InspectorFieldUndoAction::undo()
// Now save the previous data in this UndoAction // Now save the previous data in this UndoAction
// since an undo action must become a redo action and vice-versa // since an undo action must become a redo action and vice-versa
mData = data; mData = data;
} }

View file

@ -181,7 +181,7 @@ DefineConsoleFunction(NavMeshUpdateOne, void, (S32 meshid, S32 objid, bool remov
NavMesh::NavMesh() NavMesh::NavMesh()
{ {
mTypeMask |= StaticShapeObjectType | MarkerObjectType; mTypeMask |= StaticShapeObjectType | MarkerObjectType;
mFileName = StringTable->insert(""); mFileName = StringTable->EmptyString();
mNetFlags.clear(Ghostable); mNetFlags.clear(Ghostable);
mSaveIntermediates = false; mSaveIntermediates = false;
@ -211,7 +211,7 @@ NavMesh::NavMesh()
mLargeCharacters = false; mLargeCharacters = false;
mVehicles = false; mVehicles = false;
mCoverSet = StringTable->insert(""); mCoverSet = StringTable->EmptyString();
mInnerCover = false; mInnerCover = false;
mCoverDist = 1.0f; mCoverDist = 1.0f;
mPeekDist = 0.7f; mPeekDist = 0.7f;
@ -1143,10 +1143,10 @@ void NavMesh::buildLinks()
// Iterate over links // Iterate over links
for(U32 j = 0; j < mLinkIDs.size(); j++) for(U32 j = 0; j < mLinkIDs.size(); j++)
{ {
if (mLinksUnsynced[j]) if (mLinksUnsynced[j])
{ {
if(tile.box.isContained(getLinkStart(j)) || if(tile.box.isContained(getLinkStart(j)) ||
tile.box.isContained(getLinkEnd(j))) tile.box.isContained(getLinkEnd(j)))
{ {
// Mark tile for build. // Mark tile for build.
mDirtyTiles.push_back_unique(i); mDirtyTiles.push_back_unique(i);
@ -1161,7 +1161,7 @@ void NavMesh::buildLinks()
} }
} }
} }
} }
if(mDirtyTiles.size()) if(mDirtyTiles.size())
ctx->startTimer(RC_TIMER_TOTAL); ctx->startTimer(RC_TIMER_TOTAL);
} }

View file

@ -170,7 +170,7 @@ const char *NavPath::getProtectedFrom(void *obj, const char *data)
if(object->mFromSet) if(object->mFromSet)
return data; return data;
else else
return StringTable->insert(""); return StringTable->EmptyString();
} }
const char *NavPath::getProtectedTo(void *obj, const char *data) const char *NavPath::getProtectedTo(void *obj, const char *data)
@ -180,7 +180,7 @@ const char *NavPath::getProtectedTo(void *obj, const char *data)
if(object->mToSet) if(object->mToSet)
return data; return data;
else else
return StringTable->insert(""); return StringTable->EmptyString();
} }
IRangeValidator ValidIterations(1, S32_MAX); IRangeValidator ValidIterations(1, S32_MAX);

View file

@ -51,10 +51,10 @@ PopupMenu::PopupMenu() : mCanvas(NULL)
mSubmenus = new SimSet; mSubmenus = new SimSet;
mSubmenus->registerObject(); mSubmenus->registerObject();
mBarTitle = StringTable->insert(""); mBarTitle = StringTable->EmptyString();
mIsPopup = false; mIsPopup = false;
mPopupGUID = sMaxPopupGUID++; mPopupGUID = sMaxPopupGUID++;
} }
PopupMenu::~PopupMenu() PopupMenu::~PopupMenu()
@ -126,10 +126,10 @@ void PopupMenu::onMenuSelect()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PopupMenu::handleSelectEvent(U32 popID, U32 command) void PopupMenu::handleSelectEvent(U32 popID, U32 command)
{ {
if (popID == mPopupGUID && canHandleID(command)) if (popID == mPopupGUID && canHandleID(command))
if (handleSelect(command)) if (handleSelect(command))
smSelectionEventHandled = true; smSelectionEventHandled = true;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -138,8 +138,8 @@ void PopupMenu::onAttachToMenuBar(GuiCanvas *canvas, S32 pos, const char *title)
{ {
mCanvas = canvas; mCanvas = canvas;
// Attached menus must be notified of menu events // Attached menus must be notified of menu events
smPopupMenuEvent.notify(this, &PopupMenu::handleSelectEvent); smPopupMenuEvent.notify(this, &PopupMenu::handleSelectEvent);
// Pass on to sub menus // Pass on to sub menus
for(SimSet::iterator i = mSubmenus->begin();i != mSubmenus->end();++i) for(SimSet::iterator i = mSubmenus->begin();i != mSubmenus->end();++i)
@ -160,8 +160,8 @@ void PopupMenu::onRemoveFromMenuBar(GuiCanvas *canvas)
{ {
mCanvas = NULL; mCanvas = NULL;
// We are no longer interested in select events, remove ourselves from the notification list in a safe way // We are no longer interested in select events, remove ourselves from the notification list in a safe way
Sim::postCurrentEvent(this, new PopUpNotifyRemoveEvent()); Sim::postCurrentEvent(this, new PopUpNotifyRemoveEvent());
// Pass on to sub menus // Pass on to sub menus
for(SimSet::iterator i = mSubmenus->begin();i != mSubmenus->end();++i) for(SimSet::iterator i = mSubmenus->begin();i != mSubmenus->end();++i)

View file

@ -48,10 +48,10 @@ FileDialogData::FileDialogData()
if (mDefaultPath == StringTable->lookup("") || !Platform::isDirectory(mDefaultPath)) if (mDefaultPath == StringTable->lookup("") || !Platform::isDirectory(mDefaultPath))
mDefaultPath = Platform::getCurrentDirectory(); mDefaultPath = Platform::getCurrentDirectory();
mDefaultFile = StringTable->insert(""); mDefaultFile = StringTable->EmptyString();
mFilters = StringTable->insert(""); mFilters = StringTable->EmptyString();
mFile = StringTable->insert(""); mFile = StringTable->EmptyString();
mTitle = StringTable->insert(""); mTitle = StringTable->EmptyString();
mStyle = 0; mStyle = 0;

View file

@ -724,37 +724,37 @@ DefineEngineFunction( profilerMarkerEnable, void, ( const char* markerName, bool
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineFunction( profilerEnable, void, ( bool enable ),, DefineEngineFunction( profilerEnable, void, ( bool enable ),,
"@brief Enables or disables the profiler.\n\n" "@brief Enables or disables the profiler.\n\n"
"Data is only gathered while the profiler is enabled.\n\n" "Data is only gathered while the profiler is enabled.\n\n"
"@note Profiler is not available in shipping builds.\n" "@note Profiler is not available in shipping builds.\n"
"T3D has predefined profiling areas surrounded by markers, " "T3D has predefined profiling areas surrounded by markers, "
"but you may need to define additional markers (in C++) around areas you wish to profile," "but you may need to define additional markers (in C++) around areas you wish to profile,"
" by using the PROFILE_START( markerName ); and PROFILE_END(); macros.\n\n" " by using the PROFILE_START( markerName ); and PROFILE_END(); macros.\n\n"
"@ingroup Debugging\n" ) "@ingroup Debugging\n" )
{ {
if(gProfiler) if(gProfiler)
gProfiler->enable(enable); gProfiler->enable(enable);
} }
DefineEngineFunction(profilerDump, void, (),, DefineEngineFunction(profilerDump, void, (),,
"@brief Dumps current profiling stats to the console window.\n\n" "@brief Dumps current profiling stats to the console window.\n\n"
"@note Markers disabled with profilerMarkerEnable() will be skipped over. " "@note Markers disabled with profilerMarkerEnable() will be skipped over. "
"If the profiler is currently running, it will be disabled.\n" "If the profiler is currently running, it will be disabled.\n"
"@ingroup Debugging") "@ingroup Debugging")
{ {
if(gProfiler) if(gProfiler)
gProfiler->dumpToConsole(); gProfiler->dumpToConsole();
} }
DefineEngineFunction( profilerDumpToFile, void, ( const char* fileName ),, DefineEngineFunction( profilerDumpToFile, void, ( const char* fileName ),,
"@brief Dumps current profiling stats to a file.\n\n" "@brief Dumps current profiling stats to a file.\n\n"
"@note If the profiler is currently running, it will be disabled.\n" "@note If the profiler is currently running, it will be disabled.\n"
"@param fileName Name and path of file to save profiling stats to. Must use forward slashes (/). " "@param fileName Name and path of file to save profiling stats to. Must use forward slashes (/). "
"Will attempt to create the file if it does not already exist.\n" "Will attempt to create the file if it does not already exist.\n"
"@tsexample\n" "@tsexample\n"
"profilerDumpToFile( \"C:/Torque/log1.txt\" );\n" "profilerDumpToFile( \"C:/Torque/log1.txt\" );\n"
"@endtsexample\n\n" "@endtsexample\n\n"
"@ingroup Debugging" ) "@ingroup Debugging" )
{ {
if(gProfiler) if(gProfiler)
gProfiler->dumpToFile(fileName); gProfiler->dumpToFile(fileName);
@ -762,9 +762,9 @@ DefineEngineFunction( profilerDumpToFile, void, ( const char* fileName ),,
DefineEngineFunction( profilerReset, void, (),, DefineEngineFunction( profilerReset, void, (),,
"@brief Resets the profiler, clearing it of all its data.\n\n" "@brief Resets the profiler, clearing it of all its data.\n\n"
"If the profiler is currently running, it will first be disabled. " "If the profiler is currently running, it will first be disabled. "
"All markers will retain their current enabled/disabled status.\n\n" "All markers will retain their current enabled/disabled status.\n\n"
"@ingroup Debugging" ) "@ingroup Debugging" )
{ {
if(gProfiler) if(gProfiler)
gProfiler->reset(); gProfiler->reset();

View file

@ -839,7 +839,7 @@ static bool recurseDumpDirectories(const char *basePath, const char *subPath, Ve
while (d = readdir(dip)) while (d = readdir(dip))
{ {
bool isDir; bool isDir;
isDir = false; isDir = false;
if (d->d_type == DT_UNKNOWN) if (d->d_type == DT_UNKNOWN)
{ {

View file

@ -843,7 +843,7 @@ void ProcessedPrePassMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
if ( isTranslucent ) if ( isTranslucent )
{ {
prePassStateBlock.setBlend( true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha ); prePassStateBlock.setBlend( true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha );
prePassStateBlock.setColorWrites(false, false, false, true); prePassStateBlock.setColorWrites(false, false, false, true);
} }
// Enable z reads, but only enable zwrites if we're not translucent. // Enable z reads, but only enable zwrites if we're not translucent.