Josh Engebretson 10 years ago
parent
commit
c6125f91af

+ 3 - 0
Script/AtomicEditor/ui/inspector/ComponentInspector.ts

@@ -172,6 +172,8 @@ class ComponentInspector extends Atomic.UISection {
 
     addJSComponentUI(layout:Atomic.UILayout) {
 
+      var js = <Atomic.JSComponent> this.component;
+
       // expand prefab
       this.value = 1;
 
@@ -190,6 +192,7 @@ class ComponentInspector extends Atomic.UISection {
 
       var field = InspectorUtils.createAttrEditField("Script", layout);
       field.readOnly = true;
+      field.text = js.componentFile ? js.componentFile.name : "";
 
       layout.addChild(selectButton);
 

+ 11 - 0
Script/TypeScript/Atomic.d.ts

@@ -8014,12 +8014,14 @@ declare module Atomic {
 
    export class JSComponent extends Component {
 
+      componentFile: JSComponentFile;
       updateEventMask: number;
 
       // Construct.
       constructor();
 
       applyAttributes(): void;
+      getComponentFile(): JSComponentFile;
       // Handle enabled/disabled state change. Changes update event subscription.
       onSetEnabled(): void;
       // Set what update events should be subscribed to. Use this for optimization: by default all are in use. Note that this is not an attribute and is not saved or network-serialized, therefore it should always be called eg. in the subclass constructor.
@@ -8028,6 +8030,15 @@ declare module Atomic {
       getUpdateEventMask(): number;
       // Return whether the DelayedStart() function has been called.
       isDelayedStartCalled(): boolean;
+      setComponentFile(cfile: JSComponentFile, loading?: boolean): void;
+
+   }
+
+   export class JSComponentFile extends Resource {
+
+      // Construct.
+      constructor();
+
 
    }
 

+ 1 - 4
Source/AtomicEditorWork/Editors/SceneEditor3D/SceneEditor3D.cpp

@@ -124,7 +124,7 @@ bool SceneEditor3D::OnEvent(const TBWidgetEvent &ev)
         {
             if (selectedNode_.NotNull())
             {
-                clipboardNode_ = selectedNode_->Clone();
+                clipboardNode_ = selectedNode_;
             }
         }
         else if (ev.ref_id == TBIDC("paste"))
@@ -132,15 +132,12 @@ bool SceneEditor3D::OnEvent(const TBWidgetEvent &ev)
             if (clipboardNode_.NotNull() && selectedNode_.NotNull())
             {
                 SharedPtr<Node> pasteNode(clipboardNode_->Clone());
-                selectedNode_->GetParent()->AddChild(pasteNode);
 
                 VariantMap eventData;
                 eventData[EditorActiveNodeChange::P_NODE] = pasteNode;
                 SendEvent(E_EDITORACTIVENODECHANGE, eventData);
-
             }
         }
-
     }
 
     if (ev.type == EVENT_TYPE_CLICK)

+ 2 - 2
Source/AtomicJS/Javascript/JSSceneSerializable.cpp

@@ -203,8 +203,8 @@ static int Serializable_GetAttributes(duk_context* ctx)
     duk_get_global_string(ctx, "__atomic_scene_serializable_attributes");
     duk_get_prop_index(ctx, -1, type);
 
-    // return cached array of attrinfo
-    if (duk_is_object(ctx, -1))
+    // return cached array of attrinfo, unless JSComponent which has dynamic fields
+    if (serial->GetType() != JSComponent::GetTypeStatic() && duk_is_object(ctx, -1))
         return 1;
 
     const Vector<AttributeInfo>* attrs = serial->GetAttributes();

+ 1 - 1
Source/AtomicJS/Packages/Atomic/Javascript.json

@@ -1,5 +1,5 @@
 {
 	"name" : "Javascript",
 	"sources" : ["Source/AtomicJS/Javascript"],
-	"classes" : ["JSVM", "JSComponent", "JSMetrics", "JSEventHelper", "ScriptObject"]
+	"classes" : ["JSVM", "JSComponent", "JSComponentFile", "JSMetrics", "JSEventHelper", "ScriptObject"]
 }