Browse Source

Resource improvements

Josh Engebretson 10 years ago
parent
commit
2b708f5524

BIN
Data/AtomicEditor/Resources/EditorData/AtomicEditor/editor/skin/2d_level.png


+ 3 - 2
Data/AtomicEditor/Resources/EditorData/AtomicEditor/editor/skin/skin.tb.txt

@@ -33,8 +33,6 @@ elements
 		overlays
 			element Star
 				condition: target: ancestors, property: skin, value: "StarCondition"
-
-
 	Star
 		bitmap star_gray.png
 		type Image
@@ -65,6 +63,9 @@ elements
 	JavascriptBitmap
 		bitmap javascript.png
 
+	2DLevelBitmap
+		bitmap 2d_level.png
+
 	FolderCreateBitmap
 		bitmap folder_create.png
 

+ 1 - 1
Data/AtomicEditor/Resources/EditorData/AtomicEditor/editor/ui/projectframe.tb.txt

@@ -7,7 +7,7 @@ TBLayout: distribution: gravity, axis: y, id: projectframe
 		type search	
 	TBWidget: gravity: all
 		TBLayout: distribution: gravity, id: foldercontainer, gravity: all
-	TBScrollContainer: scroll-mode: y-auto, id: contentcontainerscroll
+	TBScrollContainer: scroll-mode: y-auto, id: contentcontainerscroll, gravity: all
 		TBLayout: id: contentcontainer, axis: y, position: left
 	
 

+ 10 - 0
Data/AtomicEditor/Resources/EditorData/AtomicEditor/editor/ui/resourcecreate2dlevel.tb.txt

@@ -0,0 +1,10 @@
+TBLayout: axis: y, distribution: gravity, position: left
+	TBLayout: 
+		TBTextField: text: "Level Name:"
+		TBEditField: id: level_name, autofocus: 1
+			lp: min-width: 180
+	TBSeparator: gravity: left right, skin: AESeparator
+	TBLayout: 
+		TBButton: text: Create, id: create
+		TBButton: text: Cancel, id: cancel
+		

+ 10 - 0
Data/AtomicEditor/Resources/EditorData/AtomicEditor/editor/ui/resourcecreatemodule.tb.txt

@@ -0,0 +1,10 @@
+TBLayout: axis: y, distribution: gravity, position: left
+	TBLayout: 
+		TBTextField: text: "Module Name:"
+		TBEditField: id: module_name, autofocus: 1
+			lp: min-width: 180
+	TBSeparator: gravity: left right, skin: AESeparator
+	TBLayout: 
+		TBButton: text: Create, id: create
+		TBButton: text: Cancel, id: cancel
+		

+ 8 - 0
Data/AtomicEditor/Resources/EditorData/AtomicEditor/templates/template_empty.tmx

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<map version="1.0" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="32" tileheight="32" nextobjectid="1">
+ <layer name="Tile Layer 1" width="100" height="100">
+  <data encoding="base64" compression="zlib">
+   eJztwTEBAAAAwqD1T+1lC6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAbnEAAAQ==
+  </data>
+ </layer>
+</map>

+ 1 - 0
Data/AtomicEditor/Resources/EditorData/AtomicEditor/templates/template_module.js

@@ -0,0 +1 @@
+// Atomic Module

+ 152 - 2
Source/AtomicEditor/Source/Resources/AEResourceOps.cpp

@@ -117,6 +117,74 @@ bool ResourceOps::CheckCreateScript(const String& resourcePath, const String& re
 }
 
 
+bool ResourceOps::CheckCreateModule(const String& resourcePath, const String& resourceName, bool reportError)
+{
+
+    Editor* editor = GetSubsystem<Editor>();
+    Project* project = editor->GetProject();
+
+    String fullpath = resourcePath + resourceName;
+    if (!resourceName.EndsWith(".js"))
+        fullpath += ".js";
+
+    FileSystem* fs = GetSubsystem<FileSystem>();
+
+    if (fs->FileExists(fullpath))
+    {
+        if (reportError)
+        {
+            String errorMsg;
+            errorMsg.AppendWithFormat("The module:\n\n%s\n\nalready exists", fullpath.CString());
+            editor->PostModalError("Create Module Error", errorMsg);
+        }
+
+        return false;
+    }
+
+    if (!project->IsModulesDirOrFile(resourcePath))
+    {
+        if (reportError)
+        {
+            String errorMsg;
+            errorMsg.AppendWithFormat("Modules must reside in or in a subfolder of the Modules folder");
+            editor->PostModalError("Create Module Error", errorMsg);
+        }
+
+        return false;
+    }
+
+    return true;
+
+}
+
+bool ResourceOps::CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError)
+{
+
+    Editor* editor = GetSubsystem<Editor>();
+    Project* project = editor->GetProject();
+
+    String fullpath = resourcePath + resourceName;
+    if (!resourceName.EndsWith(".tmx"))
+        fullpath += ".tmx";
+
+    FileSystem* fs = GetSubsystem<FileSystem>();
+
+    if (fs->FileExists(fullpath))
+    {
+        if (reportError)
+        {
+            String errorMsg;
+            errorMsg.AppendWithFormat("The level:\n\n%s\n\nalready exists", fullpath.CString());
+            editor->PostModalError("Create 2D Level Error", errorMsg);
+        }
+
+        return false;
+    }
+
+    return true;
+
+}
+
 bool ResourceOps::CopyFile(File* srcFile, const String& destFileName)
 {
     SharedPtr<File> destFile(new File(context_, destFileName, FILE_WRITE));
@@ -139,8 +207,9 @@ void ResourceOps::HandleResourceDelete(const String& resourcePath, bool reportEr
 
     if (fs->DirExists(resourcePath))
     {
-        if (reportError)
-            editor->PostModalError("Delete Resource Error", "Deleting Folders not currently implemented");
+        fs->RemoveDir(resourcePath, true);
+
+        GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
 
         return;
     }
@@ -290,4 +359,85 @@ void ResourceOps::HandleCreateScript(const String& resourcePath, const String& r
 
 }
 
+void ResourceOps::HandleCreateModule(const String& resourcePath, const String& resourceName,
+                                        bool navigateToResource, bool reportError)
+{
+    Editor* editor = GetSubsystem<Editor>();
+
+    if (!CheckCreateModule(resourcePath, resourceName, reportError))
+        return;
+
+    ResourceCache* cache = GetSubsystem<ResourceCache>();
+
+    SharedPtr<File> srcFile = cache->GetFile("AtomicEditor/templates/template_module.js");
+    if (srcFile.Null() || !srcFile->IsOpen())
+    {
+        editor->PostModalError("Create Script Error", "Could not open module template");
+        return;
+    }
+
+    String fullpath = resourcePath + resourceName;
+    if (!resourceName.EndsWith(".js"))
+        fullpath += ".js";
+
+    if (!CopyFile(srcFile, fullpath))
+    {
+        String errorMsg;
+        errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s",
+                                  "AtomicEditor/template_module.js", fullpath.CString());
+        editor->PostModalError("Create Module Error", errorMsg);
+        return;
+    }
+
+    if (navigateToResource)
+    {
+        ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame();
+        rframe->EditResource(fullpath);
+    }
+
+    GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
+
+}
+
+void ResourceOps::HandleCreate2DLevel(const String& resourcePath, const String& resourceName,
+                                        bool navigateToResource, bool reportError)
+{
+    Editor* editor = GetSubsystem<Editor>();
+
+    if (!CheckCreate2DLevel(resourcePath, resourceName, reportError))
+        return;
+
+    ResourceCache* cache = GetSubsystem<ResourceCache>();
+
+    SharedPtr<File> srcFile = cache->GetFile("AtomicEditor/templates/template_empty.tmx");
+    if (srcFile.Null() || !srcFile->IsOpen())
+    {
+        editor->PostModalError("Create Script Error", "Could not open module template");
+        return;
+    }
+
+    String fullpath = resourcePath + resourceName;
+    if (!resourceName.EndsWith(".tmx"))
+        fullpath += ".tmx";
+
+    if (!CopyFile(srcFile, fullpath))
+    {
+        String errorMsg;
+        errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s",
+                                  "AtomicEditor/template_empty.tmx", fullpath.CString());
+        editor->PostModalError("Create 2D Level Error", errorMsg);
+        return;
+    }
+
+    if (navigateToResource)
+    {
+        //ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame();
+        //rframe->EditResource(fullpath);
+    }
+
+    GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
+
+}
+
+
 }

+ 4 - 0
Source/AtomicEditor/Source/Resources/AEResourceOps.h

@@ -28,12 +28,16 @@ public:
     void HandleNewFolder(const String& resourcePath, bool reportError = true);
     void HandleCreateComponent(const String& resourcePath, const String& resourceName, bool navigateToResource = true, bool reportError = true);
     void HandleCreateScript(const String& resourcePath, const String& resourceName, bool navigateToResource = true, bool reportError = true);
+    void HandleCreateModule(const String& resourcePath, const String& resourceName, bool navigateToResource = true, bool reportError = true);
+    void HandleCreate2DLevel(const String& resourcePath, const String& resourceName, bool navigateToResource = false, bool reportError = true);
 private:
 
     bool CopyFile(File* srcFile, const String& destFileName);
 
     bool CheckCreateComponent(const String& resourcePath, const String& resourceName, bool reportError);
     bool CheckCreateScript(const String& resourcePath, const String& resourceName, bool reportError);
+    bool CheckCreateModule(const String& resourcePath, const String& resourceName, bool reportError);
+    bool CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError);
 
 };
 

+ 1 - 1
Source/AtomicEditor/Source/Tools/External/AEExternalTooling.cpp

@@ -51,7 +51,7 @@ void ExternalTooling::ToolExited(const String& name)
     if (!tools_.Contains(name))
         return;
 
-    tools_[name] = 0;
+    tools_.Erase(name);
 
 }
 

+ 1 - 0
Source/AtomicEditor/Source/Tools/External/AtomicTiled.cpp

@@ -62,6 +62,7 @@ bool AtomicTiled::Launch(const String& args)
     {
         SubscribeToEvent(subprocess_, E_SUBPROCESSCOMPLETE, HANDLER(AtomicTiled, HandleEvent));
         SubscribeToEvent(subprocess_, E_SUBPROCESSOUTPUT, HANDLER(AtomicTiled, HandleEvent));
+        return true;
     }
 
     return false;

+ 17 - 0
Source/AtomicEditor/Source/UI/Modal/UIModalOps.cpp

@@ -116,6 +116,23 @@ void UIModalOps::ShowCreateComponent(const String& resourcePath)
     opWindow_ = new UICreateComponent(context_);
 }
 
+void UIModalOps::ShowCreateModule(const String& resourcePath)
+{
+    assert(opWindow_.Null());
+
+    resourcePath_ = resourcePath;
+    Show();
+    opWindow_ = new UICreateModule(context_);
+}
+
+void UIModalOps::ShowCreate2DLevel(const String& resourcePath)
+{
+    assert(opWindow_.Null());
+
+    resourcePath_ = resourcePath;
+    Show();
+    opWindow_ = new UICreate2DLevel(context_);
+}
 
 void UIModalOps::ShowCreateScript(const String& resourcePath)
 {

+ 2 - 0
Source/AtomicEditor/Source/UI/Modal/UIModalOps.h

@@ -48,6 +48,8 @@ class UIModalOps: public AEWidget, private TBWidgetListener
 
     void ShowCreateComponent(const String& resourcePath);
     void ShowCreateScript(const String& resourcePath);
+    void ShowCreateModule(const String& resourcePath);
+    void ShowCreate2DLevel(const String& resourcePath);
     void ShowResourceDelete(const String& resourcePath);
     void ShowNewFolder(const String& resourcePath);
     void ShowBuildSettings();

+ 96 - 0
Source/AtomicEditor/Source/UI/Modal/UIResourceOps.cpp

@@ -208,4 +208,100 @@ bool UICreateScript::OnEvent(const TBWidgetEvent &ev)
     return false;
 }
 
+// UICreateModule------------------------------------------------
+
+UICreateModule::UICreateModule(Context* context):
+    UIModalOpWindow(context)
+{
+    TBUI* tbui = GetSubsystem<TBUI>();
+    window_->SetText("Create Module");
+    tbui->LoadResourceFile(window_->GetContentRoot(), "AtomicEditor/editor/ui/resourcecreatemodule.tb.txt");
+    nameField_ = window_->GetContentRoot()->GetWidgetByIDAndType<TBEditField>(TBIDC("module_name"));
+    assert(nameField_);
+    window_->ResizeToFitContent();
+    Center();
+}
+
+UICreateModule::~UICreateModule()
+{
+
+}
+
+bool UICreateModule::OnEvent(const TBWidgetEvent &ev)
+{
+    UIModalOps* ops = GetSubsystem<UIModalOps>();
+
+    if (ev.type == EVENT_TYPE_POINTER_MOVE)
+        return false;
+
+    if (ev.type == EVENT_TYPE_CLICK)
+    {
+        if (ev.target->GetID() == TBIDC("create"))
+        {
+            TBStr text;
+            nameField_->GetText(text);
+            ResourceOps* rops = GetSubsystem<ResourceOps>();
+            rops->HandleCreateModule(ops->GetResourcePath(), text.CStr(), true, true);
+            ops->Hide();
+            return true;
+        }
+
+        if (ev.target->GetID() == TBIDC("cancel"))
+        {
+            ops->Hide();
+            return true;
+        }
+    }
+
+    return false;
+}
+
+// UICreateModule------------------------------------------------
+
+UICreate2DLevel::UICreate2DLevel(Context* context):
+    UIModalOpWindow(context)
+{
+    TBUI* tbui = GetSubsystem<TBUI>();
+    window_->SetText("Create 2D Level");
+    tbui->LoadResourceFile(window_->GetContentRoot(), "AtomicEditor/editor/ui/resourcecreate2dlevel.tb.txt");
+    nameField_ = window_->GetContentRoot()->GetWidgetByIDAndType<TBEditField>(TBIDC("level_name"));
+    assert(nameField_);
+    window_->ResizeToFitContent();
+    Center();
+}
+
+UICreate2DLevel::~UICreate2DLevel()
+{
+
+}
+
+bool UICreate2DLevel::OnEvent(const TBWidgetEvent &ev)
+{
+    UIModalOps* ops = GetSubsystem<UIModalOps>();
+
+    if (ev.type == EVENT_TYPE_POINTER_MOVE)
+        return false;
+
+    if (ev.type == EVENT_TYPE_CLICK)
+    {
+        if (ev.target->GetID() == TBIDC("create"))
+        {
+            TBStr text;
+            nameField_->GetText(text);
+            ResourceOps* rops = GetSubsystem<ResourceOps>();
+            rops->HandleCreate2DLevel(ops->GetResourcePath(), text.CStr(), true, true);
+            ops->Hide();
+            return true;
+        }
+
+        if (ev.target->GetID() == TBIDC("cancel"))
+        {
+            ops->Hide();
+            return true;
+        }
+    }
+
+    return false;
+}
+
 }

+ 30 - 0
Source/AtomicEditor/Source/UI/Modal/UIResourceOps.h

@@ -37,6 +37,36 @@ private:
     TBEditField* nameField_;
 };
 
+class UICreateModule: public UIModalOpWindow
+{
+    OBJECT(UICreateModule);
+
+public:
+
+    UICreateModule(Context* context);
+    virtual ~UICreateModule();
+    bool OnEvent(const TBWidgetEvent &ev);
+
+private:
+
+    TBEditField* nameField_;
+};
+
+class UICreate2DLevel: public UIModalOpWindow
+{
+    OBJECT(UICreate2DLevel);
+
+public:
+
+    UICreate2DLevel(Context* context);
+    virtual ~UICreate2DLevel();
+    bool OnEvent(const TBWidgetEvent &ev);
+
+private:
+
+    TBEditField* nameField_;
+};
+
 
 class UIResourceDelete: public UIModalOpWindow
 {

+ 51 - 22
Source/AtomicEditor/Source/UI/UIMainFrame.cpp

@@ -79,12 +79,28 @@ MainFrame::MainFrame(Context* context) :
     menuResourcesSource.AddItem(new TBGenericStringItem("-"));
     menuResourcesSource.AddItem(new TBGenericStringItem("Reveal in Finder", TBIDC("reveal")));
 
-    menuResourcesCreateSource.AddItem(new TBGenericStringItem("Component", TBIDC("create_component")));
-    menuResourcesCreateSource.AddItem(new TBGenericStringItem("2D Level", TBIDC("create_tmx")));
+    TBGenericStringItem* item;
+    item = new TBGenericStringItem("Folder", TBIDC("create_folder"));
+    item->SetSkinImage(TBIDC("Folder.icon"));
+    menuResourcesCreateSource.AddItem(item);
+
     menuResourcesCreateSource.AddItem(new TBGenericStringItem("-"));
-    menuResourcesCreateSource.AddItem(new TBGenericStringItem("Javascript", TBIDC("create_javascript")));
+
+    item = new TBGenericStringItem("Component", TBIDC("create_component"));
+    item->SetSkinImage(TBIDC("JavascriptBitmap"));
+    menuResourcesCreateSource.AddItem(item);
+    item = new TBGenericStringItem("Script", TBIDC("create_script"));
+    item->SetSkinImage(TBIDC("JavascriptBitmap"));
+    menuResourcesCreateSource.AddItem(item);
+    item = new TBGenericStringItem("Module", TBIDC("create_module"));
+    item->SetSkinImage(TBIDC("JavascriptBitmap"));
+    menuResourcesCreateSource.AddItem(item);
+
     menuResourcesCreateSource.AddItem(new TBGenericStringItem("-"));
-    menuResourcesCreateSource.AddItem(new TBGenericStringItem("Folder", TBIDC("create_folder")));
+
+    item = new TBGenericStringItem("2D Level", TBIDC("create_2d_level"));
+    item->SetSkinImage(TBIDC("2DLevelBitmap"));
+    menuResourcesCreateSource.AddItem(item);
 
     menuProjectSource.AddItem(new TBGenericStringItem("Build", TBIDC("project_build")));
     menuProjectSource.AddItem(new TBGenericStringItem("Build Settings", TBIDC("project_build_settings")));
@@ -489,15 +505,39 @@ bool MainFrame::OnEvent(const TBWidgetEvent &ev)
 
         if (ev.target->GetID() == TBIDC("resources popup"))
         {
-            if (ev.ref_id == TBIDC("create_component"))
-            {
-                ShowResourceCreateWindow("Component");
-                return true;
-            }
-            else if (ev.ref_id == TBIDC("reveal"))
+            UIModalOps* ops = GetSubsystem<UIModalOps>();
+
+            String resourcePath = projectframe_->GetCurrentContentFolder();
+
+            if (resourcePath.Length())
             {
-                RevealInFinder();
+                if (ev.ref_id == TBIDC("create_component"))
+                {
+                    ops->ShowCreateComponent(resourcePath);
+                }
+                else if (ev.ref_id == TBIDC("create_script"))
+                {
+                    ops->ShowCreateScript(resourcePath);
+                }
+                else if (ev.ref_id == TBIDC("create_module"))
+                {
+                    ops->ShowCreateModule(resourcePath);
+                }
+                else if (ev.ref_id == TBIDC("create_2d_level"))
+                {
+                    ops->ShowCreate2DLevel(resourcePath);
+                }
+                else if (ev.ref_id == TBIDC("create_folder"))
+                {
+                    ops->ShowNewFolder(resourcePath);
+                }
+                else if (ev.ref_id == TBIDC("reveal"))
+                {
+                    RevealInFinder();
+                }
             }
+
+            return true;
         }
 
         if (ev.target->GetID() == TBIDC("help popup"))
@@ -655,17 +695,6 @@ void MainFrame::RevealInFinder()
 
 }
 
-void MainFrame::ShowResourceCreateWindow(const String& resourceType)
-{
-    Editor* editor = context_->GetSubsystem<Editor>();
-    Project* project = editor->GetProject();
-
-    if (!project)
-        return;
-
-    //new ResourceCreateWindow(resourceType, context_);
-}
-
 void MainFrame::HandlePlatformChange(StringHash eventType, VariantMap& eventData)
 {
     using namespace PlatformChange;

+ 0 - 1
Source/AtomicEditor/Source/UI/UIMainFrame.h

@@ -67,7 +67,6 @@ public:
 
     // reveals the current project folder in finder/explorer
     void RevealInFinder();
-    void ShowResourceCreateWindow(const String& resourceType);
 
     PlayerWidget* GetPlayerWidget();
 

+ 46 - 0
Source/AtomicEditor/Source/UI/UIProjectFrame.cpp

@@ -40,6 +40,7 @@ ProjectFrame::ProjectFrame(Context* context) :
     assert(foldercontainer);
 
     folderList_ = new ListView(context_, "folderList_");
+    folderList_->GetRootList()->SetGravity(WIDGET_GRAVITY_ALL);
 
     TBWidgetDelegate* folderListWD = folderList_->GetWidgetDelegate();
 
@@ -62,6 +63,7 @@ void ProjectFrame::Refresh()
 {
     String cfolder = currentContentFolder_;
     currentContentFolder_ = "";
+    RefreshFolders();
     SelectCurrentContentFolder(cfolder);
 }
 
@@ -399,6 +401,14 @@ bool ProjectFrame::OnContextMenuEvent(const TBWidgetEvent &ev)
     {
         ops->ShowCreateScript(contextMenuPath_);
     }
+    else if (ev.ref_id == TBIDC("create_module"))
+    {
+        ops->ShowCreateModule(contextMenuPath_);
+    }
+    else if (ev.ref_id == TBIDC("create_2d_level"))
+    {
+        ops->ShowCreate2DLevel(contextMenuPath_);
+    }
     else if (ev.ref_id == TBIDC("new_folder"))
     {
         ops->ShowNewFolder(contextMenuPath_);
@@ -411,6 +421,21 @@ bool ProjectFrame::OnContextMenuEvent(const TBWidgetEvent &ev)
     return true;
 }
 
+String ProjectFrame::GetCurrentContentFolder()
+{
+    if (currentContentFolder_.Length())
+        return currentContentFolder_;
+
+    Editor* editor = GetSubsystem<Editor>();
+    Project* project = editor->GetProject();
+
+    if (project)
+        return project->GetResourcePath();
+
+    return "";
+
+}
+
 void ProjectFrame::CreateFolderContextMenu(const String& folder, int x, int y)
 {
     contextMenuPath_ = "";
@@ -425,8 +450,10 @@ void ProjectFrame::CreateFolderContextMenu(const String& folder, int x, int y)
     item->SetSkinImage(TBIDC("FolderCreateBitmap"));
     source->AddItem(item);
 
+    bool isJS = false;
     if (project->IsComponentsDirOrFile(folder))
     {
+        isJS = true;
         source->AddItem(new TBGenericStringItem("-"));
         item = new TBGenericStringItem("Create Component", TBIDC("create_component"));
         item->SetSkinImage(TBIDC("ComponentBitmap"));
@@ -434,6 +461,7 @@ void ProjectFrame::CreateFolderContextMenu(const String& folder, int x, int y)
     }
     else if (project->IsScriptsDirOrFile(folder))
     {
+        isJS = true;
         source->AddItem(new TBGenericStringItem("-"));
         item = new TBGenericStringItem("Create Script", TBIDC("create_script"));
         item->SetSkinImage(TBIDC("JavascriptBitmap"));
@@ -441,12 +469,19 @@ void ProjectFrame::CreateFolderContextMenu(const String& folder, int x, int y)
     }
     else if (project->IsModulesDirOrFile(folder))
     {
+        isJS = true;
         source->AddItem(new TBGenericStringItem("-"));
         item = new TBGenericStringItem("Create Module", TBIDC("create_module"));
         item->SetSkinImage(TBIDC("JavascriptBitmap"));
         source->AddItem(item);
     }
 
+    if (!isJS)
+    {
+        item = new TBGenericStringItem("Create 2D Level", TBIDC("create_2d_level"));
+        item->SetSkinImage(TBIDC("2DLevelBitmap"));
+        source->AddItem(item);
+    }
 
     source->AddItem(new TBGenericStringItem("-"));
     item = new TBGenericStringItem("Reveal in Finder", TBIDC("reveal_in_finder"));
@@ -513,8 +548,10 @@ void ProjectFrame::CreateContentContainerContextMenu(int x, int y)
 
     source->AddItem(item);
 
+    bool isJS = false;
     if (project->IsComponentsDirOrFile(currentContentFolder_))
     {
+        isJS = true;
         source->AddItem(new TBGenericStringItem("-"));
         item = new TBGenericStringItem("Create Component", TBIDC("create_component"));
         item->SetSkinImage(TBIDC("ComponentBitmap"));
@@ -522,6 +559,7 @@ void ProjectFrame::CreateContentContainerContextMenu(int x, int y)
     }
     else if (project->IsScriptsDirOrFile(currentContentFolder_))
     {
+        isJS = true;
         source->AddItem(new TBGenericStringItem("-"));
         item = new TBGenericStringItem("Create Script", TBIDC("create_script"));
         item->SetSkinImage(TBIDC("JavascriptBitmap"));
@@ -529,12 +567,20 @@ void ProjectFrame::CreateContentContainerContextMenu(int x, int y)
     }
     else if (project->IsModulesDirOrFile(currentContentFolder_))
     {
+        isJS = true;
         source->AddItem(new TBGenericStringItem("-"));
         item = new TBGenericStringItem("Create Module", TBIDC("create_module"));
         item->SetSkinImage(TBIDC("JavascriptBitmap"));
         source->AddItem(item);
     }
 
+    if (!isJS)
+    {
+        item = new TBGenericStringItem("Create 2D Level", TBIDC("create_2d_level"));
+        item->SetSkinImage(TBIDC("2DLevelBitmap"));
+        source->AddItem(item);
+    }
+
     source->AddItem(new TBGenericStringItem("-"));
     source->AddItem(new TBGenericStringItem("Reveal in Finder", TBIDC("reveal_in_finder")));
 

+ 1 - 1
Source/AtomicEditor/Source/UI/UIProjectFrame.h

@@ -47,7 +47,7 @@ public:
 
     void SelectCurrentContentFolder(const String& folder);
 
-    const String& GetCurrentContentFolder() { return currentContentFolder_; }
+    String GetCurrentContentFolder();
 
 private: