mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-17 19:31:01 +00:00
Merge pull request #997 from Areloch/ExpandedEditorToolstuffs
Adds expanded ability to create and insert specialized script-based inspector fields
This commit is contained in:
commit
3529a31d0f
8 changed files with 137 additions and 7 deletions
|
|
@ -805,6 +805,16 @@ S32 GuiInspector::createInspectorGroup(StringTableEntry groupName, S32 index)
|
|||
return newGroup->getId();
|
||||
}
|
||||
|
||||
void GuiInspector::removeInspectorGroup(StringTableEntry groupName)
|
||||
{
|
||||
GuiInspectorGroup* group = findExistentGroup(groupName);
|
||||
if (group == nullptr)
|
||||
return;
|
||||
|
||||
mGroups.remove(group);
|
||||
removeObject(group);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Console Methods.
|
||||
//=============================================================================
|
||||
|
|
@ -962,3 +972,10 @@ DefineEngineMethod(GuiInspector, findExistentGroup, S32, (const char* groupName)
|
|||
GuiInspectorGroup* group = object->findExistentGroup(StringTable->insert(groupName));
|
||||
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);
|
||||
|
||||
void removeInspectorGroup(StringTableEntry groupName);
|
||||
|
||||
protected:
|
||||
|
||||
typedef Vector< SimObjectPtr< SimObject > > TargetVector;
|
||||
|
|
|
|||
|
|
@ -210,8 +210,11 @@ class GuiInspectorField : public GuiControl
|
|||
void setTargetObject(SimObject* obj) { mTargetObject = obj; }
|
||||
SimObject* getTargetObject() { return mTargetObject; }
|
||||
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_CATEGORY( "Gui Editor" );
|
||||
|
|
|
|||
|
|
@ -568,6 +568,22 @@ AbstractClassRep* GuiInspectorGroup::findCommonAncestorClass()
|
|||
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)
|
||||
{
|
||||
S32 fieldType = -1;
|
||||
|
|
@ -626,7 +642,7 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr
|
|||
//ensure our stack variable is bound if we need it
|
||||
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
|
||||
|
|
@ -639,7 +655,7 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr
|
|||
StringTableEntry fieldName = StringTable->insert(name);
|
||||
|
||||
fieldGui->setSpecialEditVariableName(fieldName);
|
||||
fieldGui->setSpecialEditCallbackName(callbackName);
|
||||
fieldGui->setSpecialEditCallbackName(StringTable->insert(callbackName));
|
||||
|
||||
fieldGui->setInspectorField(NULL, fieldName);
|
||||
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),
|
||||
("", "", "", ""),
|
||||
"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);
|
||||
}
|
||||
|
||||
|
||||
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(); }
|
||||
|
||||
GuiInspectorField* createInspectorField();
|
||||
void addInspectorField(StringTableEntry name, StringTableEntry typeName, const char* description, const char* callbackName);
|
||||
void addInspectorField(GuiInspectorField* field);
|
||||
void removeInspectorField(StringTableEntry name);
|
||||
|
||||
protected:
|
||||
// overridable method that creates our inner controls.
|
||||
|
|
|
|||
|
|
@ -184,6 +184,10 @@ function AssetBrowserPlugin::initSettings( %this )
|
|||
|
||||
EditorSettings.setDefaultValue( "AssetImporDefaultConfig", "DefaultConfig" );
|
||||
EditorSettings.setDefaultValue( "AutoImport", 1 );
|
||||
|
||||
EditorSettings.beginGroup( "New" );
|
||||
EditorSettings.setDefaultValue( "alwaysPromptModuleTarget", 0 );
|
||||
EditorSettings.endGroup();
|
||||
|
||||
EditorSettings.beginGroup( "Browser" );
|
||||
|
||||
|
|
|
|||
|
|
@ -100,12 +100,12 @@ function onStart()
|
|||
$editors[%i] = getWord( $Tools::loadFirst, %i );
|
||||
}
|
||||
|
||||
%pattern = $Tools::resourcePath @ "/*/main." @ $TorqueScriptFileExtension;
|
||||
%pattern = $Tools::resourcePath @ "/*/main." @ $TorqueScriptFileExtension @ ".dso";
|
||||
%folder = findFirstFile( %pattern );
|
||||
if ( %folder $= "")
|
||||
{
|
||||
// if we have absolutely no matches for main.tscript, we look for main.tscript.dso
|
||||
%pattern = $Tools::resourcePath @ "/*/main." @ $TorqueScriptFileExtension @ ".dso";
|
||||
%pattern = $Tools::resourcePath @ "/*/main." @ $TorqueScriptFileExtension;
|
||||
%folder = findFirstFile( %pattern );
|
||||
}
|
||||
while ( %folder !$= "" )
|
||||
|
|
@ -126,13 +126,49 @@ function onStart()
|
|||
}
|
||||
%folder = findNextFile( %pattern );
|
||||
}
|
||||
|
||||
//Next, scrape through modules and scan for tools subfolders there
|
||||
%pattern = "data/*/editor." @ $TorqueScriptFileExtension @ ".dso";
|
||||
%folder = findFirstFile( %pattern );
|
||||
if ( %folder $= "")
|
||||
{
|
||||
// if we have absolutely no matches for main.tscript, we look for main.tscript.dso
|
||||
%pattern = "data/*/editor." @ $TorqueScriptFileExtension;
|
||||
%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
|
||||
new SimSet( EditorPluginSet );
|
||||
%count = $editors[count];
|
||||
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];
|
||||
if( isFunction( %initializeFunction ) )
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@
|
|||
</Group>
|
||||
<Group
|
||||
name="New">
|
||||
<Setting
|
||||
name="alwaysPromptModuleTarget">1</Setting>
|
||||
<Setting
|
||||
name="defaultModule">ExampleModule</Setting>
|
||||
</Group>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue