Browse Source

Remove the special script attribute storage mechanism.

Lasse Öörni 9 years ago
parent
commit
8af9f4785e

+ 0 - 15
bin/Data/Scripts/Editor/AttributeEditor.as

@@ -971,16 +971,6 @@ 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();
@@ -1039,9 +1029,6 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
         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
@@ -1307,8 +1294,6 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
             target.attributes[resourcePickIndex] = Variant(attrs);
             target.ApplyAttributes();
         }
-
-        EditScriptAttributes(target, resourcePickIndex);
     }
 
     PostEditAttribute(resourceTargets, resourcePickIndex, oldValues);

+ 0 - 4
bin/Data/Scripts/Editor/EditorActions.as

@@ -410,8 +410,6 @@ class EditAttributeAction : EditAction
                 SetUIElementModified(target);
             else
                 SetSceneModified();
-                
-            EditScriptAttributes(target, attrIndex);
         }
     }
 
@@ -431,8 +429,6 @@ class EditAttributeAction : EditAction
                 SetUIElementModified(target);
             else
                 SetSceneModified();
-                
-            EditScriptAttributes(target, attrIndex);
         }
     }
 }

+ 0 - 63
bin/Data/Scripts/Editor/EditorInspectorWindow.as

@@ -26,11 +26,6 @@ uint nodeContainerIndex = M_MAX_UNSIGNED;
 uint componentContainerStartIndex = 0;
 uint elementContainerIndex = M_MAX_UNSIGNED;
 
-// Script Attribute session storage
-VariantMap scriptAttributes;
-const uint SCRIPTINSTANCE_ATTRIBUTE_IGNORE = 5;
-const uint LUASCRIPTINSTANCE_ATTRIBUTE_IGNORE = 4;
-
 // Node or UIElement hash-to-varname reverse mapping
 VariantMap globalVarNames;
 bool inspectorLocked = false;
@@ -259,9 +254,6 @@ void UpdateAttributeInspector(bool fullUpdate = true)
     if (fullUpdate)
         DeleteAllContainers();
 
-    // Update all ScriptInstances/LuaScriptInstances
-    UpdateScriptInstances();
-
     if (!editNodes.empty)
     {
         UIElement@ container = GetNodeContainer();
@@ -395,61 +387,6 @@ void UpdateAttributeInspector(bool fullUpdate = true)
         HandleWindowLayoutUpdated();
 }
 
-void UpdateScriptInstances()
-{
-    Array<Component@>@ components = scene.GetComponents("ScriptInstance", true);
-    for (uint i = 0; i < components.length; i++)
-        UpdateScriptAttributes(components[i]);
-
-    components = scene.GetComponents("LuaScriptInstance", true);
-    for (uint i = 0; i < components.length; i++)
-        UpdateScriptAttributes(components[i]);
-}
-
-String GetComponentAttributeHash(Component@ component, uint index)
-{
-    // We won't consider the main attributes, as they won't reset when an error occurs.
-    if (component.typeName == "ScriptInstance")
-    {
-        if (index <= SCRIPTINSTANCE_ATTRIBUTE_IGNORE)
-            return "";
-    }
-    else
-    {
-        if (index <= LUASCRIPTINSTANCE_ATTRIBUTE_IGNORE)
-            return "";
-    }
-    AttributeInfo attributeInfo = component.attributeInfos[index];
-    Variant attribute = component.attributes[index];
-    return String(component.id) + "-" + attributeInfo.name + "-" + attribute.typeName;
-}
-
-void UpdateScriptAttributes(Component@ component)
-{
-    for (uint i = Min(SCRIPTINSTANCE_ATTRIBUTE_IGNORE, LUASCRIPTINSTANCE_ATTRIBUTE_IGNORE) + 1; i < component.numAttributes; i++)
-    {
-        Variant attribute = component.attributes[i];
-        // Component/node ID's are always unique within a scene, based on a simple increment.
-        // This makes for a simple method of mapping a components attributes unique and consistent.
-        // We will also use the type name in the hash to be able to recall and differentiate type changes.
-        String hash = GetComponentAttributeHash(component, i);
-        if (hash.empty)
-            continue;
-
-        if (!scriptAttributes.Contains(hash))
-        {
-            // set the initial value to the default value.
-            scriptAttributes[hash] = attribute;
-        }
-        else
-        {
-            // recall the previously stored value
-            component.attributes[i] = scriptAttributes[hash];
-        }
-    }
-    component.ApplyAttributes();
-}
-
 /// Update the attribute list of the node container.
 void UpdateNodeAttributes()
 {

+ 0 - 9
bin/Data/Scripts/Editor/EditorScene.as

@@ -83,9 +83,6 @@ bool ResetScene()
     }
     else
         messageBoxCallback = null;
-        
-    // Clear stored script attributes
-    scriptAttributes.Clear();
 
     suppressSceneChanges = true;
 
@@ -200,9 +197,6 @@ bool LoadScene(const String&in fileName)
         MessageBox("Could not open file.\n" + fileName);
         return false;
     }
-    
-    // Reset stored script attributes.
-    scriptAttributes.Clear();
 
     // Add the scene's resource path in case it's necessary
     String newScenePath = GetPath(fileName);
@@ -248,9 +242,6 @@ bool LoadScene(const String&in fileName)
     CreateGrid();
     SetActiveViewport(viewports[0]);
 
-    // Store all ScriptInstance and LuaScriptInstance attributes
-    UpdateScriptInstances();
-
     return loaded;
 }