mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Adds expanded ability to create and insert specialized script-based inspector fields
Adds logic during the editor script initialization to let game modules have embedded tools Changed setting to force prompt for target modules when creating things like datablocks to minimize confusion about where they save to
This commit is contained in:
parent
bb44fa4bb7
commit
2f40b843d4
7 changed files with 131 additions and 5 deletions
|
|
@ -805,6 +805,16 @@ S32 GuiInspector::createInspectorGroup(StringTableEntry groupName, S32 index)
|
||||||
return newGroup->getId();
|
return newGroup->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiInspector::removeInspectorGroup(StringTableEntry groupName)
|
||||||
|
{
|
||||||
|
GuiInspectorGroup* group = findExistentGroup(groupName);
|
||||||
|
if (group == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mGroups.remove(group);
|
||||||
|
removeObject(group);
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Console Methods.
|
// Console Methods.
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
@ -962,3 +972,10 @@ DefineEngineMethod(GuiInspector, findExistentGroup, S32, (const char* groupName)
|
||||||
GuiInspectorGroup* group = object->findExistentGroup(StringTable->insert(groupName));
|
GuiInspectorGroup* group = object->findExistentGroup(StringTable->insert(groupName));
|
||||||
return group ? group->getId() : 0;
|
return group ? group->getId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiInspector, removeGroup, void, (const char* groupName), ,
|
||||||
|
"Finds an existing GuiInspectorGroup if it exists removes it.\n"
|
||||||
|
"@param groupName Name of the new GuiInspectorGroup to find in this Inspector.")
|
||||||
|
{
|
||||||
|
object->removeInspectorGroup(StringTable->insert(groupName));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,8 @@ public:
|
||||||
|
|
||||||
S32 createInspectorGroup(StringTableEntry groupName, S32 index);
|
S32 createInspectorGroup(StringTableEntry groupName, S32 index);
|
||||||
|
|
||||||
|
void removeInspectorGroup(StringTableEntry groupName);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef Vector< SimObjectPtr< SimObject > > TargetVector;
|
typedef Vector< SimObjectPtr< SimObject > > TargetVector;
|
||||||
|
|
|
||||||
|
|
@ -210,8 +210,11 @@ class GuiInspectorField : public GuiControl
|
||||||
void setTargetObject(SimObject* obj) { mTargetObject = obj; }
|
void setTargetObject(SimObject* obj) { mTargetObject = obj; }
|
||||||
SimObject* getTargetObject() { return mTargetObject; }
|
SimObject* getTargetObject() { return mTargetObject; }
|
||||||
void setSpecialEditField(bool isSpecialEditField) { mSpecialEditField = isSpecialEditField; }
|
void setSpecialEditField(bool isSpecialEditField) { mSpecialEditField = isSpecialEditField; }
|
||||||
void setSpecialEditVariableName(String varName) { mVariableName = StringTable->insert(varName); }
|
|
||||||
void setSpecialEditCallbackName(String callName) { mCallbackName = StringTable->insert(callName); }
|
void setSpecialEditVariableName(StringTableEntry varName) { mVariableName = varName; }
|
||||||
|
StringTableEntry getSpecialEditVariableName() { return mVariableName; }
|
||||||
|
|
||||||
|
void setSpecialEditCallbackName(StringTableEntry callName) { mCallbackName = callName; }
|
||||||
|
|
||||||
DECLARE_CONOBJECT( GuiInspectorField );
|
DECLARE_CONOBJECT( GuiInspectorField );
|
||||||
DECLARE_CATEGORY( "Gui Editor" );
|
DECLARE_CATEGORY( "Gui Editor" );
|
||||||
|
|
|
||||||
|
|
@ -568,6 +568,22 @@ AbstractClassRep* GuiInspectorGroup::findCommonAncestorClass()
|
||||||
return classRep;
|
return classRep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiInspectorField* GuiInspectorGroup::createInspectorField()
|
||||||
|
{
|
||||||
|
GuiInspectorField* newField = new GuiInspectorField();
|
||||||
|
|
||||||
|
newField->init(mParent, this);
|
||||||
|
|
||||||
|
newField->setSpecialEditField(true);
|
||||||
|
|
||||||
|
if (newField->registerObject())
|
||||||
|
{
|
||||||
|
return newField;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntry typeName, const char* description, const char* callbackName)
|
void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntry typeName, const char* description, const char* callbackName)
|
||||||
{
|
{
|
||||||
S32 fieldType = -1;
|
S32 fieldType = -1;
|
||||||
|
|
@ -626,7 +642,7 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr
|
||||||
//ensure our stack variable is bound if we need it
|
//ensure our stack variable is bound if we need it
|
||||||
Con::evaluatef("%d.stack = %d;", this->getId(), mStack->getId());
|
Con::evaluatef("%d.stack = %d;", this->getId(), mStack->getId());
|
||||||
|
|
||||||
Con::executef(this, "onConstructField", name, name, typeName, description, StringTable->EmptyString(), StringTable->EmptyString(), callbackName);
|
Con::executef(this, "onConstructField", name, name, typeName, description, StringTable->EmptyString(), StringTable->EmptyString(), callbackName, mParent->getInspectObject(0)->getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -639,7 +655,7 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr
|
||||||
StringTableEntry fieldName = StringTable->insert(name);
|
StringTableEntry fieldName = StringTable->insert(name);
|
||||||
|
|
||||||
fieldGui->setSpecialEditVariableName(fieldName);
|
fieldGui->setSpecialEditVariableName(fieldName);
|
||||||
fieldGui->setSpecialEditCallbackName(callbackName);
|
fieldGui->setSpecialEditCallbackName(StringTable->insert(callbackName));
|
||||||
|
|
||||||
fieldGui->setInspectorField(NULL, fieldName);
|
fieldGui->setInspectorField(NULL, fieldName);
|
||||||
fieldGui->setDocs(description);
|
fieldGui->setDocs(description);
|
||||||
|
|
@ -657,6 +673,35 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiInspectorGroup::addInspectorField(GuiInspectorField* field)
|
||||||
|
{
|
||||||
|
mStack->addObject(field);
|
||||||
|
mChildren.push_back(field);
|
||||||
|
mStack->updatePanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiInspectorGroup::removeInspectorField(StringTableEntry name)
|
||||||
|
{
|
||||||
|
for (U32 i = 0; i < mStack->size(); i++)
|
||||||
|
{
|
||||||
|
GuiInspectorField* field = dynamic_cast<GuiInspectorField*>(mStack->getObject(i));
|
||||||
|
|
||||||
|
if (field == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (field->getFieldName() == name || field->getSpecialEditVariableName() == name)
|
||||||
|
{
|
||||||
|
mStack->removeObject(field);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiInspectorGroup, createInspectorField, GuiInspectorField*, (), , "createInspectorField()")
|
||||||
|
{
|
||||||
|
return object->createInspectorField();
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(GuiInspectorGroup, addField, void, (const char* fieldName, const char* fieldTypeName, const char* description, const char* callbackName),
|
DefineEngineMethod(GuiInspectorGroup, addField, void, (const char* fieldName, const char* fieldTypeName, const char* description, const char* callbackName),
|
||||||
("", "", "", ""),
|
("", "", "", ""),
|
||||||
"Adds a new Inspector field to this group.\n"
|
"Adds a new Inspector field to this group.\n"
|
||||||
|
|
@ -670,3 +715,21 @@ DefineEngineMethod(GuiInspectorGroup, addField, void, (const char* fieldName, co
|
||||||
|
|
||||||
object->addInspectorField(StringTable->insert(fieldName), StringTable->insert(fieldTypeName), description, callbackName);
|
object->addInspectorField(StringTable->insert(fieldName), StringTable->insert(fieldTypeName), description, callbackName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiInspectorGroup, addInspectorField, void, (GuiInspectorField* field), (nullAsType<GuiInspectorField*>()), "addInspectorField( GuiInspectorFieldObject )")
|
||||||
|
{
|
||||||
|
if(field)
|
||||||
|
object->addInspectorField(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiInspectorGroup, removeField, void, (const char* fieldName),
|
||||||
|
(""),
|
||||||
|
"Removes a Inspector field to this group of a given name.\n"
|
||||||
|
"@param fieldName The name of the field to be removed.")
|
||||||
|
{
|
||||||
|
if (dStrEqual(fieldName, ""))
|
||||||
|
return;
|
||||||
|
|
||||||
|
object->removeInspectorField(StringTable->insert(fieldName));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,10 @@ public:
|
||||||
|
|
||||||
U32 getNumFields() const { return mChildren.size(); }
|
U32 getNumFields() const { return mChildren.size(); }
|
||||||
|
|
||||||
|
GuiInspectorField* createInspectorField();
|
||||||
void addInspectorField(StringTableEntry name, StringTableEntry typeName, const char* description, const char* callbackName);
|
void addInspectorField(StringTableEntry name, StringTableEntry typeName, const char* description, const char* callbackName);
|
||||||
|
void addInspectorField(GuiInspectorField* field);
|
||||||
|
void removeInspectorField(StringTableEntry name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// overridable method that creates our inner controls.
|
// overridable method that creates our inner controls.
|
||||||
|
|
|
||||||
|
|
@ -127,12 +127,48 @@ function onStart()
|
||||||
%folder = findNextFile( %pattern );
|
%folder = findNextFile( %pattern );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Next, scrape through modules and scan for tools subfolders there
|
||||||
|
%pattern = "data/*/editor." @ $TorqueScriptFileExtension;
|
||||||
|
%folder = findFirstFile( %pattern );
|
||||||
|
if ( %folder $= "")
|
||||||
|
{
|
||||||
|
// if we have absolutely no matches for main.tscript, we look for main.tscript.dso
|
||||||
|
%pattern = "data/*/editor." @ $TorqueScriptFileExtension @ ".dso";
|
||||||
|
%folder = findFirstFile( %pattern );
|
||||||
|
}
|
||||||
|
while ( %folder !$= "" )
|
||||||
|
{
|
||||||
|
if( filePath( %folder ) !$= "tools" ) // Skip the actual 'tools' folder...we want the children
|
||||||
|
{
|
||||||
|
%folder = filePath( %folder );
|
||||||
|
%editor = fileName( %folder );
|
||||||
|
if ( IsDirectory( %folder ) )
|
||||||
|
{
|
||||||
|
// Yes, this sucks and should be done better
|
||||||
|
if ( strstr( $Tools::loadFirst, %editor ) == -1 )
|
||||||
|
{
|
||||||
|
$editors[$editors[count]] = %editor;
|
||||||
|
$editorsPath[$editors[count]] = %folder;
|
||||||
|
$editors[count]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%folder = findNextFile( %pattern );
|
||||||
|
}
|
||||||
|
|
||||||
// initialize every editor
|
// initialize every editor
|
||||||
new SimSet( EditorPluginSet );
|
new SimSet( EditorPluginSet );
|
||||||
%count = $editors[count];
|
%count = $editors[count];
|
||||||
for ( %i = 0; %i < %count; %i++ )
|
for ( %i = 0; %i < %count; %i++ )
|
||||||
{
|
{
|
||||||
exec( "./" @ $editors[%i] @ "/main." @ $TorqueScriptFileExtension );
|
%editorFilename = "./" @ $editors[%i] @ "/main." @ $TorqueScriptFileExtension;
|
||||||
|
if(isFile(%editorFilename))
|
||||||
|
exec( "./" @ $editors[%i] @ "/main." @ $TorqueScriptFileExtension );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($editorsPath[%i] !$= "")
|
||||||
|
exec( $editorsPath[%i] @ "/editor." @ $TorqueScriptFileExtension );
|
||||||
|
}
|
||||||
|
|
||||||
%initializeFunction = "initialize" @ $editors[%i];
|
%initializeFunction = "initialize" @ $editors[%i];
|
||||||
if( isFunction( %initializeFunction ) )
|
if( isFunction( %initializeFunction ) )
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@
|
||||||
</Group>
|
</Group>
|
||||||
<Group
|
<Group
|
||||||
name="New">
|
name="New">
|
||||||
|
<Setting
|
||||||
|
name="alwaysPromptModuleTarget">1</Setting>
|
||||||
<Setting
|
<Setting
|
||||||
name="defaultModule">ExampleModule</Setting>
|
name="defaultModule">ExampleModule</Setting>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue