Browse Source

Cleaned up unneeded formatting values on the TypePointX field elements
Adds logic checks so we don't multi-apply edits from applyWord fields, causing redundant extra undo's

Areloch 1 year ago
parent
commit
0d2aeac303

+ 0 - 9
Engine/source/gui/editor/guiInspectorTypes.cpp

@@ -1797,15 +1797,9 @@ void GuiInspectorType2DValue::constructEditControlChildren(GuiControl* retCtrl,
 
 
    mCtrlX->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
    mCtrlX->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
    mCtrlX->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
    mCtrlX->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
-   mCtrlX->setDataField(StringTable->insert("format"), NULL, "%g");
-   mCtrlX->setDataField(StringTable->insert("range"), NULL, "-1e+32 1e+32");
-   mCtrlX->setDataField(StringTable->insert("increment"), NULL, "0.0001");
 
 
    mCtrlY->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
    mCtrlY->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
    mCtrlY->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
    mCtrlY->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
-   mCtrlY->setDataField(StringTable->insert("format"), NULL, "%g");
-   mCtrlY->setDataField(StringTable->insert("range"), NULL, "-1e+32 1e+32");
-   mCtrlY->setDataField(StringTable->insert("increment"), NULL, "0.0001");
 
 
    mLabelX->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiXDimensionText");
    mLabelX->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiXDimensionText");
    mLabelY->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiYDimensionText");
    mLabelY->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiYDimensionText");
@@ -1943,9 +1937,6 @@ void GuiInspectorType3DValue::constructEditControlChildren(GuiControl* retCtrl,
 
 
    mCtrlZ->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
    mCtrlZ->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile");
    mCtrlZ->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
    mCtrlZ->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
-   mCtrlZ->setDataField(StringTable->insert("format"), NULL, "%g");
-   mCtrlZ->setDataField(StringTable->insert("range"), NULL, "-1e+32 1e+32");
-   mCtrlZ->setDataField(StringTable->insert("increment"), NULL, "0.0001");
 
 
    mLabelZ->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiZDimensionText");
    mLabelZ->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiZDimensionText");
 
 

+ 102 - 0
Engine/source/gui/editor/inspector/field.cpp

@@ -266,11 +266,36 @@ void GuiInspectorField::onRightMouseUp( const GuiEvent &event )
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void GuiInspectorField::setWordData(const S32& wordIndex, const char* data, bool callbacks)
 void GuiInspectorField::setWordData(const S32& wordIndex, const char* data, bool callbacks)
 {
 {
+
    if (mSpecialEditField)
    if (mSpecialEditField)
    {
    {
       if (mTargetObject != nullptr && mVariableName != StringTable->EmptyString())
       if (mTargetObject != nullptr && mVariableName != StringTable->EmptyString())
       {
       {
          const char* fieldData = mTargetObject->getDataField(mVariableName, NULL);
          const char* fieldData = mTargetObject->getDataField(mVariableName, NULL);
+         const char* wordData = StringUnit::getUnit(fieldData, wordIndex, " \t\n");
+
+         S32 type = mField->type;
+         if (type == TypeS8 || type == TypeS32 || type == TypeF32 || type == TypeS32Vector
+            || type == TypeF32Vector
+            || type == TypeColorI
+            || type == TypeColorF
+            || type == TypePoint2I
+            || type == TypePoint2F
+            || type == TypePoint3F
+            || type == TypePoint4F
+            || type == TypeRectI
+            || type == TypeRectF
+            || type == TypeMatrixPosition
+            || type == TypeMatrixRotation
+            || type == TypeBox3F
+            || type == TypeRectUV
+            || type == TypeRotationF)
+         {
+            if (dAtof(wordData) != dAtof(data))
+               return;
+         }
+         else if(dStrEqual(wordData, data))
+            return;
 
 
          StringBuilder newFieldData;
          StringBuilder newFieldData;
          const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
          const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
@@ -295,6 +320,30 @@ void GuiInspectorField::setWordData(const S32& wordIndex, const char* data, bool
       else if (mVariableName != StringTable->EmptyString())
       else if (mVariableName != StringTable->EmptyString())
       {
       {
          const char* fieldData = Con::getVariable(mVariableName, "");
          const char* fieldData = Con::getVariable(mVariableName, "");
+         const char* wordData = StringUnit::getUnit(fieldData, wordIndex, " \t\n");
+
+         S32 type = mField->type;
+         if (type == TypeS8 || type == TypeS32 || type == TypeF32 || type == TypeS32Vector
+            || type == TypeF32Vector
+            || type == TypeColorI
+            || type == TypeColorF
+            || type == TypePoint2I
+            || type == TypePoint2F
+            || type == TypePoint3F
+            || type == TypePoint4F
+            || type == TypeRectI
+            || type == TypeRectF
+            || type == TypeMatrixPosition
+            || type == TypeMatrixRotation
+            || type == TypeBox3F
+            || type == TypeRectUV
+            || type == TypeRotationF)
+         {
+            if (dAtof(wordData) != dAtof(data))
+               return;
+         }
+         else if (dStrEqual(wordData, data))
+            return;
 
 
          StringBuilder newFieldData;
          StringBuilder newFieldData;
          const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
          const U32 wordCount = StringUnit::getUnitCount(fieldData, " \t\n");
@@ -326,6 +375,59 @@ void GuiInspectorField::setWordData(const S32& wordIndex, const char* data, bool
       String strData = data;
       String strData = data;
       const U32 numTargets = mInspector->getNumInspectObjects();
       const U32 numTargets = mInspector->getNumInspectObjects();
 
 
+      bool changed = false;
+      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);
+         const char* wordData = StringUnit::getUnit(fieldData, wordIndex, " \t\n");
+
+         S32 type = mField->type;
+         if (type == TypeS8 || type == TypeS32 || type == TypeF32 || type == TypeS32Vector
+            || type == TypeF32Vector
+            || type == TypeColorI
+            || type == TypeColorF
+            || type == TypePoint2I
+            || type == TypePoint2F
+            || type == TypePoint3F
+            || type == TypePoint4F
+            || type == TypeRectI
+            || type == TypeRectF
+            || type == TypeMatrixPosition
+            || type == TypeMatrixRotation
+            || type == TypeBox3F
+            || type == TypeRectUV
+            || type == TypeRotationF)
+         {
+            if (dAtof(wordData) != dAtof(data))
+            {
+               changed = true;
+               break;
+            }
+         }
+         else if (!dStrEqual(wordData, data))
+         {
+            changed = true;
+            break;
+         }
+      }
+
+      if(!changed)
+         return;
+
       if (callbacks && numTargets > 1)
       if (callbacks && numTargets > 1)
          Con::executef(mInspector, "onBeginCompoundEdit");
          Con::executef(mInspector, "onBeginCompoundEdit");