Browse Source

Working on serializable attr access from script and UI improvements, fixed enum access from TS definition file

Josh Engebretson 10 years ago
parent
commit
a506556c29

+ 1 - 0
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/tsconfig.json

@@ -26,6 +26,7 @@
         "./ui/inspector/DataBinding.ts",
         "./ui/inspector/InspectorFrame.ts",
         "./ui/inspector/MaterialInspector.ts",
+        "./ui/inspector/NodeInspector.ts",
         "./ui/modal/MessageModal.ts",
         "./ui/modal/ModalOps.ts"
     ]

+ 46 - 22
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/ui/inspector/InspectorFrame.ts

@@ -6,54 +6,78 @@ import DataBinding = require("./DataBinding");
 // inspectors
 
 import MaterialInspector = require("./MaterialInspector");
+import NodeInspector = require("./NodeInspector");
 
 
 var UI = Atomic.UI;
 
 class InspectorFrame extends ScriptWidget {
 
-  constructor() {
+    constructor() {
 
-    super();
+        super();
 
-    this.gravity = UI.GRAVITY_TOP_BOTTOM;
+        this.gravity = UI.GRAVITY_TOP_BOTTOM;
 
-    this.load("AtomicEditor/editor/ui/inspectorframe.tb.txt");
+        this.load("AtomicEditor/editor/ui/inspectorframe.tb.txt");
 
-    var container = this.getWidget("inspectorcontainer");
+        var container = this.getWidget("inspectorcontainer");
 
-    this.materialInspector = new MaterialInspector();
-    container.addChild(this.materialInspector);
+        // this.materialInspector = new MaterialInspector();
+        // container.addChild(this.materialInspector);
 
-    this.subscribeToEvent(UIEvents.EditResource, (data) => this.handleEditResource(data));
+        this.subscribeToEvent(UIEvents.EditResource, (data) => this.handleEditResource(data));
+        this.subscribeToEvent("EditorActiveNodeChange", (data) => this.handleActiveNodeChange(data));
 
-  }
+    }
+
+    handleEditResource(ev: UIEvents.EditorResourceEvent) {
 
-  handleEditResource(ev: UIEvents.EditorResourceEvent) {
+        var path = ev.path;
 
-      var path = ev.path;
+        var db = ToolCore.getAssetDatabase();
+        var asset = db.getAssetByPath(path);
 
-      var db = ToolCore.getAssetDatabase();
-      var asset = db.getAssetByPath(path);
-      if (asset) {
+        if (asset) {
 
-        this.inspect(asset);
+            this.inspectAsset(asset);
 
-      }
+        }
 
-  }
+    }
 
+    handleActiveNodeChange(data) {
 
-  inspect(asset:ToolCore.Asset) {
+        var node = <Atomic.Node> data.node;
 
-    if (asset.importerName == "MaterialImporter") {
+        if (!node) {
+            return;
+        }
 
-      this.materialInspector.inspect(asset);
+        this.inspectNode(node);
 
     }
-  }
 
-  materialInspector:MaterialInspector;
+
+    inspectAsset(asset: ToolCore.Asset) {
+
+        //if (asset.importerTypeName == "MaterialImporter") {
+        //this.materialInspector.inspect(asset);
+        //}
+
+    }
+
+    inspectNode(node: Atomic.Node) {
+
+        if (!node) return;
+
+        var container = this.getWidget("inspectorcontainer");
+        var inspector = new NodeInspector();
+        container.addChild(inspector);
+
+        inspector.inspect(node);
+
+    }
 
 }
 

+ 50 - 0
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/ui/inspector/NodeInspector.ts

@@ -0,0 +1,50 @@
+
+import ScriptWidget = require("../ScriptWidget");
+
+var UI = Atomic.UI;
+
+class NodeInspector extends ScriptWidget {
+
+  constructor() {
+
+    super();
+
+  }
+
+  inspect(node:Atomic.Node) {
+
+    var attrs = node.getAttributes();
+
+    for (var i in attrs) {
+        var attr = attrs[i];
+        print(attr);
+    }
+
+    var fd = new Atomic.UIFontDescription();
+    fd.id = "Vera";
+    fd.size = 11;
+
+    var nlp = new Atomic.UILayoutParams();
+    nlp.width = 304;
+
+    var nodeLayout = new Atomic.UILayout();
+    nodeLayout.spacing = 4;
+
+    nodeLayout.layoutDistribution  = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
+    nodeLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
+    nodeLayout.layoutParams = nlp;
+
+    var nodeContainer = new Atomic.UIContainer();
+    nodeContainer.gravity = Atomic.UI_GRAVITY_ALL;
+    nodeContainer.skinBg = "InspectorTopLayout";
+
+    nodeLayout.addChild(nodeContainer);
+
+    this.addChild(nodeLayout);
+
+  }
+
+
+}
+
+export = NodeInspector;

+ 9 - 0
Source/Atomic/UI/UI.cpp

@@ -45,6 +45,7 @@ using namespace tb;
 #include "UITabContainer.h"
 #include "UISceneView.h"
 #include "UIDragDrop.h"
+#include "UIContainer.h"
 
 namespace tb
 {
@@ -463,6 +464,14 @@ UIWidget* UI::WrapWidget(tb::TBWidget* widget)
 
     // this is order dependent as we're using IsOfType which also works if a base class
 
+    if (widget->IsOfType<TBContainer>())
+    {
+        UIContainer* container = new UIContainer(context_, false);
+        container->SetWidget(widget);
+        widgetWrap_[widget] = container;
+        return container;
+    }
+
     if (widget->IsOfType<TBButton>())
     {
         // don't wrap the close button of a TBWindow.close

+ 36 - 0
Source/Atomic/UI/UIContainer.cpp

@@ -0,0 +1,36 @@
+
+#include <TurboBadger/tb_widgets.h>
+#include <TurboBadger/tb_widgets_common.h>
+
+#include <Atomic/IO/Log.h>
+
+#include "UIEvents.h"
+#include "UI.h"
+#include "UIContainer.h"
+
+using namespace tb;
+
+namespace Atomic
+{
+
+UIContainer::UIContainer(Context* context, bool createWidget) : UIWidget(context, false)
+{
+    if (createWidget)
+    {
+        widget_ = new TBContainer();
+        widget_->SetDelegate(this);
+        GetSubsystem<UI>()->WrapWidget(this, widget_);
+    }
+}
+
+UIContainer::~UIContainer()
+{
+
+}
+
+bool UIContainer::OnEvent(const tb::TBWidgetEvent &ev)
+{
+    return UIWidget::OnEvent(ev);
+}
+
+}

+ 26 - 0
Source/Atomic/UI/UIContainer.h

@@ -0,0 +1,26 @@
+
+#pragma once
+
+#include "UIWidget.h"
+
+namespace Atomic
+{
+
+class UIContainer : public UIWidget
+{
+    OBJECT(UIContainer)
+
+public:
+
+    UIContainer(Context* context, bool createWidget = true);
+    virtual ~UIContainer();
+
+protected:
+
+    virtual bool OnEvent(const tb::TBWidgetEvent &ev);
+
+private:
+
+};
+
+}

+ 1 - 1
Source/Atomic/UI/UIDragDrop.cpp

@@ -39,7 +39,7 @@ UIDragDrop::UIDragDrop(Context* context) : Object(context)
 
     dragText_ = new UITextField(context);
     dragText_->SetFontDescription(fd);
-    dragText_->SetGravity(WIDGET_GRAVITY_TOP);
+    dragText_->SetGravity(UI_GRAVITY_TOP);
 
     dragLayout_ = new UILayout(context);
     dragLayout_->AddChild(dragText_);

+ 4 - 4
Source/Atomic/UI/UILayout.cpp

@@ -45,7 +45,7 @@ void UILayout::SetSpacing(int spacing)
     ((tb::TBLayout*)widget_)->SetSpacing(spacing);
 }
 
-void UILayout::SetLayoutPosition(/*LAYOUT_POSITION*/ unsigned position)
+void UILayout::SetLayoutPosition(UI_LAYOUT_POSITION position)
 {
     if (!widget_)
         return;
@@ -53,7 +53,7 @@ void UILayout::SetLayoutPosition(/*LAYOUT_POSITION*/ unsigned position)
     ((tb::TBLayout*)widget_)->SetLayoutPosition( (LAYOUT_POSITION) position);
 }
 
-void UILayout::SetLayoutDistributionPosition(/*LAYOUT_DISTRIBUTION_POSITION*/ unsigned distribution_pos)
+void UILayout::SetLayoutDistributionPosition(UI_LAYOUT_DISTRIBUTION_POSITION distribution_pos)
 {
     if (!widget_)
         return;
@@ -71,7 +71,7 @@ void UILayout::SetLayoutSize(UI_LAYOUT_SIZE size)
 
 }
 
-void UILayout::SetAxis(unsigned axis)
+void UILayout::SetAxis(UI_AXIS axis)
 {
     if (!widget_)
         return;
@@ -79,7 +79,7 @@ void UILayout::SetAxis(unsigned axis)
     ((tb::TBLayout*)widget_)->SetAxis((AXIS) axis);
 }
 
-void UILayout::SetLayoutDistribution(/* LAYOUT_DISTRIBUTION */ unsigned distribution)
+void UILayout::SetLayoutDistribution(UI_LAYOUT_DISTRIBUTION distribution)
 {
     if (!widget_)
         return;

+ 52 - 4
Source/Atomic/UI/UILayout.h

@@ -8,6 +8,13 @@
 namespace Atomic
 {
 
+enum UI_AXIS {
+    ///< Horizontal layout
+    UI_AXIS_X = tb::AXIS_X,
+    ///< Vertical layout
+    UI_AXIS_Y = tb::AXIS_Y,
+};
+
 /// Specifies which height widgets in a AXIS_X layout should have,
 ///	or which width widgets in a AXIS_Y layout should have.
 ///	No matter what, it will still prioritize minimum and maximum for each widget.
@@ -24,6 +31,46 @@ enum UI_LAYOUT_SIZE
     UI_LAYOUT_SIZE_AVAILABLE = tb::LAYOUT_SIZE_AVAILABLE
 };
 
+/// Specifies which width widgets in a AXIS_X layout should have,
+///    or which height widgets in a AXIS_Y layout should have. */
+///
+enum UI_LAYOUT_DISTRIBUTION
+{
+    ///< Size will be the preferred so each widget may be sized differently.
+    UI_LAYOUT_DISTRIBUTION_PREFERRED = tb::LAYOUT_DISTRIBUTION_PREFERRED,
+    ///< Size should grow to all available space
+    UI_LAYOUT_DISTRIBUTION_AVAILABLE = tb::LAYOUT_DISTRIBUTION_AVAILABLE,
+    ///< Sizes depend on the gravity for each widget. (If the widget pulls
+    /// ///< towards both directions, it should grow to all available space)
+    UI_LAYOUT_DISTRIBUTION_GRAVITY = tb::LAYOUT_DISTRIBUTION_GRAVITY
+};
+
+/// Specifies which y position widgets in a AXIS_X layout should have,
+///	or which x position widgets in a AXIS_Y layout should have. */
+enum UI_LAYOUT_POSITION
+{
+    ///< Position is centered
+    UI_LAYOUT_POSITION_CENTER = tb::LAYOUT_POSITION_CENTER,
+    ///< Position is to the left for AXIS_Y layout and top for AXIS_X layout.
+    UI_LAYOUT_POSITION_LEFT_TOP = tb::LAYOUT_POSITION_LEFT_TOP,
+    ///< Position is to the right for AXIS_Y layout and bottom for AXIS_X layout.
+    UI_LAYOUT_POSITION_RIGHT_BOTTOM = tb::LAYOUT_POSITION_RIGHT_BOTTOM,
+    ///< Position depend on the gravity for each widget. (If the widget pulls
+    /// ///< towards both directions, it will be centered)
+    UI_LAYOUT_POSITION_GRAVITY= tb::LAYOUT_POSITION_GRAVITY
+};
+
+/** Specifies how widgets should be moved horizontally in a AXIS_X
+    layout (or vertically in a AXIS_Y layout) if there is extra space
+    available. */
+enum UI_LAYOUT_DISTRIBUTION_POSITION
+{
+    UI_LAYOUT_DISTRIBUTION_POSITION_CENTER = tb::LAYOUT_DISTRIBUTION_POSITION_CENTER,
+    UI_LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP = tb::LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP,
+    UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM = tb::LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM
+};
+
+
 
 class UILayoutParams : public Object
 {
@@ -34,6 +81,7 @@ public:
     UILayoutParams(Context* context);
     virtual ~UILayoutParams();
 
+    void SetWidth(int width) { params_.SetWidth(width); }
     void SetHeight(int height) { params_.SetHeight(height); }
 
     tb::LayoutParams* GetTBLayoutParams() { return &params_; }
@@ -56,12 +104,12 @@ public:
 
     void SetSpacing(int spacing);
 
-    void SetAxis(/* AXIS */ unsigned axis);
+    void SetAxis(UI_AXIS axis);
     void SetLayoutSize(UI_LAYOUT_SIZE size);
 
-    void SetLayoutPosition(/*LAYOUT_POSITION*/ unsigned position);
-    void SetLayoutDistribution(/* LAYOUT_DISTRIBUTION */ unsigned distribution);
-    void SetLayoutDistributionPosition(/*LAYOUT_DISTRIBUTION_POSITION*/ unsigned distribution_pos);
+    void SetLayoutPosition(UI_LAYOUT_POSITION position);
+    void SetLayoutDistribution(UI_LAYOUT_DISTRIBUTION distribution);
+    void SetLayoutDistributionPosition(UI_LAYOUT_DISTRIBUTION_POSITION distribution_pos);
 
 
 protected:

+ 1 - 1
Source/Atomic/UI/UIListView.cpp

@@ -190,7 +190,7 @@ UIListView::UIListView(Context* context, bool createWidget) :
     rootList_->SetFilter(" ");
 
     widget_->SetGravity(WIDGET_GRAVITY_ALL);
-    rootList_->SetGravity(WIDGET_GRAVITY_ALL);
+    rootList_->SetGravity(UI_GRAVITY_ALL);
 
     source_ = new ListViewItemSource(rootList_->GetTBSelectList());
 

+ 1 - 1
Source/Atomic/UI/UIWidget.cpp

@@ -145,7 +145,7 @@ void UIWidget::SetText(const String& text)
     widget_->SetText(text.CString());
 }
 
-void UIWidget::SetGravity(/*WIDGET_GRAVITY*/ unsigned gravity)
+void UIWidget::SetGravity(UI_GRAVITY gravity)
 {
     if (!widget_)
         return;

+ 18 - 1
Source/Atomic/UI/UIWidget.h

@@ -22,6 +22,23 @@ enum UI_WIDGET_VISIBILITY
     UI_WIDGET_VISIBILITY_GONE = tb::WIDGET_VISIBILITY_GONE
 };
 
+/// TBWidget gravity (may be combined).
+/// Gravity gives hints about positioning and sizing preferences.
+enum UI_GRAVITY {
+
+    UI_GRAVITY_NONE = tb::WIDGET_GRAVITY_NONE,
+    UI_GRAVITY_LEFT = tb::WIDGET_GRAVITY_LEFT,
+    UI_GRAVITY_RIGHT = tb::WIDGET_GRAVITY_RIGHT,
+    UI_GRAVITY_TOP = tb::WIDGET_GRAVITY_TOP,
+    UI_GRAVITY_BOTTOM = tb::WIDGET_GRAVITY_BOTTOM,
+
+    UI_GRAVITY_LEFT_RIGHT	= tb::WIDGET_GRAVITY_LEFT_RIGHT,
+    UI_GRAVITY_TOP_BOTTOM	= tb::WIDGET_GRAVITY_TOP_BOTTOM,
+    UI_GRAVITY_ALL			= tb::WIDGET_GRAVITY_ALL,
+    UI_GRAVITY_DEFAULT		= tb::WIDGET_GRAVITY_DEFAULT
+};
+
+
 class UILayoutParams;
 class UIFontDescription;
 
@@ -63,7 +80,7 @@ public:
     virtual void SetId(const String& id);
 
     void Center();
-    void SetGravity(/*WIDGET_GRAVITY*/ unsigned gravity);
+    void SetGravity(UI_GRAVITY gravity);
 
     void SetValue(double value);
     double GetValue();

+ 1 - 1
Source/AtomicEditorWork/Editors/ResourceEditor.cpp

@@ -83,7 +83,7 @@ ResourceEditor::ResourceEditor(Context* context, const String& fullpath, UITabCo
     ((TBTabContainer*)container_->GetInternalWidget())->GetTabLayout()->AddChild(editorTabLayout_);
 
     rootContentWidget_ = new UIWidget(context_);
-    rootContentWidget_->SetGravity(WIDGET_GRAVITY_ALL);
+    rootContentWidget_->SetGravity(UI_GRAVITY_ALL);
     container_->GetContentRoot()->AddChild(rootContentWidget_);
 
     SubscribeToEvent(E_FILECHANGED, HANDLER(ResourceEditor, HandleFileChanged));

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

@@ -65,7 +65,7 @@ SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, UITabCon
 
     }
 
-    sceneView_->SetGravity(WIDGET_GRAVITY_ALL);
+    sceneView_->SetGravity(UI_GRAVITY_ALL);
 
     rootContentWidget_->AddChild(sceneView_);
 

+ 1 - 1
Source/AtomicEditorWork/Inspector/UIInspectorFrame.cpp

@@ -31,7 +31,7 @@ namespace AtomicEditor
 InspectorFrame::InspectorFrame(Context* context) :
     UIWidget(context, true)
 {
-    SetGravity(WIDGET_GRAVITY_TOP_BOTTOM);
+    SetGravity(UI_GRAVITY_TOP_BOTTOM);
 
     InitializeSources();
 

+ 4 - 0
Source/AtomicJS/Javascript/JSScene.cpp

@@ -14,6 +14,8 @@
 namespace Atomic
 {
 
+void jsapi_init_scene_serializable(JSVM* vm);
+
 static int Node_CreateJSComponent(duk_context* ctx)
 {
     duk_push_this(ctx);
@@ -146,6 +148,8 @@ void jsapi_init_scene(JSVM* vm)
 {
     duk_context* ctx = vm->GetJSContext();
 
+    jsapi_init_scene_serializable(vm);
+
     js_class_get_prototype(ctx, "Atomic", "Node");
     duk_push_c_function(ctx, Node_GetChildrenWithComponent, DUK_VARARGS);
     duk_put_prop_string(ctx, -2, "getChildrenWithComponent");

+ 111 - 0
Source/AtomicJS/Javascript/JSSceneSerializable.cpp

@@ -0,0 +1,111 @@
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+// Please see LICENSE.md in repository root for license information
+// https://github.com/AtomicGameEngine/AtomicGameEngine
+
+#include <Atomic/Resource/ResourceCache.h>
+#include <Atomic/IO/File.h>
+#include <Atomic/Scene/Node.h>
+#include <Atomic/Scene/Scene.h>
+
+#include "JSScene.h"
+#include "JSComponent.h"
+#include "JSVM.h"
+
+namespace Atomic
+{
+
+/*
+    /// Attribute type.
+    VariantType type_;
+    /// Name.
+    String name_;
+    /// Byte offset from start of object.
+    unsigned offset_;
+    /// Enum names.
+    const char** enumNames_;
+    /// Helper object for accessor mode.
+    SharedPtr<AttributeAccessor> accessor_;
+    /// Default value for network replication.
+    Variant defaultValue_;
+    /// Attribute mode: whether to use for serialization, network replication, or both.
+    unsigned mode_;
+    /// Attribute data pointer if elsewhere than in the Serializable.
+    void* ptr_;
+
+*/
+static int Serializable_GetAttributes(duk_context* ctx)
+{
+    duk_push_this(ctx);
+    Serializable* serial = js_to_class_instance<Serializable>(ctx, -1, 0);
+    unsigned type = serial->GetType().Value();
+
+    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 1;
+
+    const Vector<AttributeInfo>* attrs = serial->GetAttributes();
+
+    duk_push_array(ctx);
+    duk_dup(ctx, -1);
+    duk_put_prop_index(ctx, -4, type);
+
+    for (unsigned i = 0; i < attrs->Size(); i++)
+    {
+        const AttributeInfo* attr = &attrs->At(i);
+
+        duk_push_object(ctx);
+
+        duk_push_number(ctx, (double) attr->type_);
+        duk_put_prop_string(ctx, -2, "type");
+
+        duk_push_string(ctx, attr->name_.CString());
+        duk_put_prop_string(ctx, -2, "name");
+
+        duk_push_number(ctx, (double) attr->mode_);
+        duk_put_prop_string(ctx, -2, "mode");
+
+        duk_push_string(ctx,attr->defaultValue_.ToString().CString());
+        duk_put_prop_string(ctx, -2, "defaultValue");
+
+        duk_push_array(ctx);
+
+        const char** enumPtr = attr->enumNames_;
+        unsigned enumCount = 0;
+
+        if (enumPtr)
+        {
+            while (*enumPtr)
+            {
+                duk_push_string(ctx, *enumPtr);
+                duk_put_prop_index(ctx, -2, enumCount++);
+            }
+        }
+
+        duk_put_prop_string(ctx, -2, "enumNames");
+
+        // store attr object
+        duk_put_prop_index(ctx, -2, i);
+    }
+
+    return 1;
+}
+
+void jsapi_init_scene_serializable(JSVM* vm)
+{
+    duk_context* ctx = vm->GetJSContext();
+
+    // cached attr
+    duk_push_object(ctx);
+    duk_put_global_string(ctx, "__atomic_scene_serializable_attributes");
+
+    js_class_get_prototype(ctx, "Atomic", "Serializable");
+    duk_push_c_function(ctx, Serializable_GetAttributes, 0);
+    duk_put_prop_string(ctx, -2, "getAttributes");
+    duk_pop(ctx);
+
+}
+
+}

+ 1 - 0
Source/AtomicJS/Javascript/JSUI.cpp

@@ -52,6 +52,7 @@ JSUI::JSUI(Context* context) : Object(context),
     uiTypes_["UISkinImage"] = true;
     uiTypes_["UITabContainer"] = true;
     uiTypes_["UISceneView"] = true;
+    uiTypes_["UIContainer"] = true;
 
 }
 

+ 2 - 1
Source/AtomicJS/Packages/Atomic/UI.json

@@ -7,7 +7,8 @@
 								"UISelectItem", "UISelectItemSource", "UIMenuWindow", "UIEditField",
 								"UIImageWidget", "UIClickLabel", "UICheckBox", "UIMenuItem", "UIMenuItemSource",
 								"UISelectList", "UIListView", "UIMessageWindow", "UILayoutParams", "UIFontDescription",
-								"UISkinImage", "UITabContainer", "UISceneView", "UIPreferredSize", "UIDragObject"],
+								"UISkinImage", "UITabContainer", "UISceneView", "UIPreferredSize", "UIDragObject",
+								"UIContainer"],
 	"overloads" : {
 	}
 }

+ 7 - 9
Source/ToolCore/JSBind/JSBTypeScript.cpp

@@ -245,23 +245,21 @@ void JSBTypeScript::ExportModuleEnums(JSBModule* module)
 
     for (unsigned i = 0; i <enums.Size(); i++)
     {
-        JSBEnum* _enum =enums[i];
+        JSBEnum* _enum = enums[i];
 
-        source_ += "   export enum " + _enum->GetName();
-        source_ += " {\n\n";
+        // can't use a TS enum, so use a type alias
+
+        source_ += "\n   // enum " + _enum->GetName() + "\n";
+        source_ += "   export type " + _enum->GetName() + " = number;\n";
 
         Vector<String>& values = _enum->GetValues();
 
         for (unsigned j = 0; j < values.Size(); j++)
         {
-            source_ += "      " + values[j];
-            if (j !=  values.Size() - 1)
-                source_ += ",\n";
+            source_ += "   export var " + values[j] + ": " +  _enum->GetName() + ";\n";
         }
 
-        source_ += "\n\n   }\n\n";
-
-
+        source_ += "\n";
 
     }