Browse Source

Add break mode for prefabs

Josh Engebretson 9 years ago
parent
commit
922622f31d

+ 6 - 0
Resources/EditorData/AtomicEditor/editor/skin/skin.tb.txt

@@ -210,6 +210,12 @@ elements
 		min-width 140
 		max-width 140
 
+	InspectorPrefabTextAttrName
+		padding 4
+		text-color #aaaaaa
+		min-width 110
+		max-width 110
+
 	HierarchyPrefabText
 		text-color #11aaaa
 	HierarchyPrefabText.selected

+ 6 - 0
Resources/EditorData/AtomicEditor/editor/skin_light/skin.tb.txt

@@ -210,6 +210,12 @@ elements
 		min-width 140
 		max-width 140
 
+	InspectorPrefabTextAttrName
+		padding 4
+		text-color #2c2c2c
+		min-width 110
+		max-width 110
+
 	HierarchyPrefabText
 		text-color #2c2c2c
 	HierarchyPrefabText.selected

+ 12 - 21
Script/AtomicEditor/ui/frames/inspector/SelectionPrefabWidget.ts

@@ -20,6 +20,7 @@
 // THE SOFTWARE.
 //
 
+var breakMode = false;
 
 class SelectionPrefabWidget extends Atomic.UILayout {
 
@@ -44,7 +45,7 @@ class SelectionPrefabWidget extends Atomic.UILayout {
 
         var name = new Atomic.UITextField();
         name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
-        name.skinBg = "InspectorTextAttrName";
+        name.skinBg = "InspectorPrefabTextAttrName";
         name.text = "Prefab";
         name.fontDescription = fd;
 
@@ -70,32 +71,24 @@ class SelectionPrefabWidget extends Atomic.UILayout {
         };
 
         var breakButton = new Atomic.UIButton();
-        breakButton.text = "Break";
+        breakButton.text = "Edit Break";
+        breakButton.toggleMode = true;
+        breakButton.value = breakMode ? 1 : 0;
         breakButton.fontDescription = fd;
+        breakButton.tooltip  = "Remove prefab connection on edit";
 
         breakButton.onClick = () => {
-
-            this.node.scene.sendEvent("SceneEditPrefabBreak", {node : this.node});
+            breakMode = breakButton.value == 1 ? true : false;
             return true;
         };
 
-        var copyButton = new Atomic.UIButton();
-        copyButton.text = "Copy";
-        copyButton.fontDescription = fd;
-
-        copyButton.onClick = () => {
-            this.node.scene.sendEvent("SceneEditPrefabCopy", {node : this.node });
-            return true;
-        };
+        this.subscribeToEvent("SceneEditEnd", () => {
 
-        var pasteButton = new Atomic.UIButton();
-        pasteButton.text = "Paste";
-        pasteButton.fontDescription = fd;
+            if (breakMode && this.node) {
+                this.node.scene.sendEvent("SceneEditPrefabBreak", {node : this.node});
+            }
 
-        pasteButton.onClick = () => {
-            this.node.scene.sendEvent("SceneEditPrefabPaste", {node : this.node });
-            return true;
-        };
+        });
 
         var noticeName = new Atomic.UITextField();
         noticeName.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
@@ -116,8 +109,6 @@ class SelectionPrefabWidget extends Atomic.UILayout {
         widgetLayout.addChild(saveButton);
         widgetLayout.addChild(undoButton);
         widgetLayout.addChild(breakButton);
-        widgetLayout.addChild(copyButton);
-        widgetLayout.addChild(pasteButton);
 
         this.addChild(this.widgetLayout);
         this.addChild(this.noticeLayout);

+ 1 - 4
Source/AtomicNET/NETScript/CSComponent.cpp

@@ -52,11 +52,8 @@ void CSComponent::RegisterObject(Context* context)
 {
     context->RegisterFactory<CSComponent>(LOGIC_CATEGORY);
 
-    ATOMIC_ACCESSOR_ATTRIBUTE("Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
-
-    ATOMIC_ATTRIBUTE("FieldValues", VariantMap, fieldValues_, Variant::emptyVariantMap, AM_FILE);
-
     ATOMIC_ACCESSOR_ATTRIBUTE("Class", GetComponentClassName, SetComponentClassName, String, String::EMPTY, AM_DEFAULT);
+    ATOMIC_COPY_BASE_ATTRIBUTES(ScriptComponent);
 
 }