Beispiel #1
0
        public NewProjectForm()
        {
            AfterSet = () =>
            {
                Title.Text = "New Project";

                if (ProjectName == null)
                {
                    var pnlab = new LabelForm().Set(5, 5, 120, 20, "Project Name");
                    var ptlab = new LabelForm().Set(5, 35, 120, 20, "Project Type");
                    var pplab = new LabelForm().Set(5, 95, 120, 20, "Project Path");

                    Body.Add(pnlab);
                    Body.Add(ptlab);
                    Body.Add(pplab);

                    ProjectName = new TextBoxForm().Set(115, 10, 220, 20) as TextBoxForm;
                    ProjectType = new DropDownListForm().Set(115, 35, 220, 20) as DropDownListForm;
                    ProjectPath = new TextBoxForm().Set(115, 100, 220, 20) as TextBoxForm;

                    ProjectType.AddItem("2D Map Game");
                    ProjectType.AddItem("3D Game");

                    var BrowsePath = new ButtonForm().Set(280, 125, 80, 25, "Browse") as ButtonForm;

                    CreateProject = new ButtonForm().Set(20, 230, 130, 25, "Create Project") as ButtonForm;

                    Body.Add(CreateProject);

                    CreateProject.Click = (b) =>
                    {
                        Vivid.Project.VividProject new_proj = new Vivid.Project.VividProject();
                        new_proj.Path = NewPath;
                        new_proj.Name = ProjectName.Text;
                        switch (ProjectType.CurrentItem)
                        {
                        case "2D Map Game":
                            new_proj.Type = Vivid.Project.ProjectType.GameMap;
                            break;

                        case "3D Game":
                            new_proj.Type = Vivid.Project.ProjectType.Game3D;
                            break;
                        }

                        VividManager.States.ManagerMain.AddProject(new_proj);

                        UI.CurUI.Top = null;
                    };

                    BrowsePath.Click = (b) =>
                    {
                        var req = new RequestFileForm("Select a empty folder for the project..", "C:/", true);
                        UI.CurUI.Top.Add(req);

                        req.Selected = (path) =>
                        {
                            ProjectPath.Text = path;
                            NewPath          = path;
                            UI.CurUI.Top.Forms.Remove(req);
                        };
                    };

                    Body.Add(ProjectName);
                    Body.Add(ProjectType);
                    Body.Add(ProjectPath);
                    Body.Add(BrowsePath);
                }
            };
        }
Beispiel #2
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);
        }