Browse Source

Don't check for unsaved changes in SceneEditor yet, some fixes and clean up

rsredsq 10 years ago
parent
commit
0fd9e767ff

+ 4 - 0
Script/AtomicEditor/ui/EditorUI.ts

@@ -48,6 +48,10 @@ export function showModalError(windowText:string, message:string) {
   editorUI.showModalError(windowText, message);
   editorUI.showModalError(windowText, message);
 }
 }
 
 
+export function getCurrentResourceEditor():Editor.ResourceEditor {
+    return getMainFrame().resourceframe.currentResourceEditor;
+}
+
 
 
 class EditorUI extends Atomic.ScriptObject {
 class EditorUI extends Atomic.ScriptObject {
 
 

+ 10 - 10
Script/AtomicEditor/ui/frames/HierarchyFrame.ts

@@ -68,10 +68,10 @@ class HierarchyFrame extends Atomic.UIWidget {
 
 
         this.subscribeToEvent("ComponentAdded", (ev: Atomic.ComponentAddedEvent) => {
         this.subscribeToEvent("ComponentAdded", (ev: Atomic.ComponentAddedEvent) => {
 
 
-            var resourceEditor = EditorUI.getMainFrame().resourceframe.currentResourceEditor;
-            if (resourceEditor) {
-                resourceEditor.setModified(true);
-            }
+            //var resourceEditor = EditorUI.getCurrentResourceEditor();
+            //if (resourceEditor) {
+            //    resourceEditor.setModified(true);
+            //}
 
 
             if (!ev.component || ev.component.typeName != "PrefabComponent") return;
             if (!ev.component || ev.component.typeName != "PrefabComponent") return;
 
 
@@ -89,10 +89,10 @@ class HierarchyFrame extends Atomic.UIWidget {
 
 
         this.subscribeToEvent("ComponentRemoved", (ev: Atomic.ComponentRemovedEvent) => {
         this.subscribeToEvent("ComponentRemoved", (ev: Atomic.ComponentRemovedEvent) => {
 
 
-            var resourceEditor = EditorUI.getMainFrame().resourceframe.currentResourceEditor;
-            if (resourceEditor) {
-                resourceEditor.setModified(true);
-            }
+            //var resourceEditor = EditorUI.getCurrentResourceEditor();
+            //if (resourceEditor) {
+            //    resourceEditor.setModified(true);
+            //}
 
 
             if (!ev.component || ev.component.typeName != "PrefabComponent") return;
             if (!ev.component || ev.component.typeName != "PrefabComponent") return;
 
 
@@ -142,7 +142,7 @@ class HierarchyFrame extends Atomic.UIWidget {
         if (!node.parent || node.scene != this.scene)
         if (!node.parent || node.scene != this.scene)
             return;
             return;
 
 
-        EditorUI.getMainFrame().resourceframe.currentResourceEditor.setModified(true);
+        //EditorUI.getCurrentResourceEditor().setModified(true);
 
 
         var parentID = this.nodeIDToItemID[node.parent.id];
         var parentID = this.nodeIDToItemID[node.parent.id];
 
 
@@ -158,7 +158,7 @@ class HierarchyFrame extends Atomic.UIWidget {
         if (!this.scene)
         if (!this.scene)
             return;
             return;
 
 
-        EditorUI.getMainFrame().resourceframe.currentResourceEditor.setModified(true);
+        //EditorUI.getCurrentResourceEditor().setModified(true);
 
 
         var node = ev.node;
         var node = ev.node;
 
 

+ 0 - 1
Script/AtomicEditor/ui/frames/inspector/ComponentInspector.ts

@@ -211,7 +211,6 @@ class ComponentInspector extends Atomic.UISection {
 
 
             // refresh entire inspector, fix this...
             // refresh entire inspector, fix this...
             this.sendEvent("EditorActiveNodeChange", { node: node });
             this.sendEvent("EditorActiveNodeChange", { node: node });
-            this.sendEvent("ComponentRemoved");
             
             
             return true;
             return true;
 
 

+ 0 - 1
Script/AtomicEditor/ui/frames/inspector/CreateComponentButton.ts

@@ -138,7 +138,6 @@ class CreateComponentButton extends Atomic.UIButton {
 
 
               this.parent.addChildRelative(ci, Atomic.UI_WIDGET_Z_REL_BEFORE, this);
               this.parent.addChildRelative(ci, Atomic.UI_WIDGET_Z_REL_BEFORE, this);
 
 
-              this.sendEvent("ComponentAdded");
             }
             }
 
 
             return true;
             return true;

+ 1 - 1
Script/AtomicEditor/ui/frames/inspector/DataBinding.ts

@@ -479,7 +479,7 @@ class DataBinding {
 
 
         if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
         if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
             if (this.widget == ev.target || this.widget.isAncestorOf(ev.target)) {
             if (this.widget == ev.target || this.widget.isAncestorOf(ev.target)) {
-                EditorUI.getMainFrame().resourceframe.currentResourceEditor.setModified(true);
+                //EditorUI.getCurrentResourceEditor().setModified(true);
                 this.setObjectValueFromWidget(ev.target);
                 this.setObjectValueFromWidget(ev.target);
                 return true;
                 return true;
             }
             }

+ 2 - 6
Source/AtomicEditor/Editors/JSResourceEditor.cpp

@@ -222,9 +222,7 @@ void JSResourceEditor::OnChange(TBStyleEdit* styleEdit)
     textDirty_ = true;
     textDirty_ = true;
     modified_ = true;
     modified_ = true;
 
 
-    String filename = GetFileNameAndExtension(fullpath_);
-    filename += "*";
-    button_->SetText(filename.CString());
+    SetModified(true);
 
 
     autocomplete_->Hide();
     autocomplete_->Hide();
 
 
@@ -584,9 +582,7 @@ bool JSResourceEditor::Save()
     file.Write((void*) text.CStr(), text.Length());
     file.Write((void*) text.CStr(), text.Length());
     file.Close();
     file.Close();
 
 
-    String filename = GetFileNameAndExtension(fullpath_);
-    button_->SetText(filename.CString());
-    modified_ = false;
+    SetModified(false);
 
 
     return true;
     return true;
 
 

+ 17 - 1
Source/AtomicEditor/Editors/ResourceEditor.cpp

@@ -43,11 +43,12 @@ public:
             settings.dimmer = true;
             settings.dimmer = true;
             settings.styling = true;
             settings.styling = true;
             msg_win->Show("Unsaved Modifications", "There are unsaved modifications.\nDo you wish to discard them and close?", &settings, 640, 360);
             msg_win->Show("Unsaved Modifications", "There are unsaved modifications.\nDo you wish to discard them and close?", &settings, 640, 360);
+            return false;
         }
         }
         else
         else
         {
         {
             editor_->Close();
             editor_->Close();
-            return false;
+            return true;
         }
         }
     }
     }
 
 
@@ -171,4 +172,19 @@ void ResourceEditor::InvokeShortcut(const String& shortcut)
     OnEvent(ev);
     OnEvent(ev);
 }
 }
 
 
+void ResourceEditor::SetModified(bool modified)
+{
+    if (modified)
+    {
+        String filename = GetFileNameAndExtension(fullpath_);
+        filename += "*";
+        button_->SetText(filename.CString());
+    }
+    else
+    {
+        String filename = GetFileNameAndExtension(fullpath_);
+        button_->SetText(filename.CString());
+    }
+}
+
 }
 }

+ 1 - 1
Source/AtomicEditor/Editors/ResourceEditor.h

@@ -54,7 +54,7 @@ public:
 
 
     void RequestClose();
     void RequestClose();
 
 
-    virtual void SetModified(bool modified) { modified_ = modified; };
+    void SetModified(bool modified);
 
 
 protected:
 protected:
 
 

+ 3 - 19
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3D.cpp

@@ -142,7 +142,9 @@ bool SceneEditor3D::OnEvent(const TBWidgetEvent &ev)
         } 
         } 
         else if (ev.ref_id == TBIDC("close"))
         else if (ev.ref_id == TBIDC("close"))
         {
         {
-            RequestClose();
+            //Don't check for unsaved changes yet
+            Close();
+            //RequestClose();
         }
         }
     }
     }
 
 
@@ -261,22 +263,4 @@ bool SceneEditor3D::Save()
 
 
 }
 }
 
 
-void SceneEditor3D::SetModified(bool modified)
-{
-    ResourceEditor::SetModified(modified);
-
-    if (modified)
-    {
-        String filename = GetFileNameAndExtension(fullpath_);
-        filename += "*";
-        button_->SetText(filename.CString());
-    }
-    else
-    {
-        String filename = GetFileNameAndExtension(fullpath_);
-        button_->SetText(filename.CString());
-    }
-
-}
-
 }
 }

+ 0 - 2
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3D.h

@@ -54,8 +54,6 @@ public:
     void Close(bool navigateToAvailableResource = true);
     void Close(bool navigateToAvailableResource = true);
     bool Save();
     bool Save();
 
 
-    void SetModified(bool modified);
-
 private:
 private:
 
 
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
     void HandleUpdate(StringHash eventType, VariantMap& eventData);