mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Adds the ability for modules to flag if they override existing objects during their creation.
This commit is contained in:
parent
2f88bdf865
commit
336020c102
|
|
@ -51,6 +51,7 @@ mModuleId(StringTable->EmptyString()),
|
|||
mSynchronized( false ),
|
||||
mDeprecated( false ),
|
||||
mCriticalMerge( false ),
|
||||
mOverrideExitingObjects(false),
|
||||
mModuleDescription( StringTable->EmptyString() ),
|
||||
mAuthor(StringTable->EmptyString()),
|
||||
mModuleGroup(StringTable->EmptyString()),
|
||||
|
|
@ -91,6 +92,7 @@ void ModuleDefinition::initPersistFields()
|
|||
addProtectedField( "Synchronized", TypeBool, Offset(mSynchronized, ModuleDefinition), &setSynchronized, &defaultProtectedGetFn, &writeSynchronized, "Whether the module should be synchronized or not. Optional: If not specified then the module is not synchronized." );
|
||||
addProtectedField( "Deprecated", TypeBool, Offset(mDeprecated, ModuleDefinition), &setDeprecated, &defaultProtectedGetFn, &writeDeprecated, "Whether the module is deprecated or not. Optional: If not specified then the module is not deprecated." );
|
||||
addProtectedField( "CriticalMerge", TypeBool, Offset(mCriticalMerge, ModuleDefinition), &setDeprecated, &defaultProtectedGetFn, &writeCriticalMerge, "Whether the merging of a module prior to a restart is critical or not. Optional: If not specified then the module is not merge critical." );
|
||||
addProtectedField( "OverrideExistingObjects", TypeBool, Offset(mOverrideExitingObjects, ModuleDefinition), &setOverrideExistingObjects, &defaultProtectedGetFn, &writeOverrideExistingObjects, "Controls if when this module is loaded and the create function is executed, it will replace existing objects that share names or not.");
|
||||
addProtectedField( "Description", TypeString, Offset(mModuleDescription, ModuleDefinition), &setModuleDescription, &defaultProtectedGetFn, &writeModuleDescription, "The description typically used for debugging purposes but can be used for anything." );
|
||||
addProtectedField( "Author", TypeString, Offset(mAuthor, ModuleDefinition), &setAuthor, &defaultProtectedGetFn, &writeAuthor, "The author of the module." );
|
||||
addProtectedField( "Group", TypeString, Offset(mModuleGroup, ModuleDefinition), &setModuleGroup, &defaultProtectedGetFn, "The module group used typically when loading modules as a group." );
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ private:
|
|||
bool mSynchronized;
|
||||
bool mDeprecated;
|
||||
bool mCriticalMerge;
|
||||
bool mOverrideExitingObjects;
|
||||
StringTableEntry mModuleDescription;
|
||||
StringTableEntry mAuthor;;
|
||||
StringTableEntry mModuleGroup;
|
||||
|
|
@ -141,6 +142,8 @@ public:
|
|||
inline bool getDeprecated( void ) const { return mDeprecated; }
|
||||
inline void setCriticalMerge( const bool mergeCritical ) { if ( checkUnlocked() ) { mCriticalMerge = mergeCritical; } }
|
||||
inline bool getCriticalMerge( void ) const { return mCriticalMerge; }
|
||||
inline void setOverrideExistingObjects(const bool overrideExistingObj) { if (checkUnlocked()) { mOverrideExitingObjects = overrideExistingObj; } }
|
||||
inline bool getOverrideExistingObjects(void) const { return mOverrideExitingObjects; }
|
||||
inline void setModuleDescription( const char* pModuleDescription ) { if ( checkUnlocked() ) { mModuleDescription = StringTable->insert(pModuleDescription); } }
|
||||
inline StringTableEntry getModuleDescription( void ) const { return mModuleDescription; }
|
||||
inline void setAuthor( const char* pAuthor ) { if ( checkUnlocked() ) { mAuthor = StringTable->insert(pAuthor); } }
|
||||
|
|
@ -206,6 +209,8 @@ protected:
|
|||
static bool setDeprecated(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setDeprecated(dAtob(data)); return false; }
|
||||
static bool writeDeprecated( void* obj, StringTableEntry pFieldName ) { return static_cast<ModuleDefinition*>(obj)->getDeprecated() == true; }
|
||||
static bool writeCriticalMerge( void* obj, StringTableEntry pFieldName ){ return static_cast<ModuleDefinition*>(obj)->getCriticalMerge() == true; }
|
||||
static bool setOverrideExistingObjects(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setOverrideExistingObjects(dAtob(data)); return false; }
|
||||
static bool writeOverrideExistingObjects(void* obj, StringTableEntry pFieldName) { return static_cast<ModuleDefinition*>(obj)->getOverrideExistingObjects() == true; }
|
||||
static bool setModuleDescription(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setModuleDescription(data); return false; }
|
||||
static bool writeModuleDescription( void* obj, StringTableEntry pFieldName ) { return static_cast<ModuleDefinition*>(obj)->getModuleDescription() != StringTable->EmptyString(); }
|
||||
static bool setAuthor(void* obj, const char* index, const char* data) { static_cast<ModuleDefinition*>(obj)->setAuthor(data); return false; }
|
||||
|
|
|
|||
|
|
@ -429,7 +429,22 @@ bool ModuleManager::loadModuleGroup( const char* pModuleGroup )
|
|||
if ( pScopeSet->isMethod( pLoadReadyModuleDefinition->getCreateFunction() ) )
|
||||
{
|
||||
// Yes, so call the create method.
|
||||
Con::executef( pScopeSet, pLoadReadyModuleDefinition->getCreateFunction() );
|
||||
|
||||
//But first, check if we're overriding objects, and if so, set our console var to make that happen while we exec our create function
|
||||
if (pLoadReadyModuleDefinition->getOverrideExistingObjects())
|
||||
{
|
||||
String redefineBehaviorPrev = Con::getVariable("$Con::redefineBehavior");
|
||||
Con::setVariable("$Con::redefineBehavior", "replaceExisting");
|
||||
Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
|
||||
|
||||
//And now that we've executed, switch back to the prior behavior
|
||||
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Nothing to do, just run the create function
|
||||
Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue