Esempio n. 1
0
        public void Rebuild()
        {
            tree.Root = new Vivid.Resonance.Forms.TreeNode("Map Root");

            var menu = tree.ContextMenu = new Vivid.Resonance.Forms.ContextMenuForm();


            var m_nodes = menu.AddItem("Nodes");

            var m_logic = m_nodes.Menu.AddItem("Logic");

            var l_marker = m_logic.Menu.AddItem("Marker");

            var n_lights = m_nodes.Menu.AddItem("Lights");

            var l_pointL = n_lights.Menu.AddItem("Point Light");

            l_marker.Click = () =>
            {
                var gm = new Vivid.Scene.GraphMarker();
                gm.SetPos(300, 300);
                GameGlobal.EditMap.AddMarker(gm);
            };

            l_pointL.Click = () =>
            {
                var nl = new Vivid.Scene.GraphLight();

                nl.SetPos(250, 250);
                nl.Range = 800;
                nl.Z     = 0.1f;
                map.AddLight(nl);
                Console.WriteLine("Added light to scene.");
            };
        }
Esempio n. 2
0
        public void Rebuild()
        {
            tree.Root = new Vivid.Resonance.Forms.TreeNode("Map Root");

            var menu = tree.ContextMenu = new Vivid.Resonance.Forms.ContextMenuForm();


            var m_nodes = menu.AddItem("Nodes");

            var n_lights = m_nodes.Menu.AddItem("Lights");

            var l_pointL = n_lights.Menu.AddItem("Point Light");

            l_pointL.Click = () =>
            {
                var nl = new Vivid.Scene.GraphLight();

                nl.SetPos(250, 250);
                nl.Range = 800;
                nl.Z     = 0.1f;
                map.AddLight(nl);
                Console.WriteLine("Added light to scene.");
            };
        }
Esempio n. 3
0
        public WindowForm CrTileSetEditor()
        {
            setX      = 0;
            setY      = 0;
            CurSetMap = new Map();

            var setLight = new Vivid.Scene.GraphLight();

            setLight.SetPos(120, 120);
            setLight.SetZ(40);
            setLight.Diffuse  = new OpenTK.Vector3(1, 1, 1);
            setLight.Specular = new OpenTK.Vector3(1, 1, 1);
            setLight.Range    = 1200;

            CurSetMap.AddLight(setLight);

            WindowForm set_Editor = new WindowForm().Set(200, 200, 700, 600, "TileSet") as WindowForm;

            ToolBarForm tools = new ToolBarForm().Set(0, 0, 700, 25) as ToolBarForm;



            set_Editor.body.Add(tools);

            MapViewForm tileSet_View = new MapViewForm(CurSetMap).Set(0, 25, set_Editor.body.W, set_Editor.body.H - 25) as MapViewForm;

            tView = tileSet_View;
            //CurSetMap = new Map(1);
            tView.MouseLeave = () =>
            {
                ClearHL(tileSet_View);
            };
            tView.MouseMove = (x, y, dx, dy) =>
            {
                if (tView.Graph != null)
                {
                    var node = tView.Graph.Pick(x, y);

                    if (node != null)
                    {
                        tView.Map.HL.Clear();
                        tView.Map.HighlightTile(node.TileX, node.TileY);
                        tileSet_View.UpdateGraph();
                        // tileSet_View.Graph.X = -32 + tileSet_View.W / 2;
                        //tileSet_View.Graph.Y = -32 + tileSet_View.H / 2;
                        // Console.WriteLine("MX:" + x + " MY:" + y);
                    }
                    else
                    {
                        ClearHL(tileSet_View);
                    }
                }
            };

            CurSetLayer = CurSetMap.AddLayer(new SpaceEngine.Map.Layer.MapLayer(setWidth, setHeight));



            set_Editor.body.Add(tileSet_View);

            void click_AddFolder()
            {
                var req = new RequestFileForm("Select a folder to scan..", ContentPath, true);

                SUI.Top = req;

                req.Selected = (path) =>
                {
                    Console.WriteLine("Folder:" + path + ":");
                    SUI.Top = null;

                    var di = new DirectoryInfo(path);

                    foreach (var file in di.GetFiles())
                    {
                        switch (file.Extension)
                        {
                        case ".png":
                        case ".bmp":
                        case ".jpg":
                        case ".tga":
                            FAddTile(file.FullName);

                            break;
                        }
                    }

                    ResetMap(tView);
                };


                // var file
            }

            tools.AddItem("Clear");
            var tile_Add       = tools.AddItem("Add Tile");
            var tile_AddFolder = tools.AddItem("Add Folder");

            tile_AddFolder.Click = click_AddFolder;

            void click_AddTile()
            {
                var addReq = new RequestFileForm("Add Tile to set...", ContentPath);

                SUI.Top = addReq;

                addReq.Selected = (path) =>
                {
                    Console.WriteLine("Loading Tile:" + path);

                    FAddTile(path);
                    //CurSetMap.HighlightTile(setX - 1, setY);
                    ResetMap(tileSet_View);
                    //tileSet_View.Graph.X = (CurSetMap.Layers[0].Width * 64)/2;
                    // tileSet_View.Graph.Y = (CurSetMap.Layers[0].Height * 64) / 2;
                    // tileSet_View.Graph.X -= 64;
                    SUI.Top = null;
                };
            }

            tile_Add.Click = click_AddTile;


            return(set_Editor);
        }
