|
|
@@ -795,6 +795,16 @@ void UpdateAttributes(Array<Serializable@>@ serializables, ListView@ list, bool&
|
|
|
list.viewPosition = oldViewPos;
|
|
|
}
|
|
|
|
|
|
+void EditScriptAttributes(Component@ component, uint index)
|
|
|
+{
|
|
|
+ if (component !is null && component.typeName.Contains("ScriptInstance"))
|
|
|
+ {
|
|
|
+ String hash = GetComponentAttributeHash(component, index);
|
|
|
+ if (!hash.empty)
|
|
|
+ scriptAttributes[hash] = component.attributes[index];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void CreateDragSlider(LineEdit@ parent)
|
|
|
{
|
|
|
Button@ dragSld = Button();
|
|
|
@@ -834,6 +844,7 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
|
|
|
inEditAttribute = true;
|
|
|
|
|
|
Array<Variant> oldValues;
|
|
|
+
|
|
|
if (!dragEditAttribute)
|
|
|
{
|
|
|
// Store old values so that PostEditAttribute can create undo actions
|
|
|
@@ -844,14 +855,16 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
|
|
|
StoreAttributeEditor(parent, serializables, index, subIndex, coordinate);
|
|
|
for (uint i = 0; i < serializables.length; ++i)
|
|
|
serializables[i].ApplyAttributes();
|
|
|
-
|
|
|
- //disable undo
|
|
|
+
|
|
|
if (!dragEditAttribute)
|
|
|
{
|
|
|
// Do the editor post logic after attribute has been modified.
|
|
|
PostEditAttribute(serializables, index, oldValues);
|
|
|
}
|
|
|
|
|
|
+ // Update the stored script attributes if this is a ScriptInstance
|
|
|
+ EditScriptAttributes(serializables[0], index);
|
|
|
+
|
|
|
inEditAttribute = false;
|
|
|
|
|
|
// If not an intermediate edit, reload the editor fields with validated values
|
|
|
@@ -865,15 +878,15 @@ void LineDragBegin(StringHash eventType, VariantMap& eventData)
|
|
|
UIElement@ label = eventData["Element"].GetPtr();
|
|
|
int x = eventData["X"].GetInt();
|
|
|
label.vars["posX"] = x;
|
|
|
-
|
|
|
- //store value old value before dragging
|
|
|
+
|
|
|
+ // Store the old value before dragging
|
|
|
dragEditAttribute = false;
|
|
|
LineEdit@ selectedNumEditor = label.parent;
|
|
|
- //not convenient way to trigger EditAttribute event
|
|
|
- selectedNumEditor.text = selectedNumEditor.text;
|
|
|
+
|
|
|
selectedNumEditor.vars["DragBeginValue"] = selectedNumEditor.text;
|
|
|
selectedNumEditor.cursorPosition = 0;
|
|
|
|
|
|
+ // Set mouse mode to user preference
|
|
|
SetMouseMode(true);
|
|
|
}
|
|
|
|
|
|
@@ -882,6 +895,9 @@ void LineDragMove(StringHash eventTypem, VariantMap& eventData)
|
|
|
UIElement@ label = eventData["Element"].GetPtr();
|
|
|
LineEdit@ selectedNumEditor = label.parent;
|
|
|
|
|
|
+ // Prevent undo
|
|
|
+ dragEditAttribute = true;
|
|
|
+
|
|
|
int x = eventData["X"].GetInt();
|
|
|
int posx = label.vars["posX"].GetInt();
|
|
|
float val = input.mouseMoveX;
|
|
|
@@ -891,13 +907,28 @@ void LineDragMove(StringHash eventTypem, VariantMap& eventData)
|
|
|
label.vars["posX"] = x;
|
|
|
selectedNumEditor.text = fieldVal;
|
|
|
selectedNumEditor.cursorPosition = 0;
|
|
|
- //disable storing undo
|
|
|
- dragEditAttribute = true;
|
|
|
}
|
|
|
|
|
|
void LineDragEnd(StringHash eventType, VariantMap& eventData)
|
|
|
{
|
|
|
+ UIElement@ label = eventData["Element"].GetPtr();
|
|
|
+ LineEdit@ selectedNumEditor = label.parent;
|
|
|
+
|
|
|
+ // Prepare the attributes to store an undo with:
|
|
|
+ // - old value = drag begin value
|
|
|
+ // - new value = final value
|
|
|
+
|
|
|
+ String finalValue = selectedNumEditor.text;
|
|
|
+ // Reset attribute to begin value, and prevent undo
|
|
|
+ dragEditAttribute = true;
|
|
|
+ selectedNumEditor.text = selectedNumEditor.vars["DragBeginValue"].GetString();
|
|
|
+
|
|
|
+ // Store final value, allow undo
|
|
|
dragEditAttribute = false;
|
|
|
+ selectedNumEditor.text = finalValue;
|
|
|
+ selectedNumEditor.cursorPosition = 0;
|
|
|
+
|
|
|
+ // Revert mouse to normal behaviour
|
|
|
SetMouseMode(false);
|
|
|
}
|
|
|
|
|
|
@@ -905,11 +936,13 @@ void LineDragCancel(StringHash eventType, VariantMap& eventData)
|
|
|
{
|
|
|
UIElement@ label = eventData["Element"].GetPtr();
|
|
|
|
|
|
- //prevent undo triggering
|
|
|
+ // Reset value to what it was when drag edit began, preventing undo.
|
|
|
dragEditAttribute = true;
|
|
|
LineEdit@ selectedNumEditor = label.parent;
|
|
|
selectedNumEditor.text = selectedNumEditor.vars["DragBeginValue"].GetString();
|
|
|
selectedNumEditor.cursorPosition = 0;
|
|
|
+
|
|
|
+ // Revert mouse to normal behaviour
|
|
|
SetMouseMode(false);
|
|
|
}
|
|
|
|
|
|
@@ -1096,6 +1129,8 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
|
|
|
target.attributes[resourcePickIndex] = Variant(attrs);
|
|
|
target.ApplyAttributes();
|
|
|
}
|
|
|
+
|
|
|
+ EditScriptAttributes(target, resourcePickIndex);
|
|
|
}
|
|
|
|
|
|
PostEditAttribute(resourceTargets, resourcePickIndex, oldValues);
|