Browse Source

Adding Snap Settings

Josh Engebretson 10 years ago
parent
commit
0a38b1f725

+ 30 - 0
Resources/EditorData/AtomicEditor/editor/ui/snapsettings.tb.txt

@@ -0,0 +1,30 @@
+TBLayout: axis: y, distribution: gravity, position: left
+	TBLayout: distribution: gravity
+		TBTextField: text: "Translate X:"
+		TBLayout: gravity: left right, distribution-position: right bottom
+			TBEditField: id: trans_x, autofocus: 1, text-align: center
+				lp: min-width: 100
+	TBLayout: distribution: gravity
+		TBTextField: text: "Translate Y:"
+		TBLayout: gravity: left right, distribution-position: right bottom
+			TBEditField: id: trans_y, text-align: center
+				lp: min-width: 100
+	TBLayout: distribution: gravity
+		TBTextField: text: "Translate Z:"
+		TBLayout: gravity: left right, distribution-position: right bottom
+			TBEditField: id: trans_z, text-align: center
+				lp: min-width: 100
+	TBLayout: distribution: gravity
+		TBTextField: text: "Rotation:"
+		TBLayout: gravity: left right, distribution-position: right bottom
+			TBEditField: id: rotation, text-align: center
+				lp: min-width: 100
+	TBLayout: distribution: gravity
+		TBTextField: text: "Scale:"
+		TBLayout: gravity: left right, distribution-position: right bottom
+			TBEditField: id: scale, text-align: center
+				lp: min-width: 100
+	TBSeparator: gravity: left right, skin: AESeparator
+	TBLayout: 
+		TBButton: text: Apply, id: apply
+		TBButton: text: Cancel, id: cancel

+ 8 - 1
Script/AtomicEditor/ui/frames/menus/MainFrameMenu.ts

@@ -98,6 +98,11 @@ class MainFrameMenu extends Atomic.ScriptObject {
                 return true;
             }
 
+            if (refid == "edit snap settings") {
+                EditorUI.getModelOps().showSnapSettings();
+                return true;
+            }
+
             return false;
 
         } else if (target.id == "menu file popup") {
@@ -250,7 +255,9 @@ var editItems = {
     "Format Code": ["edit format code", StringID.ShortcutBeautify],
     "-4": null,
     "Play": ["edit play", StringID.ShortcutPlay],
-    "Debug (C# Project)": ["edit play debug", StringID.ShortcutPlayDebug]
+    "Debug (C# Project)": ["edit play debug", StringID.ShortcutPlayDebug],
+    "-5": null,
+    "Snap Settings": ["edit snap settings"]
 
 };
 

+ 16 - 0
Script/AtomicEditor/ui/modal/ModalOps.ts

@@ -26,6 +26,8 @@ import ResourceSelection = require("./ResourceSelection");
 
 import UIResourceOps = require("./UIResourceOps");
 
+import SnapSettingsWindow = require("./SnapSettingsWindow");
+
 class ModalOps extends Atomic.ScriptObject {
 
     constructor() {
@@ -246,6 +248,20 @@ class ModalOps extends Atomic.ScriptObject {
 
     }
 
+    showSnapSettings() {
+
+        // only show snap settings if we have a project loaded
+        if (!ToolCore.toolSystem.project)
+          return;
+
+        if (this.show()) {
+
+            this.opWindow = new SnapSettingsWindow();
+
+        }
+
+    }
+
     private show(): boolean {
 
         if (this.dimmer.parent) {

+ 79 - 0
Script/AtomicEditor/ui/modal/SnapSettingsWindow.ts

@@ -0,0 +1,79 @@
+import ModalWindow = require("./ModalWindow");
+
+class SnapSettingsWindow extends ModalWindow {
+
+    constructor() {
+
+        super();
+
+        this.init("Snap Settings", "AtomicEditor/editor/ui/snapsettings.tb.txt");
+
+        this.transXEditField = <Atomic.UIEditField>this.getWidget("trans_x");
+        this.transYEditField = <Atomic.UIEditField>this.getWidget("trans_y");
+        this.transZEditField = <Atomic.UIEditField>this.getWidget("trans_z");
+        this.rotateEditField = <Atomic.UIEditField>this.getWidget("rotation");
+        this.scaleEditField = <Atomic.UIEditField>this.getWidget("scale");
+
+        this.refreshWidgets();
+
+    }
+
+    apply() {
+
+        var userPrefs = ToolCore.toolSystem.project.userPrefs;
+        userPrefs.snapTranslationX = Number(this.transXEditField.text);
+        userPrefs.snapTranslationY = Number(this.transYEditField.text);
+        userPrefs.snapTranslationZ = Number(this.transZEditField.text);
+        userPrefs.snapRotation = Number(this.rotateEditField.text);
+        userPrefs.snapScale = Number(this.scaleEditField.text);
+
+        ToolCore.toolSystem.project.saveUserPrefs();
+
+    }
+
+    refreshWidgets() {
+
+        var userPrefs = ToolCore.toolSystem.project.userPrefs;
+
+        this.transXEditField.text = parseFloat(userPrefs.snapTranslationX.toFixed(5)).toString();
+        this.transYEditField.text = parseFloat(userPrefs.snapTranslationY.toFixed(5)).toString();
+        this.transZEditField.text = parseFloat(userPrefs.snapTranslationZ.toFixed(5)).toString();
+        this.rotateEditField.text = parseFloat(userPrefs.snapRotation.toFixed(5)).toString();
+        this.scaleEditField.text = parseFloat(userPrefs.snapScale.toFixed(5)).toString();
+
+    }
+
+    handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
+
+        if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
+
+            var id = ev.target.id;
+
+            if (id == "apply") {
+
+                this.apply();
+                this.hide();
+                return true;
+
+            }
+
+            if (id == "cancel") {
+
+                this.hide();
+
+                return true;
+            }
+
+        }
+
+    }
+
+    transXEditField: Atomic.UIEditField;
+    transYEditField: Atomic.UIEditField;
+    transZEditField: Atomic.UIEditField;
+    rotateEditField: Atomic.UIEditField;
+    scaleEditField: Atomic.UIEditField;
+
+}
+
+export = SnapSettingsWindow;

+ 1 - 0
Script/tsconfig.json

@@ -71,6 +71,7 @@
         "./AtomicEditor/ui/modal/NewProject.ts",
         "./AtomicEditor/ui/modal/ProgressModal.ts",
         "./AtomicEditor/ui/modal/ResourceSelection.ts",
+        "./AtomicEditor/ui/modal/SnapSettingsWindow.ts",
         "./AtomicEditor/ui/modal/UIResourceOps.ts",
         "./AtomicEditor/ui/playmode/PlayerOutput.ts",
         "./AtomicEditor/ui/playmode/PlayMode.ts",

+ 96 - 25
Source/AtomicEditor/Editors/SceneEditor3D/Gizmo3D.cpp

@@ -230,19 +230,27 @@ bool Gizmo3D::MoveEditNodes(Vector3 adjust)
 {
     bool moved = false;
 
+    Input* input = GetSubsystem<Input>();
+
+#ifdef ATOMIC_PLATFORM_OSX
+    bool moveSnap = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#else
+    bool moveSnap = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#endif
+
     if (adjust.Length() > M_EPSILON)
     {
         for (unsigned i = 0; i < editNodes_->Size(); ++i)
         {
-            /*
             if (moveSnap)
             {
-                float moveStepScaled = moveStep * snapScale;
-                adjust.x = Floor(adjust.x / moveStepScaled + 0.5) * moveStepScaled;
-                adjust.y = Floor(adjust.y / moveStepScaled + 0.5) * moveStepScaled;
-                adjust.z = Floor(adjust.z / moveStepScaled + 0.5) * moveStepScaled;
+                float moveStepScaled = snapTranslationX_;
+                adjust.x_ = floorf(adjust.x_ / moveStepScaled + 0.5) * moveStepScaled;
+                moveStepScaled = snapTranslationY_;
+                adjust.y_ = floorf(adjust.y_ / moveStepScaled + 0.5) * moveStepScaled;
+                moveStepScaled = snapTranslationZ_;
+                adjust.z_ = floorf(adjust.z_ / moveStepScaled + 0.5) * moveStepScaled;
             }
-            */
 
             Node* node = editNodes_->At(i);
             Vector3 nodeAdjust = adjust;
@@ -273,15 +281,21 @@ bool Gizmo3D::RotateEditNodes(Vector3 adjust)
 {
     bool moved = false;
 
-    /*
+    Input* input = GetSubsystem<Input>();
+
+#ifdef ATOMIC_PLATFORM_OSX
+    bool rotateSnap = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#else
+    bool rotateSnap = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#endif
+
     if (rotateSnap)
     {
-        float rotateStepScaled = rotateStep * snapScale;
-        adjust.x = Floor(adjust.x / rotateStepScaled + 0.5) * rotateStepScaled;
-        adjust.y = Floor(adjust.y / rotateStepScaled + 0.5) * rotateStepScaled;
-        adjust.z = Floor(adjust.z / rotateStepScaled + 0.5) * rotateStepScaled;
+        float rotateStepScaled = snapRotation_;
+        adjust.x_ = floorf(adjust.x_ / rotateStepScaled + 0.5) * rotateStepScaled;
+        adjust.y_ = floorf(adjust.y_ / rotateStepScaled + 0.5) * rotateStepScaled;
+        adjust.z_ = floorf(adjust.z_ / rotateStepScaled + 0.5) * rotateStepScaled;
     }
-    */
 
     if (adjust.Length() > M_EPSILON)
     {
@@ -314,6 +328,15 @@ bool Gizmo3D::ScaleEditNodes(Vector3 adjust)
 {
     bool moved = false;
 
+    Input* input = GetSubsystem<Input>();
+
+#ifdef ATOMIC_PLATFORM_OSX
+    bool scaleSnap = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#else
+    bool scaleSnap = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#endif
+
+
     if (adjust.Length() > M_EPSILON)
     {
         for (unsigned i = 0; i < editNodes_->Size(); ++i)
@@ -323,28 +346,26 @@ bool Gizmo3D::ScaleEditNodes(Vector3 adjust)
             Vector3 scale = node->GetScale();
             Vector3 oldScale = scale;
 
-            if (true)//!scaleSnap)
+            if (!scaleSnap)
                 scale += adjust;
             else
             {
-                /*
-                float scaleStepScaled = scaleStep * snapScale;
-                if (adjust.x != 0)
+                float scaleStepScaled = snapScale_;
+                if (adjust.x_ != 0)
                 {
-                    scale.x += adjust.x * scaleStepScaled;
-                    scale.x = Floor(scale.x / scaleStepScaled + 0.5) * scaleStepScaled;
+                    scale.x_ += adjust.x_ * scaleStepScaled;
+                    scale.x_ = floorf(scale.x_ / scaleStepScaled + 0.5) * scaleStepScaled;
                 }
-                if (adjust.y != 0)
+                if (adjust.y_ != 0)
                 {
-                    scale.y += adjust.y * scaleStepScaled;
-                    scale.y = Floor(scale.y / scaleStepScaled + 0.5) * scaleStepScaled;
+                    scale.y_ += adjust.y_ * scaleStepScaled;
+                    scale.y_ = floorf(scale.y_ / scaleStepScaled + 0.5) * scaleStepScaled;
                 }
-                if (adjust.z != 0)
+                if (adjust.z_ != 0)
                 {
-                    scale.z += adjust.z * scaleStepScaled;
-                    scale.z = Floor(scale.z / scaleStepScaled + 0.5) * scaleStepScaled;
+                    scale.z_ += adjust.z_ * scaleStepScaled;
+                    scale.z_ = floorf(scale.z_ / scaleStepScaled + 0.5) * scaleStepScaled;
                 }
-                */
             }
 
             if (scale != oldScale)
@@ -461,4 +482,54 @@ void Gizmo3D::Show()
 
 }
 
+float Gizmo3D::GetSnapTranslationX() const
+{
+    return snapTranslationX_;
+}
+
+float Gizmo3D::GetSnapTranslationY() const
+{
+    return snapTranslationY_;
+}
+
+float Gizmo3D::GetSnapTranslationZ() const
+{
+    return snapTranslationZ_;
+}
+
+float Gizmo3D::GetSnapRotation() const
+{
+    return snapRotation_;
+}
+
+float Gizmo3D::GetSnapScale() const
+{
+    return snapScale_;
+}
+
+void Gizmo3D::SetSnapTranslationX(float value)
+{
+    snapTranslationX_ = value;
+}
+
+void Gizmo3D::SetSnapTranslationY(float value)
+{
+    snapTranslationY_ = value;
+}
+
+void Gizmo3D::SetSnapTranslationZ(float value)
+{
+    snapTranslationZ_ = value;
+}
+
+void Gizmo3D::SetSnapRotation(float value)
+{
+    snapRotation_ = value;
+}
+
+void Gizmo3D::SetSnapScale(float value)
+{
+    snapScale_ = value;
+}
+
 }

+ 18 - 0
Source/AtomicEditor/Editors/SceneEditor3D/Gizmo3D.h

@@ -125,6 +125,18 @@ public:
 
     Node* GetGizmoNode() { return gizmoNode_; }
 
+    float GetSnapTranslationX() const;
+    float GetSnapTranslationY() const;
+    float GetSnapTranslationZ() const;
+    float GetSnapRotation() const;
+    float GetSnapScale() const;
+
+    void SetSnapTranslationX(float value);
+    void SetSnapTranslationY(float value);
+    void SetSnapTranslationZ(float value);
+    void SetSnapRotation(float value);
+    void SetSnapScale(float value);
+
 private:
 
     void Position();
@@ -156,6 +168,12 @@ private:
     Vector<Node *> *editNodes_;
     bool dragging_;
 
+    float snapTranslationX_;
+    float snapTranslationY_;
+    float snapTranslationZ_;
+    float snapRotation_;
+    float snapScale_;
+
 };
 
 }

+ 29 - 0
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3D.cpp

@@ -23,9 +23,14 @@
 #include <Atomic/Input/Input.h>
 #include <Atomic/UI/UI.h>
 
+#include <ToolCore/ToolSystem.h>
+#include <ToolCore/Project/Project.h>
+#include <ToolCore/Project/ProjectEvents.h>
+#include <ToolCore/Project/ProjectUserPrefs.h>
 #include <ToolCore/Assets/AssetDatabase.h>
 #include <ToolCore/Assets/Asset.h>
 
+
 #include "../../EditorMode/AEEditorEvents.h"
 
 #include "SceneEditor3D.h"
@@ -40,6 +45,12 @@ namespace AtomicEditor
 SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, UITabContainer *container) :
     ResourceEditor(context, fullpath, container)
 {
+
+    // store a local reference to user project prefs
+    ToolSystem* tsystem = GetSubsystem<ToolSystem>();
+    Project* project = tsystem->GetProject();
+    userPrefs_ = project->GetUserPrefs();
+
     ResourceCache* cache = GetSubsystem<ResourceCache>();
 
     scene_ = new Scene(context_);
@@ -81,6 +92,7 @@ SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, UITabCon
     gizmo3D_ = new Gizmo3D(context_);
     gizmo3D_->SetView(sceneView_);
     gizmo3D_->Show();
+    UpdateGizmoSnapSettings();
 
     SubscribeToEvent(E_UPDATE, HANDLER(SceneEditor3D, HandleUpdate));
     SubscribeToEvent(E_EDITORACTIVENODECHANGE, HANDLER(SceneEditor3D, HandleEditorActiveNodeChange));
@@ -93,6 +105,8 @@ SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, UITabCon
     IntRect rect = container_->GetContentRoot()->GetRect();
     rootContentWidget_->SetSize(rect.Width(), rect.Height());
 
+    SubscribeToEvent(E_PROJECTUSERPREFSAVED, HANDLER(SceneEditor3D, HandleUserPrefSaved));
+
     SubscribeToEvent(E_EDITORPLAYSTARTED, HANDLER(SceneEditor3D, HandlePlayStarted));
     SubscribeToEvent(E_EDITORPLAYSTOPPED, HANDLER(SceneEditor3D, HandlePlayStopped));
 
@@ -322,6 +336,11 @@ void SceneEditor3D::HandleSceneEditSceneModified(StringHash eventType, VariantMa
     SetModified(true);    
 }
 
+void SceneEditor3D::HandleUserPrefSaved(StringHash eventType, VariantMap& eventData)
+{
+    UpdateGizmoSnapSettings();
+}
+
 void SceneEditor3D::GetSelectionBoundingBox(BoundingBox& bbox)
 {
     bbox.Clear();
@@ -350,4 +369,14 @@ void SceneEditor3D::GetSelectionBoundingBox(BoundingBox& bbox)
 
 }
 
+void SceneEditor3D::UpdateGizmoSnapSettings()
+{
+    gizmo3D_->SetSnapTranslationX(userPrefs_->GetSnapTranslationX());
+    gizmo3D_->SetSnapTranslationY(userPrefs_->GetSnapTranslationY());
+    gizmo3D_->SetSnapTranslationZ(userPrefs_->GetSnapTranslationZ());
+    gizmo3D_->SetSnapRotation(userPrefs_->GetSnapRotation());
+    gizmo3D_->SetSnapScale(userPrefs_->GetSnapScale());
+
+}
+
 }

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

@@ -27,6 +27,13 @@ class Octree;
 
 }
 
+namespace ToolCore
+{
+    class ProjectUserPrefs;
+}
+
+using namespace ToolCore;
+
 namespace AtomicEditor
 {
 
@@ -60,6 +67,8 @@ public:
     void Undo();
     void Redo();
 
+    ProjectUserPrefs* GetUserPrefs();
+
 private:
 
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
@@ -69,11 +78,15 @@ private:
     void HandleGizmoEditModeChanged(StringHash eventType, VariantMap& eventData);
     void HandleGizmoAxisModeChanged(StringHash eventType, VariantMap& eventData);
 
+    void HandleUserPrefSaved(StringHash eventType, VariantMap& eventData);
+
     void HandleNodeAdded(StringHash eventType, VariantMap& eventData);
     void HandleNodeRemoved(StringHash eventType, VariantMap& eventData);
 
     void HandleSceneEditSceneModified(StringHash eventType, VariantMap& eventData);
 
+    void UpdateGizmoSnapSettings();
+
     SharedPtr<Scene> scene_;
 
     // TODO: multiple views
@@ -86,6 +99,8 @@ private:
 
     SharedPtr<SceneEditHistory> editHistory_;
 
+    WeakPtr<ProjectUserPrefs> userPrefs_;
+
 };
 
 }

+ 7 - 0
Source/ThirdParty/TurboBadger/tb_widgets_reader.cpp

@@ -188,6 +188,13 @@ void TBEditField::OnInflate(const INFLATE_INFO &info)
 		else if (stristr(type, "url"))		SetEditType(EDIT_TYPE_URL);
 		else if (stristr(type, "number"))	SetEditType(EDIT_TYPE_NUMBER);
 	}
+    if (const char *text_align = info.node->GetValueString("text-align", nullptr))
+    {
+        if (!strcmp(text_align, "left"))		SetTextAlign(TB_TEXT_ALIGN_LEFT);
+        else if (!strcmp(text_align, "center"))	SetTextAlign(TB_TEXT_ALIGN_CENTER);
+        else if (!strcmp(text_align, "right"))	SetTextAlign(TB_TEXT_ALIGN_RIGHT);
+    }
+
 	TBWidget::OnInflate(info);
 }
 

+ 1 - 0
Source/ToolCore/Assets/AssetDatabase.cpp

@@ -18,6 +18,7 @@
 #include "../ToolEvents.h"
 #include "../ToolSystem.h"
 #include "../Project/Project.h"
+#include "../Project/ProjectEvents.h"
 #include "AssetEvents.h"
 #include "AssetDatabase.h"
 

+ 1 - 1
Source/ToolCore/NETTools/NETToolSystem.cpp

@@ -9,7 +9,7 @@
 #include <Atomic/IO/FileSystem.h>
 #include <AtomicNET/NETCore/NETCore.h>
 
-#include "../ToolEvents.h"
+#include "../Project/ProjectEvents.h"
 #include "../ToolEnvironment.h"
 
 #include "NETToolSystem.h"

+ 1 - 0
Source/ToolCore/Project/Project.cpp

@@ -18,6 +18,7 @@
 #include "../ToolEvents.h"
 #include "../Platform/Platform.h"
 
+#include "ProjectEvents.h"
 #include "ProjectFile.h"
 #include "ProjectBuildSettings.h"
 #include "ProjectUserPrefs.h"

+ 32 - 0
Source/ToolCore/Project/ProjectEvents.h

@@ -0,0 +1,32 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+// LICENSE: Atomic Game Engine Editor and Tools EULA
+// Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
+// license information: https://github.com/AtomicGameEngine/AtomicGameEngine
+//
+
+#pragma once
+
+#include <Atomic/Core/Object.h>
+
+using namespace Atomic;
+
+namespace ToolCore
+{
+
+EVENT(E_PROJECTLOADED, ProjectLoaded)
+{
+    PARAM(P_PROJECTPATH, ProjectPath);    // string
+}
+
+EVENT(E_PROJECTUNLOADED, ProjectUnloaded)
+{
+}
+
+EVENT(E_PROJECTUSERPREFSAVED, ProjectUserPrefSaved)
+{
+    PARAM(P_PREFS, Prefs);    // ProjectUserPrefs
+}
+
+
+}

+ 82 - 1
Source/ToolCore/Project/ProjectUserPrefs.cpp

@@ -5,6 +5,7 @@
 // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
 //
 
+#include "ProjectEvents.h"
 #include "ProjectUserPrefs.h"
 
 #include <Atomic/IO/File.h>
@@ -13,7 +14,13 @@
 namespace ToolCore
 {
 
-ProjectUserPrefs::ProjectUserPrefs(Context* context) : Object(context)
+ProjectUserPrefs::ProjectUserPrefs(Context* context) : Object(context),
+  snapTranslationX_(1.0f),
+  snapTranslationY_(1.0f),
+  snapTranslationZ_(1.0f),
+  snapRotation_(15.0f),
+  snapScale_(0.1f)
+
 {
 #ifdef ATOMIC_PLATFORM_OSX
     defaultPlatform_ = PLATFORMID_MAC;
@@ -27,6 +34,56 @@ ProjectUserPrefs::~ProjectUserPrefs()
 
 }
 
+float ProjectUserPrefs::GetSnapTranslationX() const
+{
+    return snapTranslationX_;
+}
+
+float ProjectUserPrefs::GetSnapTranslationY() const
+{
+    return snapTranslationY_;
+}
+
+float ProjectUserPrefs::GetSnapTranslationZ() const
+{
+    return snapTranslationZ_;
+}
+
+float ProjectUserPrefs::GetSnapRotation() const
+{
+    return snapRotation_;
+}
+
+float ProjectUserPrefs::GetSnapScale() const
+{
+    return snapScale_;
+}
+
+void ProjectUserPrefs::SetSnapTranslationX(float value)
+{
+    snapTranslationX_ = value;
+}
+
+void ProjectUserPrefs::SetSnapTranslationY(float value)
+{
+    snapTranslationY_ = value;
+}
+
+void ProjectUserPrefs::SetSnapTranslationZ(float value)
+{
+    snapTranslationZ_ = value;
+}
+
+void ProjectUserPrefs::SetSnapRotation(float value)
+{
+    snapRotation_ = value;
+}
+
+void ProjectUserPrefs::SetSnapScale(float value)
+{
+    snapScale_ = value;
+}
+
 bool ProjectUserPrefs::Load(const String& path)
 {
     SharedPtr<File> file(new File(context_, path));
@@ -46,6 +103,19 @@ bool ProjectUserPrefs::Load(const String& path)
 
     lastBuildPath_ = root.Get("lastBuildPath").GetString();
 
+    if (root.Contains("snapTransX"))
+        SetSnapTranslationX(root.Get("snapTransX").GetFloat());
+    if (root.Contains("snapTransY"))
+        SetSnapTranslationY(root.Get("snapTransY").GetFloat());
+    if (root.Contains("snapTransZ"))
+        SetSnapTranslationZ(root.Get("snapTransZ").GetFloat());
+
+    if (root.Contains("snapRotation"))
+        SetSnapRotation(root.Get("snapRotation").GetFloat());
+
+    if (root.Contains("snapScale"))
+        SetSnapScale(root.Get("snapScale").GetFloat());
+
     return true;
 }
 
@@ -60,10 +130,21 @@ void ProjectUserPrefs::Save(const String& path)
 
     root.Set("lastBuildPath", lastBuildPath_);
 
+    // Snap settings
+    root.Set("snapTransX", snapTranslationX_);
+    root.Set("snapTransY", snapTranslationY_);
+    root.Set("snapTransZ", snapTranslationZ_);
+    root.Set("snapRotation", snapRotation_);
+    root.Set("snapScale", snapScale_);
+
     jsonFile->Save(*file, String("   "));
 
     file->Close();
 
+    VariantMap evData;
+    evData[ProjectUserPrefSaved::P_PREFS] = this;
+    SendEvent(E_PROJECTUSERPREFSAVED);
+
 
 }
 

+ 18 - 0
Source/ToolCore/Project/ProjectUserPrefs.h

@@ -34,6 +34,18 @@ public:
     const String& GetLastBuildPath() { return lastBuildPath_; }
     void SetLastBuildPath(const String& path) { lastBuildPath_ = path; }
 
+    float GetSnapTranslationX() const;
+    float GetSnapTranslationY() const;
+    float GetSnapTranslationZ() const;
+    float GetSnapRotation() const;
+    float GetSnapScale() const;
+
+    void SetSnapTranslationX(float value);
+    void SetSnapTranslationY(float value);
+    void SetSnapTranslationZ(float value);
+    void SetSnapRotation(float value);
+    void SetSnapScale(float value);
+
 private:
 
     bool Load(const String& path);
@@ -42,6 +54,12 @@ private:
     PlatformID defaultPlatform_;
     String lastBuildPath_;
 
+    float snapTranslationX_;
+    float snapTranslationY_;
+    float snapTranslationZ_;
+    float snapRotation_;
+    float snapScale_;
+
 };
 
 }

+ 0 - 9
Source/ToolCore/ToolEvents.h

@@ -14,15 +14,6 @@ using namespace Atomic;
 namespace ToolCore
 {
 
-EVENT(E_PROJECTLOADED, ProjectLoaded)
-{
-    PARAM(P_PROJECTPATH, ProjectPath);    // string
-}
-
-EVENT(E_PROJECTUNLOADED, ProjectUnloaded)
-{
-}
-
 EVENT(E_PLATFORMCHANGED, PlatformChanged)
 {
     PARAM(P_PLATFORM, Platform);    // Platform Ptr

+ 1 - 0
Source/ToolCore/ToolSystem.cpp

@@ -26,6 +26,7 @@
 #include "ToolEvents.h"
 
 #include "Project/Project.h"
+#include "Project/ProjectEvents.h"
 #include "Project/ProjectUserPrefs.h"
 
 #ifdef ATOMIC_DOTNET