Esempio n. 1
0
        public override void InitState()
        {
            GameGlobal.ContentPath = ContentPath;
            base.InitState();

            var split1 = new HorizontalSplitterForm().Set(0, 0, AppInfo.W, AppInfo.H) as HorizontalSplitterForm;

            split1.SetSplit(AppInfo.H - AppInfo.H / 4);

            var tileBrowse = new TileBrowser().Set(0, 0, split1.BotDock.W, split1.BotDock.H) as TileBrowser;;

            split1.SetBottom(tileBrowse);

            var split2 = new HorizontalSplitterForm().Set(0, 0, split1.TopDock.W, split1.TopDock.H) as HorizontalSplitterForm;

            var menu = new MenuForm().Set(0, 0, AppInfo.W, 20) as MenuForm;

            UI.Menu = menu;

            var menu_map = menu.AddItem("Map");

            menu_map.Menu.AddItem("Load Map");
            menu_map.Menu.AddItem("Save Map");
            menu_map.Menu.AddItem("New Map");
            menu_map.Menu.AddItem("Exit", (b) => { Environment.Exit(1); });

            var menu_tiles = menu.AddItem("Tiles");

            var tiles_newSet = menu_tiles.Menu.AddItem("New Set");
            var tiles_addSet = menu_tiles.Menu.AddItem("Add set");

            tiles_newSet.Click = (b) =>
            {
                tileBrowse.newSet();
            };

            tiles_addSet.Click = (b) =>
            {
                var reqs = new RequestFileForm("Load tileset .ts..", ContentPath);
                SUI.Top       = reqs;
                reqs.Selected = (path) =>
                {
                    var ts = new TileSet(path);
                    ts.Load(path);
                    SUI.Top = null;

                    tileBrowse.AddTileSet(ts);
                };
            };


            menu.AddItem("Edit");
            //menu.AddItem("")
            split1.SetTop(split2);

            UIForm topForm = new UIForm().Set(0, 0, split2.TopDock.W, split2.TopDock.H);

            //topForm.Add(menu);
            //split2.SetTop(topForm);

            //split1.SetTop(split2);

            split2.SetSplit(50);

            var split3 = new VerticalSplitterForm().Set(0, 0, split2.BotDock.W, split2.BotDock.H) as VerticalSplitterForm;

            var toolRoot = new UIForm().Set(0, 0, split2.TopDock.W, split2.TopDock.H);


            split2.SetTop(toolRoot);

            split2.SetBottom(split3);

            split3.SetSplit(150);

            var nodeTree = new NodeGraphView().Set(0, 0, split3.LeftDock.W, split3.LeftDock.H, "Scene Nodes") as NodeGraphView;

            split3.SetLeft(nodeTree);



            var nodeBrowse = new NodeBrowser().Set(0, 0, split3.LeftDock.W, split3.LeftDock.H) as NodeBrowser;


            //split3.SetLeft(nodeBrowse);

            var mapEdit = new MapEditForm().Set(0, 0, split3.RightDock.W, split3.RightDock.H) as MapEditForm;

            nodeTree.SetMap(mapEdit.CurMap);

            split3.SetRight(mapEdit);

            SUI      = new UI();
            SUI.Root = split1;


            var toolBar = new ToolBarForm().Set(0, 0, toolRoot.W, 25) as ToolBarForm;

            var tb_paste     = toolBar.AddItem("Paste");
            var tb_rect      = toolBar.AddItem("Rect");
            var tb_oval      = toolBar.AddItem("Oval");
            var tb_fill      = toolBar.AddItem("Fill");
            var tb_smartfill = toolBar.AddItem("Smart-Fill");

            tb_paste.Click = () =>
            {
                mapEdit.Mode = EditMode.Paste;
            };

            tb_fill.Click = () =>
            {
                mapEdit.Mode = EditMode.Fill;
            };



            toolRoot.Add(toolBar);

            var mapMode  = new Texture2D("content/edit/mapmode.png", LoadMethod.Single, true);
            var tileMode = new Texture2D("content/edit/tiles.png", LoadMethod.Single, true);

            SUI.Dock.AddIcon(mapMode, 64);
            var mode_Tiles = SUI.Dock.AddIcon(tileMode, 64);

            mode_Tiles.Click = () => {
                UI.Menu = null;
                Vivid.App.VividApp.PushState(new MapViewer.States.TileSetEditor());
            };
        }
Esempio n. 2
0
        public override void InitState()
        {
            base.InitState();
            SUI = new Vivid.Resonance.UI();

            var main_menu = new MenuForm().Set(0, 0, AppInfo.W, 25, "") as MenuForm;

            UIForm ui_Root = new UIForm();

            ui_Root.Add(main_menu);

            SUI.Root = ui_Root;

            var menu_TileSet = main_menu.AddItem("TileSet");

            main_menu.AddItem("Edit");

            var win_NewSet  = new WindowForm().Set(50, 100, 500, 300, "New Tileset") as WindowForm;
            var newSet_Name = new TextBoxForm().Set(85, 5, 120, 25, "") as TextBoxForm;

            win_NewSet.body.Add(newSet_Name);
            var newSet_Label = new LabelForm().Set(5, 5, 35, 25, "SetName");

            var newSet_Create = new ButtonForm().Set(5, 245, 60, 25, "Create");

            win_NewSet.body.Add(newSet_Create);


            win_NewSet.body.Add(newSet_Label);


            void click_NewSet(int b)
            {
                SUI.Top = win_NewSet;
            }

            void click_Exit(int b)
            {
                Environment.Exit(1);
            }

            void click_LoadSet(int b)
            {
                var req = new RequestFileForm("Load set..", ContentPath);

                SUI.Top = req;

                req.Selected = (path) =>
                {
                    CurSet = new SpaceEngine.Map.TileSet.TileSet("");
                    CurSet.Load(path);

                    CurSetLayer.Fill(null);
                    setX = setY = 0;
                    foreach (var t in CurSet.Tiles)
                    {
                        CurSetLayer.SetTile(setX, setY, t);
                        setX++;
                    }

                    tView.UpdateGraph();
                    // tView.Graph.X = -32 + tView.W / 2;
                    // tView.Graph.Y = -32 + tView.H / 2;
                    SUI.Top = null;
                };
            }

            void click_SaveSet(int b)
            {
                var req = new RequestFileForm("Save set as..", ContentPath);

                SUI.Top = req;

                req.Selected = (path) =>
                {
                    CurSet.Save(path + ".ts");
                    SUI.Top = null;
                };
            }

            menu_TileSet.Menu.AddItem("New Set", click_NewSet);
            menu_TileSet.Menu.AddItem("Load Set", click_LoadSet);
            menu_TileSet.Menu.AddItem("Save Set", click_SaveSet);
            menu_TileSet.Menu.AddItem("Exit", click_Exit);

            ui_Root.Add(CrTileSetEditor());
        }
Esempio n. 3
0
        public override void InitState()
        {
            // GameGlobal.ContentPath = ContentPath;
            base.InitState();

            var split1 = new HorizontalSplitterForm().Set(0, 0, AppInfo.W, AppInfo.H) as HorizontalSplitterForm;

            split1.SetSplit(AppInfo.H - AppInfo.H / 4);

            tileBrowse = new TileBrowser().Set(0, 0, split1.BotDock.W, split1.BotDock.H) as TileBrowser;;

            split1.SetBottom(tileBrowse);

            var split2 = new HorizontalSplitterForm().Set(0, 0, split1.TopDock.W, split1.TopDock.H) as HorizontalSplitterForm;

            var menu = new MenuForm().Set(0, 0, AppInfo.W, 20) as MenuForm;

            UI.Menu = menu;

            var menu_map = menu.AddItem("Map");

            var loadm = menu_map.Menu.AddItem("Load Map");

            loadm.Click = (b) =>
            {
                var req = new RequestFileForm("Select map to load..", GameGlobal.ProjectPath);
                SUI.Top      = req;
                req.Selected = (path) =>
                {
                    mapEdit.LoadMap(path);
                    SUI.Top = null;
                };
            };


            var savem = menu_map.Menu.AddItem("Save Map");

            savem.Click = (b) =>
            {
                var req = new RequestFileForm("Select a name to save..", GameGlobal.ProjectPath);
                SUI.Top      = req;
                req.Selected = (path) =>
                {
                    mapEdit.SaveMap(path);
                    SUI.Top = null;
                };
            };

            var newm = menu_map.Menu.AddItem("New Map");

            newm.Click = (b) =>
            {
                mapEdit.NewMap();


                nodeTree.SetMap(GameGlobal.EditMap);

                SaveEditState();
            };

            var exitm = menu_map.Menu.AddItem("Exit");

            exitm.Click = (b) =>
            {
                SaveEditState();
                Environment.Exit(0);
            };

            //SaveEditState()
            //Environment.Exit(1)


            var menu_tiles = menu.AddItem("Tiles");

            var tiles_newSet = menu_tiles.Menu.AddItem("New Set");
            var tiles_addSet = menu_tiles.Menu.AddItem("Add set");

            tiles_newSet.Click = (b) =>
            {
                tileBrowse.newSet();
                SaveEditState();
            };

            tiles_addSet.Click = (b) =>
            {
                var reqs = new RequestFileForm("Load tileset .ts..", GameGlobal.ContentPath);
                SUI.Top = reqs;

                reqs.Selected = (path) =>
                {
                    var ts = new TileSet(path);
                    ts.Load(path);
                    SUI.Top = null;

                    tileBrowse.AddTileSet(ts);

                    SaveEditState();
                };
            };


            menu.AddItem("Edit");
            //menu.AddItem("")
            split1.SetTop(split2);

            UIForm topForm = new UIForm().Set(0, 0, split2.TopDock.W, split2.TopDock.H);

            //topForm.Add(menu);
            //split2.SetTop(topForm);

            //split1.SetTop(split2);

            split2.SetSplit(50);

            var split3 = new VerticalSplitterForm().Set(0, 0, split2.BotDock.W, split2.BotDock.H) as VerticalSplitterForm;

            var toolRoot = new UIForm().Set(0, 0, split2.TopDock.W, split2.TopDock.H);


            split2.SetTop(toolRoot);

            split2.SetBottom(split3);

            split3.SetSplit(150);

            nodeTree = new NodeGraphView().Set(0, 0, split3.LeftDock.W, split3.LeftDock.H, "Scene Nodes") as NodeGraphView;

            split3.SetLeft(nodeTree);



            var nodeBrowse = new NodeBrowser().Set(0, 0, split3.LeftDock.W, split3.LeftDock.H) as NodeBrowser;


            //split3.SetLeft(nodeBrowse);
            var mapSplit = new VerticalSplitterForm().Set(0, 0, split3.RightDock.W, split3.RightDock.H) as VerticalSplitterForm;

            var classIn = new InspectorForm().Set(0, 0, mapSplit.RightDock.W, mapSplit.RightDock.H) as InspectorForm;

            mapEdit = new MapEditForm().Set(0, 0, split3.RightDock.W, split3.RightDock.H) as MapEditForm;

            mapEdit.Selected = (node) =>
            {
                classIn.SetObj(node);

                //       if (node == null) return;
                //Console.WriteLine("Selected:" + node.Name);
            };

            nodeTree.SetMap(GameGlobal.EditMap);

            split3.SetRight(mapSplit);

            mapSplit.SetLeft(mapEdit);


            mapSplit.SetRight(classIn);

            mapSplit.SetSplit(split3.RightDock.W - 250);


            SUI      = new UI();
            SUI.Root = split1;


            var toolBar = new ToolBarForm().Set(0, 0, toolRoot.W, 25) as ToolBarForm;

            var tb_pick      = toolBar.AddItem("Pick");
            var tb_paste     = toolBar.AddItem("Paste");
            var tb_rect      = toolBar.AddItem("Rect");
            var tb_oval      = toolBar.AddItem("Oval");
            var tb_fill      = toolBar.AddItem("Fill");
            var tb_smartfill = toolBar.AddItem("Smart-Fill");

            tb_pick.Click = () =>
            {
                mapEdit.Mode = EditMode.Pick;
                mapEdit.Rebuild();
            };

            tb_paste.Click = () =>
            {
                mapEdit.Mode = EditMode.Paste;
                mapEdit.Rebuild();
            };


            tb_fill.Click = () =>
            {
                mapEdit.Mode = EditMode.Fill;
                mapEdit.Rebuild();
            };



            toolRoot.Add(toolBar);

            var mapMode  = new Texture2D("content/edit/mapmode.png", LoadMethod.Single, true);
            var tileMode = new Texture2D("content/edit/tiles.png", LoadMethod.Single, true);

            SUI.Dock.AddIcon(mapMode, 64);
            var mode_Tiles = SUI.Dock.AddIcon(tileMode, 64);

            mode_Tiles.Click = () => {
                UI.Menu = null;
                Vivid.App.VividApp.PushState(new MapEditor.States.TileSetEditor());
            };

            LoadEditState();
        }