mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Adds handling for complex fields such as Point2, Point3 and Point4's to be able to apply value changes to only one axis across a multi-object set without affecting other axis'
This commit is contained in:
parent
72eb21ede0
commit
fdadfa5eea
4 changed files with 179 additions and 30 deletions
|
|
@ -1765,12 +1765,12 @@ void GuiInspectorTypeSFXSourceName::consoleInit()
|
||||||
|
|
||||||
void GuiInspectorType2DValue::constructEditControlChildren(GuiControl* retCtrl, S32 width)
|
void GuiInspectorType2DValue::constructEditControlChildren(GuiControl* retCtrl, S32 width)
|
||||||
{
|
{
|
||||||
mCtrlX = new GuiTextEditSliderCtrl();
|
mCtrlX = new GuiTextEditCtrl();
|
||||||
_registerEditControl(mCtrlX, "x");
|
_registerEditControl(mCtrlX, "x");
|
||||||
mLabelX = new GuiControl();
|
mLabelX = new GuiControl();
|
||||||
_registerEditControl(mLabelX, "lx");
|
_registerEditControl(mLabelX, "lx");
|
||||||
|
|
||||||
mCtrlY = new GuiTextEditSliderCtrl();
|
mCtrlY = new GuiTextEditCtrl();
|
||||||
_registerEditControl(mCtrlY, "y");
|
_registerEditControl(mCtrlY, "y");
|
||||||
mLabelY = new GuiControl();
|
mLabelY = new GuiControl();
|
||||||
_registerEditControl(mLabelY, "ly");
|
_registerEditControl(mLabelY, "ly");
|
||||||
|
|
@ -1824,14 +1824,17 @@ void GuiInspectorType2DValue::constructEditControlChildren(GuiControl* retCtrl,
|
||||||
mCtrlX->setPosition(Point2I(labelWidth, 0));
|
mCtrlX->setPosition(Point2I(labelWidth, 0));
|
||||||
mCtrlY->setPosition(Point2I(labelWidth, 0));
|
mCtrlY->setPosition(Point2I(labelWidth, 0));
|
||||||
|
|
||||||
char szBuffer[512];
|
char szXCBuffer[512];
|
||||||
dSprintf(szBuffer, 512, "%d.apply(%d.getText() SPC %d.getText());", getId(), mCtrlX->getId(), mCtrlY->getId());
|
dSprintf(szXCBuffer, 512, "%d.applyWord(0, %d.getText());", getId(), mCtrlX->getId());
|
||||||
|
|
||||||
mCtrlX->setField("AltCommand", szBuffer);
|
char szYCBuffer[512];
|
||||||
mCtrlY->setField("AltCommand", szBuffer);
|
dSprintf(szYCBuffer, 512, "%d.applyWord(1, %d.getText());", getId(), mCtrlY->getId());
|
||||||
|
|
||||||
mCtrlX->setField("Validate", szBuffer);
|
mCtrlX->setField("AltCommand", szXCBuffer);
|
||||||
mCtrlY->setField("Validate", szBuffer);
|
mCtrlY->setField("AltCommand", szYCBuffer);
|
||||||
|
|
||||||
|
mCtrlX->setField("Validate", szXCBuffer);
|
||||||
|
mCtrlY->setField("Validate", szYCBuffer);
|
||||||
|
|
||||||
mContainerX = new GuiControl();
|
mContainerX = new GuiControl();
|
||||||
mContainerX->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
|
mContainerX->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
|
||||||
|
|
@ -1933,7 +1936,7 @@ void GuiInspectorType3DValue::constructEditControlChildren(GuiControl* retCtrl,
|
||||||
{
|
{
|
||||||
Parent::constructEditControlChildren(retCtrl, width);
|
Parent::constructEditControlChildren(retCtrl, width);
|
||||||
|
|
||||||
mCtrlZ = new GuiTextEditSliderCtrl();
|
mCtrlZ = new GuiTextEditCtrl();
|
||||||
_registerEditControl(mCtrlZ, "z");
|
_registerEditControl(mCtrlZ, "z");
|
||||||
mLabelZ = new GuiControl();
|
mLabelZ = new GuiControl();
|
||||||
_registerEditControl(mLabelZ, "lz");
|
_registerEditControl(mLabelZ, "lz");
|
||||||
|
|
@ -1953,16 +1956,22 @@ void GuiInspectorType3DValue::constructEditControlChildren(GuiControl* retCtrl,
|
||||||
|
|
||||||
mCtrlZ->setPosition(Point2I(labelWidth, 0));
|
mCtrlZ->setPosition(Point2I(labelWidth, 0));
|
||||||
|
|
||||||
char szBuffer[512];
|
char szXCBuffer[512];
|
||||||
dSprintf(szBuffer, 512, "%d.apply(%d.getText() SPC %d.getText() SPC %d.getText());", getId(), mCtrlX->getId(), mCtrlY->getId(), mCtrlZ->getId());
|
dSprintf(szXCBuffer, 512, "%d.applyWord(0, %d.getText());", getId(), mCtrlX->getId());
|
||||||
|
|
||||||
mCtrlX->setField("AltCommand", szBuffer);
|
char szYCBuffer[512];
|
||||||
mCtrlY->setField("AltCommand", szBuffer);
|
dSprintf(szYCBuffer, 512, "%d.applyWord(1, %d.getText());", getId(), mCtrlY->getId());
|
||||||
mCtrlZ->setField("AltCommand", szBuffer);
|
|
||||||
|
|
||||||
mCtrlX->setField("Validate", szBuffer);
|
char szZCBuffer[512];
|
||||||
mCtrlY->setField("Validate", szBuffer);
|
dSprintf(szZCBuffer, 512, "%d.applyWord(2, %d.getText());", getId(), mCtrlZ->getId());
|
||||||
mCtrlZ->setField("Validate", szBuffer);
|
|
||||||
|
mCtrlX->setField("AltCommand", szXCBuffer);
|
||||||
|
mCtrlY->setField("AltCommand", szYCBuffer);
|
||||||
|
mCtrlZ->setField("AltCommand", szZCBuffer);
|
||||||
|
|
||||||
|
mCtrlX->setField("Validate", szXCBuffer);
|
||||||
|
mCtrlY->setField("Validate", szYCBuffer);
|
||||||
|
mCtrlZ->setField("Validate", szZCBuffer);
|
||||||
|
|
||||||
mContainerZ = new GuiControl();
|
mContainerZ = new GuiControl();
|
||||||
mContainerZ->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
|
mContainerZ->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
|
||||||
|
|
@ -2057,18 +2066,27 @@ void GuiInspectorType4DValue::constructEditControlChildren(GuiControl* retCtrl,
|
||||||
|
|
||||||
mCtrlW->setPosition(Point2I(labelWidth, 0));
|
mCtrlW->setPosition(Point2I(labelWidth, 0));
|
||||||
|
|
||||||
char szBuffer[512];
|
char szXCBuffer[512];
|
||||||
dSprintf(szBuffer, 512, "%d.apply(%d.getText() SPC %d.getText() SPC %d.getText() SPC %d.getText());", getId(), mCtrlX->getId(), mCtrlY->getId(), mCtrlZ->getId(), mCtrlW->getId());
|
dSprintf(szXCBuffer, 512, "%d.applyWord(0, %d.getText());", getId(), mCtrlX->getId());
|
||||||
|
|
||||||
mCtrlX->setField("AltCommand", szBuffer);
|
char szYCBuffer[512];
|
||||||
mCtrlY->setField("AltCommand", szBuffer);
|
dSprintf(szYCBuffer, 512, "%d.applyWord(1, %d.getText());", getId(), mCtrlY->getId());
|
||||||
mCtrlZ->setField("AltCommand", szBuffer);
|
|
||||||
mCtrlW->setField("AltCommand", szBuffer);
|
|
||||||
|
|
||||||
mCtrlX->setField("Validate", szBuffer);
|
char szZCBuffer[512];
|
||||||
mCtrlY->setField("Validate", szBuffer);
|
dSprintf(szZCBuffer, 512, "%d.applyWord(2, %d.getText());", getId(), mCtrlZ->getId());
|
||||||
mCtrlZ->setField("Validate", szBuffer);
|
|
||||||
mCtrlW->setField("Validate", szBuffer);
|
char szWCBuffer[512];
|
||||||
|
dSprintf(szZCBuffer, 512, "%d.applyWord(3, %d.getText());", getId(), mCtrlW->getId());
|
||||||
|
|
||||||
|
mCtrlX->setField("AltCommand", szXCBuffer);
|
||||||
|
mCtrlY->setField("AltCommand", szYCBuffer);
|
||||||
|
mCtrlZ->setField("AltCommand", szZCBuffer);
|
||||||
|
mCtrlW->setField("AltCommand", szWCBuffer);
|
||||||
|
|
||||||
|
mCtrlX->setField("Validate", szXCBuffer);
|
||||||
|
mCtrlY->setField("Validate", szYCBuffer);
|
||||||
|
mCtrlZ->setField("Validate", szZCBuffer);
|
||||||
|
mCtrlW->setField("Validate", szWCBuffer);
|
||||||
|
|
||||||
GuiControl* mContainerW = new GuiControl();
|
GuiControl* mContainerW = new GuiControl();
|
||||||
mContainerW->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
|
mContainerW->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
|
||||||
|
|
|
||||||
|
|
@ -604,10 +604,10 @@ class GuiInspectorType2DValue : public GuiInspectorField
|
||||||
private:
|
private:
|
||||||
typedef GuiInspectorField Parent;
|
typedef GuiInspectorField Parent;
|
||||||
protected:
|
protected:
|
||||||
GuiTextEditSliderCtrl* mCtrlX;
|
GuiTextEditCtrl* mCtrlX;
|
||||||
GuiControl* mLabelX;
|
GuiControl* mLabelX;
|
||||||
GuiControl* mContainerX;
|
GuiControl* mContainerX;
|
||||||
GuiTextEditSliderCtrl* mCtrlY;
|
GuiTextEditCtrl* mCtrlY;
|
||||||
GuiControl* mLabelY;
|
GuiControl* mLabelY;
|
||||||
GuiControl* mContainerY;
|
GuiControl* mContainerY;
|
||||||
GuiTextCtrl* mScriptValue;
|
GuiTextCtrl* mScriptValue;
|
||||||
|
|
@ -634,7 +634,7 @@ class GuiInspectorType3DValue : public GuiInspectorType2DValue
|
||||||
private:
|
private:
|
||||||
typedef GuiInspectorType2DValue Parent;
|
typedef GuiInspectorType2DValue Parent;
|
||||||
protected:
|
protected:
|
||||||
GuiTextEditSliderCtrl* mCtrlZ;
|
GuiTextEditCtrl* mCtrlZ;
|
||||||
GuiControl* mLabelZ;
|
GuiControl* mLabelZ;
|
||||||
GuiControl* mContainerZ;
|
GuiControl* mContainerZ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,129 @@ void GuiInspectorField::onRightMouseUp( const GuiEvent &event )
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
void GuiInspectorField::setWordData(const S32& wordIndex, const char* data, bool callbacks)
|
||||||
|
{
|
||||||
|
if (mSpecialEditField)
|
||||||
|
{
|
||||||
|
if (mTargetObject != nullptr && mVariableName != StringTable->EmptyString())
|
||||||
|
{
|
||||||
|
const char* fieldData = mTargetObject->getDataField(mVariableName, NULL);
|
||||||
|
|
||||||
|
StringBuilder newFieldData;
|
||||||
|
const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
|
||||||
|
for (U32 i = 0; i < wordCount; i++)
|
||||||
|
{
|
||||||
|
if (i != 0)
|
||||||
|
newFieldData.append(" ");
|
||||||
|
|
||||||
|
if (i == wordIndex)
|
||||||
|
newFieldData.append(data);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newFieldData.append(StringUnit::getUnit(fieldData, i, " \t\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTargetObject->setDataField(mVariableName, NULL, newFieldData.end());
|
||||||
|
|
||||||
|
if (mCallbackName != StringTable->EmptyString())
|
||||||
|
Con::executef(mInspector, mCallbackName, mVariableName, newFieldData.end(), mTargetObject);
|
||||||
|
}
|
||||||
|
else if (mVariableName != StringTable->EmptyString())
|
||||||
|
{
|
||||||
|
const char* fieldData = Con::getVariable(mVariableName, "");
|
||||||
|
|
||||||
|
StringBuilder newFieldData;
|
||||||
|
const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
|
||||||
|
for (U32 i = 0; i < wordCount; i++)
|
||||||
|
{
|
||||||
|
if (i != 0)
|
||||||
|
newFieldData.append(" ");
|
||||||
|
|
||||||
|
if (i == wordIndex)
|
||||||
|
newFieldData.append(data);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newFieldData.append(StringUnit::getUnit(fieldData, i, " \t\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Con::setVariable(mVariableName, newFieldData.end());
|
||||||
|
|
||||||
|
if (mCallbackName != StringTable->EmptyString())
|
||||||
|
Con::executef(mInspector, mCallbackName, mVariableName, newFieldData.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mField == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (verifyData(data))
|
||||||
|
{
|
||||||
|
String strData = data;
|
||||||
|
const U32 numTargets = mInspector->getNumInspectObjects();
|
||||||
|
|
||||||
|
if (callbacks && numTargets > 1)
|
||||||
|
Con::executef(mInspector, "onBeginCompoundEdit");
|
||||||
|
|
||||||
|
for (U32 i = 0; i < numTargets; ++i)
|
||||||
|
{
|
||||||
|
//For now, for simplicity's sake, you can only edit the components in a simple edit
|
||||||
|
SimObject* target = NULL;
|
||||||
|
if (numTargets == 1)
|
||||||
|
{
|
||||||
|
target = mTargetObject;
|
||||||
|
|
||||||
|
if (!target)
|
||||||
|
target = mInspector->getInspectObject(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target = mInspector->getInspectObject(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* fieldData = target->getDataField(mField->pFieldname, mFieldArrayIndex);
|
||||||
|
|
||||||
|
StringBuilder newFieldData;
|
||||||
|
const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
|
||||||
|
for (U32 i = 0; i < wordCount; i++)
|
||||||
|
{
|
||||||
|
if (i != 0)
|
||||||
|
newFieldData.append(" ");
|
||||||
|
|
||||||
|
if (i == wordIndex)
|
||||||
|
newFieldData.append(data);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newFieldData.append(StringUnit::getUnit(fieldData, i, " \t\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target->inspectPreApply();
|
||||||
|
|
||||||
|
// Fire callback single-object undo.
|
||||||
|
|
||||||
|
if (callbacks && !mField->flag.test(AbstractClassRep::FieldFlags::FIELD_ComponentInspectors))
|
||||||
|
Con::executef(mInspector, "onInspectorFieldModified",
|
||||||
|
target->getIdString(),
|
||||||
|
mField->pFieldname,
|
||||||
|
mFieldArrayIndex ? mFieldArrayIndex : "(null)",
|
||||||
|
fieldData,
|
||||||
|
newFieldData.end());
|
||||||
|
|
||||||
|
target->setDataField(mField->pFieldname, mFieldArrayIndex, newFieldData.end());
|
||||||
|
|
||||||
|
// Give the target a chance to validate.
|
||||||
|
target->inspectPostApply();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callbacks && numTargets > 1)
|
||||||
|
Con::executef(mInspector, "onEndCompoundEdit");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force our edit to update
|
||||||
|
updateValue();
|
||||||
|
}
|
||||||
|
|
||||||
void GuiInspectorField::setData( const char* data, bool callbacks )
|
void GuiInspectorField::setData( const char* data, bool callbacks )
|
||||||
{
|
{
|
||||||
|
|
@ -762,6 +885,12 @@ DefineEngineMethod( GuiInspectorField, apply, void, ( const char * newValue, boo
|
||||||
object->setData( newValue, callbacks );
|
object->setData( newValue, callbacks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
DefineEngineMethod(GuiInspectorField, applyWord, void, (S32 wordIndex, const char* newValue, bool callbacks), (true), "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false.")
|
||||||
|
{
|
||||||
|
object->setWordData(wordIndex, newValue, callbacks);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
DefineEngineMethod( GuiInspectorField, applyWithoutUndo, void, (const char * data), , "() - Set field value without recording undo (same as 'apply( value, false )')." )
|
DefineEngineMethod( GuiInspectorField, applyWithoutUndo, void, (const char * data), , "() - Set field value without recording undo (same as 'apply( value, false )')." )
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,8 @@ class GuiInspectorField : public GuiControl
|
||||||
/// to perform their own verification.
|
/// to perform their own verification.
|
||||||
virtual bool verifyData( StringTableEntry data ) { return true; }
|
virtual bool verifyData( StringTableEntry data ) { return true; }
|
||||||
|
|
||||||
|
void setWordData(const S32& wordIndex, const char* data, bool callbacks);
|
||||||
|
|
||||||
/// Set value of the field we are inspecting
|
/// Set value of the field we are inspecting
|
||||||
virtual void setData( const char* data, bool callbacks = true );
|
virtual void setData( const char* data, bool callbacks = true );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue