Ejemplo n.º 1
0
        public AssetManagerLayout(
            IAssetManagerProvider assetManagerProvider,
            I2DRenderUtilities renderUtilities,
            IAssetLoader[] loaders,
            CanvasEntity canvasEntity)
        {
            this.m_CanvasEntity = canvasEntity;

            var toolbarContainer = new HorizontalContainer();
            toolbarContainer.AddChild(new SingleContainer(), "*");
            toolbarContainer.AddChild(this.Bake = new Button { Text = "Bake" }, "50");
            toolbarContainer.AddChild(this.MarkDirty = new Button { Text = "Mark Dirty" }, "80");

            var assetContainer = new VerticalContainer();
            assetContainer.AddChild(toolbarContainer, "20");
            assetContainer.AddChild(this.EditorContainer = new SingleContainer(), "*");

            var contentContainer = new HorizontalContainer();
            contentContainer.AddChild(this.AssetTree = new TreeView(), "210");
            contentContainer.AddChild(assetContainer, "*");

            var menuContainer = new VerticalContainer();
            menuContainer.AddChild(this.MainMenu = new MainMenu(assetManagerProvider, renderUtilities), "24");
            menuContainer.AddChild(contentContainer, "*");
            menuContainer.AddChild(this.Status = new Label { Text = "..." }, "24");
            this.SetChild(menuContainer);

            var exitItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Exit" };
            var bakeAllItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Bake All" };
            var assetManagerMenuItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Asset Manager" };
            exitItem.Click += (sender, e) =>
            {
                if (this.ExitClick != null)
                    this.ExitClick(sender, e);
            };
            bakeAllItem.Click += (sender, e) =>
            {
                if (this.BakeAllClick != null)
                    this.BakeAllClick(sender, e);
                (bakeAllItem.Parent as MenuItem).Active = false;
            };
            assetManagerMenuItem.AddChild(bakeAllItem);
            assetManagerMenuItem.AddChild(exitItem);
            this.MainMenu.AddChild(assetManagerMenuItem);

            var newAssetMenuItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Create New..." };
            foreach (var loader in loaders.Where(x => x.CanNew()))
            {
                var createNewMenuItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = loader.GetType().Name };
                createNewMenuItem.Click += (sender, e) =>
                {
                    if (this.PromptWindow == null)
                    {
                        this.PromptForCreation(loader.GetType().Name, (_, _2) =>
                        {
                            if (this.CreateNameEntered != null)
                                this.CreateNameEntered(this, new CreateEventArgs(loader));
                        });
                    }
                };
                newAssetMenuItem.AddChild(createNewMenuItem);
            }
            this.MainMenu.AddChild(newAssetMenuItem);
        }