Esempio n. 4
0
        public WindowForm CrTileSetEditor()
        {
            setX      = 0;
            setY      = 0;
            CurSetMap = new Map();


            var setLight = new Vivid.Scene.GraphLight();

            setLight.SetPos(120, 120);
            setLight.SetZ(40);
            setLight.Diffuse  = new OpenTK.Vector3(1, 1, 1);
            setLight.Specular = new OpenTK.Vector3(1, 1, 1);
            setLight.Range    = 1200;

            //  CurSetMap.AddLight(setLight);


            WindowForm set_Editor = new WindowForm().Set(200, 200, 700, 600, "TileSet") as WindowForm;

            ToolBarForm tools = new ToolBarForm().Set(0, 0, 700, 25) as ToolBarForm;



            set_Editor.Body.Add(tools);

            MapViewForm tileSet_View = new MapViewForm(CurSetMap).Set(0, 25, set_Editor.Body.W, set_Editor.Body.H - 25) as MapViewForm;

            tView = tileSet_View;


            // tileSet_View.LockCam = true;
            //tileSet_View.LockX = (set_Editor.Body.W / 2)-32;
            //tileSet_View.LockY = (set_Editor.Body.H / 2)-48;
            bool move_on = false;

            //CurSetMap = new Map(1);
            tView.MouseLeave = () =>
            {
                ClearHL(tileSet_View);
            };
            tView.MouseUp = (b) =>
            {
                if (b == 1)
                {
                    move_on = false;
                }
            };
            tView.MouseDown = (b) =>
            {
                if (b == 1)
                {
                    move_on = true;
                }
                if (CurTile != null)
                {
                    Inspect.SetObj(CurTile);
                }
            };
            tView.MouseMove = (x, y, dx, dy) =>
            {
                if (tView.Graph != null)
                {
                    if (move_on == true)
                    {
                        tView.Graph.Move(-dx, -dy);
                        if (tView.Graph.X > (tileSet_View.W / 2) - 32)
                        {
                            tView.Graph.X = ((tileSet_View.W / 2) - 32) - 6;
                        }
                        ;
                        if (tView.Graph.Y > (tileSet_View.H / 2) - 32)
                        {
                            tView.Graph.Y = ((tileSet_View.H / 2) - 32) - 6;
                        }
                    }

                    AppInfo.RW = tView.MapFrame.IW;
                    AppInfo.RH = tView.MapFrame.IH;
                    var node = tView.Graph.Pick(x, y);
                    AppInfo.RW = AppInfo.W;
                    AppInfo.RH = AppInfo.H;
                    if (node != null)
                    {
                        tView.Map.HL.Clear();
                        tView.Map.HighlightTile(node.TileX, node.TileY);
                        tileSet_View.UpdateGraph();
                        //Inspect.SetObj(node.Obj[0]);
                        CurTile = node.Obj[0];
                        // tileSet_View.Graph.X = -32 + tileSet_View.W / 2;
                        //tileSet_View.Graph.Y = -32 + tileSet_View.H / 2;
                        // Console.WriteLine("MX:" + x + " MY:" + y);
                    }
                    else
                    {
                        ClearHL(tileSet_View);
                    }
                }
            };

            CurSetLayer = CurSetMap.AddLayer(new Vivid.Map.Layer.MapLayer(setWidth, setHeight, CurSetMap));



            set_Editor.Body.Add(tileSet_View);

            void click_AddFolder()
            {
                var req = new RequestFileForm("Select a folder to scan..", GameGlobal.ContentPath, true);

                SUI.Top = req;

                req.Selected = (path) =>
                {
                    Console.WriteLine("Folder:" + path + ":");
                    SUI.Top = null;

                    var di = new DirectoryInfo(path);

                    foreach (var file in di.GetFiles())
                    {
                        switch (file.Extension)
                        {
                        case ".png":
                        case ".bmp":
                        case ".jpg":
                        case ".tga":

                            if (file.FullName.ToLower().Contains("nrm"))
                            {
                                continue;
                            }

                            FAddTile(file.FullName);

                            break;
                        }
                    }

                    ResetMap(tView);
                };


                // var file
            }

            tools.AddItem("Clear");
            var tile_Add       = tools.AddItem("Add Tile");
            var tile_AddFolder = tools.AddItem("Add Folder");

            tile_AddFolder.Click = click_AddFolder;

            void click_AddTile()
            {
                var addReq = new RequestFileForm("Add Tile to set...", GameGlobal.ContentPath);

                SUI.Top = addReq;

                addReq.Selected = (path) =>
                {
                    Console.WriteLine("Loading Tile:" + path);

                    FAddTile(path);
                    //CurSetMap.HighlightTile(setX - 1, setY);
                    ResetMap(tileSet_View);
                    //tileSet_View.Graph.X = (CurSetMap.Layers[0].Width * 64)/2;
                    // tileSet_View.Graph.Y = (CurSetMap.Layers[0].Height * 64) / 2;
                    // tileSet_View.Graph.X -= 64;
                    SUI.Top = null;
                };
            }

            tile_Add.Click = click_AddTile;


            return(set_Editor);
        }