Exemplo n.º 1
0
        public override void InitState()
        {
            base.InitState();

            FXGrid = new Vivid.PostProcess.Processes.PPVirtualGrid();

            SUI = new UI();

            vid = new VideoForm().Set(0, 0, AppInfo.W, AppInfo.H) as VideoForm;
            Console.WriteLine("Play video");
            vid.SetVideo("Corona/Video/intro2.mov");
            SUI.Root      = vid;
            SUI.FadeUI    = false;
            SUI.FadeAlpha = 0.0f;
            vid.Click     = (b) =>
            {
                vid.Stop();
                VividApp.PushState(new ScopeNineMenu());
            };


            var lab = new LabelForm().Set(AppInfo.W / 2 - 110, AppInfo.H - 80, 300, 30, "PRESS START TO CONTINUE") as LabelForm;

            vid.Add(lab);
        }
Exemplo n.º 2
0
        public override void InitState()
        {
            SUI = new UI();


            var bg = new ImageForm().Set(0, 0, AppInfo.W, AppInfo.H, "").SetImage(new Texture2D("FoomED/bg1.jpg", LoadMethod.Single, false));

            SUI.Root.Add(bg);

            var back = new ButtonForm().Set(5, 5, 80, 30, "Back");

            bg.Add(back);

            back.Click = (b) =>
            {
                FusionApp.PopState();
            };

            var lab = new LabelForm().Set(25, 80, 200, 30, "Map Title:");

            bg.Add(lab);

            TextBoxForm map_name = new TextBoxForm().Set(120, 75, 200, 30, "") as TextBoxForm;

            bg.Add(map_name);

            map_name.Enter = (txt) =>
            {
                Directory.CreateDirectory("Game/Maps/" + txt + "/");

                var edit_state = new EditMapState(txt);
                FusionApp.PushState(edit_state);
            };
        }
Exemplo n.º 3
0
        public WelcomeForm()
        {
            var ul = new LabelForm().Set(20, 60, 120, 25, "Username");

            Add(ul);
            var ub = new TextBoxForm().Set(120, 63, 170, 25);

            Add(ub);

            ul = new LabelForm().Set(20, 110, 120, 25, "Password");
            var pb = new TextBoxForm().Set(120, 113, 170, 25);

            Add(pb);
            Add(ul);

            var eb = new ButtonForm().Set(20, 200, 90, 25, "Login");

            Add(eb);

            eb.Click = (b) =>
            {
                LogIn?.Invoke(ub.Text, pb.Text);
            };

            var qb = new ButtonForm().Set(215, 200, 90, 25, "Exit");

            Add(qb);

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

            var cab = new ButtonForm().Set(125, 200, 80, 25, "Create");

            Add(cab);

            cab.Click = (b) =>
            {
                Create?.Invoke(ub.Text, pb.Text);
            };
        }
Exemplo n.º 4
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());
        }
Exemplo n.º 5
0
    //
    static void Main(string[] args)
    {
        LabelForm lf = new LabelForm();

        Application.Run(lf);
    }
Exemplo n.º 6
0
        public MapEditForm()


        {
            var layDown = new ButtonForm().Set(140, -20, 30, 20, "\\/");
            var layUp   = new ButtonForm().Set(240, -20, 30, 20, "/\\");

            lay = new TextBoxForm().Set(175, -20, 70, 20, "0") as TextBoxForm;
            Body.Add(layDown);
            Body.Add(layUp);
            Body.Add(lay);

            layDown.Click = (b) =>
            {
                EditZ--;
                if (EditZ < 0)
                {
                    EditZ = 0;
                }
                lay.Text = EditZ.ToString();
            };
            layUp.Click = (b) =>
            {
                EditZ++;
                if (EditZ >= View.Map.Layers.Count)
                {
                    EditZ = View.Map.Layers.Count - 1;
                }
                ;
                lay.Text = EditZ.ToString();
            };
            Tab           = new TabForm();
            moveForm      = new MoveNodeForm().Set(0, 0, 0, 0) as MoveNodeForm;
            moveForm.View = View;
            NewMap();

            var l1 = new Vivid.Scene.GraphLight();
            var l2 = new Vivid.Scene.GraphLight();
            var l3 = new Vivid.Scene.GraphLight();

            //            View.Map.AddLight(l1);
            //          View.Map.AddLight(l2);
            //        View.Map.AddLight(l3);

            cLab = null;
            ; var TView = View;

            float r = 0;

            Update = () =>

            {
                if (lMode != Mode)
                {
                    updateModeLabel();
                    lMode = Mode;
                }
                View.UpdateGraph();

                /*
                 * TView.Map.Lights[0].SetPos(300,300);
                 * TView.Map.Lights[0].Range = 450;
                 * TView.Map.Lights[0].Diffuse = new OpenTK.Vector3(0, 1, 1);
                 * TView.Map.Lights[1].SetPos(650, 400);
                 * TView.Map.Lights[1].Range = 400;
                 * TView.Map.Lights[1].Diffuse = new OpenTK.Vector3(1, 1, 0);
                 * TView.Map.Lights[0].Z = 0.1f;
                 * TView.Map.Lights[1].Z = 0.1f;
                 * TView.Map.Lights[2].Z = 0.1f;
                 * TView.Map.Lights[2].Diffuse = new OpenTK.Vector3(1, 0, 1);
                 * TView.Map.Lights[2].Range = 600;
                 * TView.Map.Lights[2].SetPos(150, 150);
                 */
            };

            void updateModeLabel()
            {
                if (cLab != null)
                {
                    View.Forms.Remove(cLab);
                }
                cLab = new LabelForm().Set(2, -23, 30, 20, "Mode:Paste") as LabelForm;

                View.Add(cLab);
                Rebuild();
            }

            updateModeLabel();

            // Body.Add(View);



            AfterSet = () =>
            {
                Tab.W = W;
                Tab.H = Body.H;
                View.Set(0, 0, Body.W, Body.H);
                View.UpdateGraph();
            };
        }
Exemplo n.º 7
0
        private void BuildUI(dynamic obj)
        {
            if (MapSet == null)
            {
                MapSet = new Texture2D("data/ui/mapset.png", LoadMethod.Single, false);
                NoMap  = new Texture2D("data/ui/nomap.png", LoadMethod.Single, false);
                Blank  = new Texture2D("data/ui/blank.jpg", LoadMethod.Single, false);
                CamPic = new Texture2D("data/ui/campic1.jpg", LoadMethod.Single, true);
            }
            Body.Forms.Clear();

            if (scroller == null)
            {
                scroller                 = new ScrollBarV().Set(Body.W - 10, 1, 10, Body.H) as ScrollBarV;
                scroller.ViewX           = GX;
                scroller.ViewY           = GY + 25;
                scroller.ViewW           = W;
                scroller.ViewH           = H - 35;
                scroller.ScrollBut.ViewX = GX;
                scroller.ScrollBut.ViewY = GY + 25;
                scroller.ScrollBut.ViewW = W;
                scroller.ScrollBut.ViewH = H - 35;
            }

            scroller.ValueChange = (v) =>
            {
                foreach (var f in Body.Forms)
                {
                    if (f == scroller)
                    {
                        continue;
                    }
                    f.OffY = (int)-scroller.Cur;
                    Console.WriteLine("sc:" + scroller.Cur);
                }
            };

            Body.Add(scroller);



            var lab = new LabelForm().Set(5, 10, 120, 25, "Class:" + obj.Name + " Type:" + obj.GetType().Name);

            Body.Add(lab);

            object t = obj as object;

            int py = 40;

            if (Obj is Vivid.Scripting.NodeScript)
            {
                var applyBut = new ButtonForm().Set(5, py, 80, 25, "Update") as ButtonForm;
                applyBut.Click = (b) =>
                {
                    Obj.ApplyInEditor();
                };

                Body.Add(applyBut);

                py += 35;
            }

            foreach (var prop in t.GetType().GetProperties())
            {
                var prop_lab = new LabelForm().Set(5, py, 80, 25, prop.Name);

                py += 30;

                var name = prop.PropertyType;
                //Console.WriteLine("Name:" + name.FullName);

                Console.WriteLine("Type:" + name.Name);

                var nn = name.Name;

                if (name.Name.Contains("List"))
                {
                    nn = "List";
                }

                if (prop.PropertyType.IsEnum)
                {
                    nn = "Enum";
                }



                bool use = false;
                switch (nn)
                {
                case "Enum":

                    var p_enum = prop.GetValue(Obj);



                    DropDownListForm list_f = new DropDownListForm().Set(5, py, 160, 25) as DropDownListForm;



                    foreach (var enum_name in prop.PropertyType.GetEnumNames())
                    {
                        list_f.AddItem(enum_name);
                    }

                    list_f.CurrentItem = p_enum.ToString();

                    list_f.SelectedItem = (item) =>
                    {
                        string ai = "";
                        int    ee = 0;
                        foreach (var enum_name in prop.PropertyType.GetEnumNames())
                        {
                            if (enum_name == item)
                            {
                                break;
                            }
                            ee++;
                        }
                        prop.SetValue(Obj, ee);
                    };

                    Body.Add(list_f);

                    py += 35;

                    use = true;
                    break;

                case "List":

                    var     p_list = prop.GetValue(Obj);
                    dynamic p_l    = p_list;
                    if (p_l != null)
                    {
                        foreach (dynamic litem in p_l)
                        {
                            var l_itemname = new TextBoxForm().Set(5, py, 180, 25, litem.GetName());
                            var l_edit     = new ButtonForm().Set(190, py, 60, 25, "Edit") as ButtonForm;
                            var l_remove   = new ButtonForm().Set(260, py, 80, 25, "Remove") as ButtonForm;


                            Body.Add(l_itemname);
                            Body.Add(l_remove);
                            Body.Add(l_edit);

                            l_edit.Click = (b) =>
                            {
                                SetObj(litem);
                            };

                            l_remove.Click = (b) =>
                            {
                                p_l.Remove(litem);
                                SetObj(Obj);
                            };


                            py += 35;
                        }
                    }

                    var l_dragzone = new DragZoneForm().Set(5, py, 180, 25) as DragZoneForm;

                    l_dragzone.DraggedObj = (o) =>
                    {
                        if (o.DragObj is ContentEntry)
                        {
                            var ce = o.DragObj as ContentEntry;
                            var le = ce.Load();
                            p_l.Add(le);
                            if (le is Vivid.Scripting.NodeScript)
                            {
                                le.Node = Obj;
                            }
                            SetObj(Obj);
                        }
                        ;
                    };
                    Body.Add(l_dragzone);

                    py += 35;

                    use = true;

                    break;

                case "Scripts":



                    var p_al = prop.GetValue(Obj) as System.Collections.Generic.List <Vivid.Scripting.NodeScript>;

                    foreach (var s in p_al)
                    {
                        var scr_name = new TextBoxForm().Set(5, py, 180, 25, s.GetType().Name);
                        var scr_edit = new ButtonForm().Set(190, py, 80, 25, "Edit") as ButtonForm;
                        py += 35;

                        Body.Add(scr_name);
                        Body.Add(scr_edit);

                        scr_edit.Click = (b) =>
                        {
                            SetObj(s);
                        };
                    }

                    use = true;
                    break;

                case "ClassLin4":



                    break;

                case "TextureCube":

                    var texc = prop.GetValue(Obj) as TextureCube;

                    var tc_name = new TextBoxForm().Set(5, py, 120, 25, "EnvMap");

                    Body.Add(tc_name);

                    py += 30;

                    Texture2D pi = null;

                    if (texc == null)
                    {
                        pi = NoMap;
                    }
                    else
                    {
                        pi = MapSet;
                    }
                    //     pi = Blank;

                    var texc_p = new ImageForm().Set(5, py, 128, 128, "").SetImage(pi) as ImageForm;

                    Body.Add(texc_p);

                    texc_p.CanDrop = true;
                    py            += 136;

                    texc_p.DraggedObj = (obj2) =>
                    {
                        var drago = obj2 as DragObject;
                        Console.WriteLine("Prev!");
                        if (drago.DragObj is ContentEntry)
                        {
                            var ce   = drago.DragObj as ContentEntry;
                            var ntex = new TextureCube(ce.FullPath);
                            //Console.WriteLine("Setting Content");
                            try
                            {
                                prop.SetValue(Obj, ntex);
                                SetObj(Obj);
                            }
                            catch
                            {
                            }
                        }
                    };

                    use = true;

                    break;

                case "Tex2D":
                    var tex = prop.GetValue(Obj) as Vivid.Tex.Tex2D;

                    if (tex == null)
                    {
                        prop.SetValue(Obj, WhiteTex2D);
                        tex = WhiteTex2D;
                    }

                    var t_name = new TextBoxForm().Set(5, py, 120, 25, tex.Name);

                    Body.Add(t_name);

                    py += 30;

                    var m_prev = new ImageForm().Set(5, py, 128, 128, "").SetImage(tex.ToTexture2D()) as ImageForm;

                    var set_image = new ButtonForm().Set(140, py, 80, 25, "Set Image") as ButtonForm;

                    Body.Add(set_image);

                    set_image.Click = (b) =>
                    {
                        var sir = new RequestFileForm("Select image..", GameGlobal.ContentPath);

                        UI.CurUI.Top = sir;

                        sir.Selected = (path) =>
                        {
                            UI.CurUI.Top = null;
                            prop.SetValue(Obj, new Vivid.Tex.Tex2D(path, true));
                            SetObj(Obj);
                        };
                    };

                    py += 136;

                    //var nm_name = new TextBoxForm().Set(5,py,120,25,N)

                    m_prev.DraggedObj = (o) =>
                    {
                        var drago = o as DragObject;
                        Console.WriteLine("Prev!");
                        if (drago.DragObj is ContentEntry)
                        {
                            var ce   = drago.DragObj as ContentEntry;
                            var ntex = new Texture2D(ce.FullPath, LoadMethod.Single, true);
                            //Console.WriteLine("Setting Content");
                            try
                            {
                                prop.SetValue(Obj, ntex.ToTex2D());
                                SetObj(Obj);
                            }
                            catch
                            {
                            }
                        }
                    };

                    m_prev.CanDrop = true;

                    Body.Add(m_prev);

                    use = true;

                    break;

                case "Texture2D":

                    var tex2 = prop.GetValue(Obj) as Texture2D;

                    if (tex2 == null)
                    {
                        prop.SetValue(Obj, WhiteTex);
                        tex2 = WhiteTex;
                    }

                    var t_name2 = new TextBoxForm().Set(5, py, 120, 25, tex2.Name);

                    Body.Add(t_name2);

                    py += 30;

                    var m_prev2 = new ImageForm().Set(5, py, 128, 128, "").SetImage(tex2) as ImageForm;


                    py += 136;

                    //var nm_name = new TextBoxForm().Set(5,py,120,25,N)

                    m_prev2.DraggedObj = (o) =>
                    {
                        var drago = o as DragObject;
                        Console.WriteLine("Prev!");
                        if (drago.DragObj is ContentEntry)
                        {
                            var ce   = drago.DragObj as ContentEntry;
                            var ntex = new Texture2D(ce.FullPath, LoadMethod.Single, true);
                            //Console.WriteLine("Setting Content");
                            try
                            {
                                prop.SetValue(Obj, ntex);
                                SetObj(Obj);
                            }
                            catch
                            {
                            }
                        }
                    };

                    m_prev2.CanDrop = true;

                    Body.Add(m_prev2);

                    use = true;

                    break;

                case "ScriptList":

                    var sl = prop.GetValue(Obj) as Vivid.Script.ScriptList;

                    use = true;

                    int num = 0;
                    foreach (var ns in sl.Scripts)
                    {
                        var scr_name_lab = new TextBoxForm().Set(5, py, 240, 25, "Script" + num + ":" + ns.Name);
                        Body.Add(scr_name_lab);
                        num++;
                        py += 30;
                    }

                    break;

                case "Material3D":

                    var mat = prop.GetValue(Obj) as Vivid.Material.Material3D;

                    var m_name = new TextBoxForm().Set(5, py, 120, 25, mat.Name);

                    var m_edit = new ButtonForm().Set(130, py, 60, 25, "Edit");

                    m_edit.Click = (b) =>
                    {
                        SetObj(mat);
                    };

                    Body.Add(m_name);
                    Body.Add(m_edit);
                    py += 30;
                    use = true;

                    break;

                case "string":
                case "String":

                    var str = prop.GetValue(Obj) as string;
                    if (str == null)
                    {
                        str = "";
                    }
                    var str_box = new TextBoxForm().Set(5, py, 220, 25, str) as TextBoxForm;

                    str_box.Enter = (txt) =>
                    {
                        prop.SetValue(Obj, str_box.Text);
                    };

                    //Console.WriteLine("TB==" + str + "!");

                    if (prop.Name.Contains("Path"))
                    {
                        var path_sel = new ButtonForm().Set(230, py, 60, 25, "Select");
                        Body.Add(path_sel);


                        path_sel.Click = (b) =>
                        {
                            var path_r = new RequestFileForm("Select file...");
                            UI.CurUI.Top    = path_r;
                            path_r.Selected = (path) =>
                            {
                                prop.SetValue(Obj, path);
                                UI.CurUI.Top = null;
                                SetObj(Obj);
                            };
                        };
                    }

                    Body.Add(str_box);
                    use = true;
                    py += 30;

                    break;

                case "ClassLis4":
                    use = true;


                    break;

                case "Int32":
                    use = true;
                    //while (true)
                    //{
                    //}

                    var ival = prop.GetValue(Obj);

                    var i_lab = new LabelForm().Set(5, py, 25, 25, "Val");
                    var i_box = new TextBoxForm().Set(50, py, 75, 25, ival.ToString()) as TextBoxForm;

                    i_box.Enter = (n44) =>
                    {
                        try
                        {
                            ival = int.Parse(n44);
                            prop.SetValue(Obj, ival);
                        }
                        catch
                        {
                            ival = 0;
                        }

                        try
                        {
                            Obj.Changed();
                        }
                        catch
                        {
                        }
                    };

                    Body.Add(i_lab, i_box);

                    py += 30;

                    break;

                case "Single":

                    use = true;
                    //while (true)
                    //{
                    //}

                    var fval = prop.GetValue(Obj);

                    var v_lab = new LabelForm().Set(5, py, 25, 25, "Val");
                    var v_box = new TextBoxForm().Set(50, py, 75, 25, fval.ToString()) as TextBoxForm;

                    v_box.Enter = (n44) =>
                    {
                        try
                        {
                            fval = float.Parse(n44);
                            prop.SetValue(Obj, fval);
                        }
                        catch
                        {
                            fval = 0;
                        }

                        try
                        {
                            Obj.Changed();
                        }
                        catch
                        {
                        }
                    };

                    Body.Add(v_lab, v_box);

                    py += 30;

                    //  v_box.Enter = (sval) =>

                    //       fval = float.Parse(sval);/

                    break;


                case "Vector3":
                    use = true;

                    var vec3 = prop.GetValue(Obj);

                    var x_lab = new LabelForm().Set(5, py, 25, 25, "X") as LabelForm;
                    var y_lab = new LabelForm().Set(110, py, 25, 25, "Y");
                    var z_lab = new LabelForm().Set(215, py, 25, 25, "Z");

                    var x_box = new TextBoxForm().Set(30, py, 75, 25, vec3.X.ToString()) as TextBoxForm;
                    var y_box = new TextBoxForm().Set(135, py, 75, 25, vec3.Y.ToString()) as TextBoxForm;
                    var z_box = new TextBoxForm().Set(240, py, 75, 25, vec3.Z.ToString()) as TextBoxForm;

                    x_box.Enter = (val) =>
                    {
                        try
                        {
                            vec3.X = float.Parse(val);
                        }
                        catch
                        {
                        }
                        prop.SetValue(Obj, vec3);
                        try
                        {
                            Obj.Changed();
                        }
                        catch
                        {
                        }
                    };

                    y_box.Enter = (val) =>
                    {
                        try
                        {
                            vec3.Y = float.Parse(val);
                        }
                        catch
                        {
                        }
                        prop.SetValue(Obj, vec3);
                        try
                        {
                            Obj.Changed();
                        }
                        catch
                        {
                        }
                    };

                    z_box.Enter = (val) =>
                    {
                        try
                        {
                            vec3.Z = float.Parse(val);
                        }
                        catch
                        {
                        }
                        prop.SetValue(Obj, vec3);
                        try
                        {
                            Obj.Changed();
                        }
                        catch
                        {
                        }
                    };

                    Body.Add(x_lab, y_lab, z_lab);
                    Body.Add(x_box, y_box, z_box);

                    py += 30;

                    break;
                }
                if (use)
                {
                    var prop_type = new LabelForm().Set(5, py, 80, 25, name.Name);

                    Body.Add(prop_lab);
                    //  body.Add(prop_type);

                    //py += 30;
                }
                else
                {
                    py -= 30;
                }
            }
            scroller.SetMax(py);
        }
Exemplo n.º 8
0
        public ContentArea()
        {
            AfterSet = () =>
            {
                ViewX = GX;

                ViewY = GY;
                ViewW = W;
                ViewH = H;
                Scroller.Set(W - 10, 0, 10, H);
                if (Contents.Count > 0)
                {
                    var lo = Contents[Contents.Count - 1];
                    Scroller.SetMax(lo.Y + 55);
                }
            };

            Resized = () =>
            {
            };

            Scroller = new ScrollBarV();
            Add(Scroller);
            Scroller.ValueChange = (v) =>
            {
                YDif = -(int)v;
            };

            if (FileTex == null)
            {
                FileTex   = new Texture2D("data/ui/file1.png", LoadMethod.Single, true);
                FolderTex = new Texture2D("data/nxUI/content/folder.png", LoadMethod.Single, true);
                ScriptTex = new Texture2D("data/nxUI/content/script.png", LoadMethod.Single, true);
                MusicTex  = new Texture2D("data/nxUI/content/music.png", LoadMethod.Single, true);
                ImgTex    = new Texture2D("data/nxUI/content/texture.png", LoadMethod.Single, true);
            }
            Draw = () =>
            {
                DrawFormSolid(new OpenTK.Vector4(0.2f, 0.2f, 0.2f, 0.9f));

                foreach (var ce in Contents)
                {
                    if (ce == Over)
                    {
                        DrawFormSolid(new OpenTK.Vector4(0.7f, 0.7f, 0.7f, 0.7f), ce.X, ce.Y + YDif, 64, 64);
                    }
                    if (ce.IsFolder)
                    {
                        DrawForm(FolderTex, ce.X + 5, ce.Y + 5 + YDif, 54, 54);
                    }
                    else
                    {
                        DrawForm(FileTex, ce.X, ce.Y + YDif, 64, 64);
                        var ext = new FileInfo(ce.FullPath).Extension;
                        switch (ext)
                        {
                        case ".cs":
                            DrawForm(ScriptTex, ce.X, ce.Y + 24 + YDif, 64, 44);
                            break;

                        case ".jpg":
                        case ".png":
                        case ".bmp":
                            DrawForm(ImgTex, ce.X, ce.Y + 24 + YDif, 64, 44);
                            break;

                        case ".mp3":
                        case ".wav":
                        case ".ogg":
                            DrawForm(MusicTex, ce.X, ce.Y + 24 + YDif, 64, 44);
                            break;
                        }
                    }
                    if (ce == Over)
                    {
                        DrawFormSolid(new OpenTK.Vector4(0.9f, 0.9f, 0.9f, 0.8f), ce.X - 5, ce.Y + 58 + YDif, 120, 25);

                        DrawText(ce.Name, ce.X, ce.Y + 58 + YDif, new OpenTK.Vector4(0.1f, 0.1f, 0.1f, 0.8f));
                    }
                    else
                    {
                        DrawText(ce.Name, ce.X, ce.Y + 58 + YDif, new OpenTK.Vector4(1, 1, 1, 0.8f));
                    }
                }
            };
            MouseLeave = () =>
            {
                Over = null;
            };
            MouseMove = (x, y, mx, my) =>
            {
                Over = null;
                foreach (var ce in Contents)
                {
                    if (x > ce.X && y > (ce.Y + YDif) && x < ce.X + 64 && y < ce.Y + 64)
                    {
                        Over = ce;
                    }
                }
                if (DragEntry != null)
                {
                    DragEntry.X += mx;
                    DragEntry.Y += my;

                    if (DragEntry.X < 12)
                    {
                        DragEntry.X = 12;
                    }
                    if (DragEntry.Y < 12)
                    {
                        DragEntry.Y = 12;
                    }
                }
            };
            MouseUp = (b) =>
            {
                if (b == 0)
                {
                    DragEntry = null;
                    if (UI.CurUI.DragObj == null)
                    {
                        return;
                    }

                    UI.CurUI.CompleteDrag();

                    UI.CurUI.DragObj = null;
                }
            };
            MouseDown = (b) =>
            {
                if (b == 0)
                {
                    var ce = GetContent();
                    //  DragEntry = ce;
                    if (ce != null)
                    {
                        if (ce.IsFolder)
                        {
                            return;
                        }
                        var dragObj = new DragObject();
                        dragObj.DragImg  = FileTex;
                        UI.CurUI.DragObj = dragObj;
                        var item = new LabelForm().Set(-10, 50, 120, 25, ce.Name);
                        dragObj.Add(item);
                        dragObj.DragObj    = ce;
                        dragObj.DragSubObj = this;
                        DragEntry          = null;
                    }
                }
                if (b == 2)
                {
                    GoBack();
                }
            };
            DoubleClick = (b) =>
            {
                var ce = GetContent();
                if (ce == null)
                {
                    return;
                }
                if (ce.IsFolder)
                {
                    Root.SetPath(ce.FullPath);
                    return;
                }
                else
                {
                    Root.LoadAsset(ce.FullPath);
                }
            };
        }
Exemplo n.º 9
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);
                }
            };
        }
Exemplo n.º 10
0
        public MapEditForm()

        {
            var layDown = new ButtonForm().Set(140, -20, 30, 20, "\\/");
            var layUp   = new ButtonForm().Set(240, -20, 30, 20, "/\\");
            var lay     = new TextBoxForm().Set(175, -20, 70, 20, "0");

            body.Add(layDown);
            body.Add(layUp);
            body.Add(lay);

            layDown.Click = (b) =>
            {
                EditZ--;
                if (EditZ < 0)
                {
                    EditZ = 0;
                }
                lay.Text = EditZ.ToString();
            };
            layUp.Click = (b) =>
            {
                EditZ++;
                if (EditZ >= View.Map.Layers.Count)
                {
                    EditZ = View.Map.Layers.Count - 1;
                }
                ;
                lay.Text = EditZ.ToString();
            };
            Tab = new TabForm();

            CurMap = new Map();
            for (int i = 0; i < 4; i++)
            {
                Layers.Add(new MapLayer(24, 24, CurMap));
                CurMap.AddLayer(Layers[i]);
            }
            //CurMap.AddLayer(layer[0]);

            CurLayer = Layers[0];

            CurTile = null;


            View = new MapViewForm(CurMap);

            var l1 = new Vivid.Scene.GraphLight();
            var l2 = new Vivid.Scene.GraphLight();
            var l3 = new Vivid.Scene.GraphLight();

//            View.Map.AddLight(l1);
//          View.Map.AddLight(l2);
//        View.Map.AddLight(l3);

            LabelForm cLab = null;

            ; var TView = View;

            float r = 0;

            Update = () =>

            {
                if (lMode != Mode)
                {
                    updateModeLabel();
                    lMode = Mode;
                }

                /*
                 * TView.Map.Lights[0].SetPos(300,300);
                 * TView.Map.Lights[0].Range = 450;
                 * TView.Map.Lights[0].Diffuse = new OpenTK.Vector3(0, 1, 1);
                 * TView.Map.Lights[1].SetPos(650, 400);
                 * TView.Map.Lights[1].Range = 400;
                 * TView.Map.Lights[1].Diffuse = new OpenTK.Vector3(1, 1, 0);
                 * TView.Map.Lights[0].Z = 0.1f;
                 * TView.Map.Lights[1].Z = 0.1f;
                 * TView.Map.Lights[2].Z = 0.1f;
                 * TView.Map.Lights[2].Diffuse = new OpenTK.Vector3(1, 0, 1);
                 * TView.Map.Lights[2].Range = 600;
                 * TView.Map.Lights[2].SetPos(150, 150);
                 */
            };

            void updateModeLabel()
            {
                if (cLab != null)
                {
                    View.Forms.Remove(cLab);
                }
                cLab = new LabelForm().Set(2, -23, 30, 20, "Mode:Paste") as LabelForm;

                View.Add(cLab);
            }

            updateModeLabel();

            body.Add(View);

            MoveNodeForm moveForm = new MoveNodeForm().Set(0, 0, 0, 0) as MoveNodeForm;

            moveForm.View = TView;
            TView.Add(moveForm);

            TView.MouseDown = (b) =>
            {
                if (b == 2)
                {
                    rotCam = true;
                    return;
                }
                if (b == 1)
                {
                    MoveCam = true;
                    return;
                }
                Console.WriteLine("MX:" + mX + " MY:" + mY);
                AppInfo.RW = W;
                AppInfo.RH = H;
                var pn = TView.PickObj(mX, mY);
                if (pn != null)
                {
                    if (pn is Vivid.Scene.GraphLight)
                    {
                        ActiveNode       = pn;
                        TView.ActiveNode = pn;
                        TView.SetActiveSprite();
                        moveForm.SetNode(TView.ActiveNode);
                        moveForm.Set((int)TView.ActiveNodeSprite.DrawP[0].X, (int)TView.ActiveNodeSprite.DrawP[0].Y, 64, 64);
                        Console.WriteLine("Set PN");
                    }
                    else
                    {
                        Console.WriteLine("nope");
                    }
                }
                else
                {
                    Console.WriteLine("No obj");
                }

                MouseIn = true;
                var hz = ONode; // TView.Graph.Pick(lx, ly);

                if (hz != null)
                {
                }
            };
            TView.MouseWheelMoved = (z) =>
            {
                TView.Graph.Z += ((z * 0.1f) * TView.Graph.Z);
            };
            TView.MouseUp = (b) =>
            {
                if (b == 2)
                {
                    rotCam = false;
                    return;
                }
                if (b == 1)
                {
                    MoveCam = false;
                    return;
                }
                MouseIn = false;
            };

            TView.MouseMove = (x, y, dx, dy) =>
            {
                mX = x;
                mY = y;

                if (rotCam)
                {
                    TView.Graph.Rot += dx;
                }
                if (MoveCam)
                {
                    TView.Graph.Move(-dx, -dy);
                    //TView.Graph.X -= dx;
                    // TView.Graph.Y -= dy;
                }

                lx = x;
                ly = y;
                if (TView.Graph != null)
                {
                    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)
                    {
                        ONode = node;

                        if (MouseIn)
                        {
                            switch (Mode)
                            {
                            case EditMode.Paste:
                                TView.Map.Layers[EditZ].SetTile(node.TileX, node.TileY, TileBrowser.ActiveTile);
                                //TView.UpdateGraph();
                                break;

                            case EditMode.Fill:
                                TView.Map.Layers[EditZ].Fill(TileBrowser.ActiveTile);
                                break;
                            }
                        }

                        var tView = TView;

                        TView.Map.HL.Clear();
                        TView.Map.HighlightTile(node.TileX, node.TileY);
                        TView.UpdateGraph();


                        if (TView.ActiveNodeSprite != null)
                        {
                            // TView.ActiveNodeSprite.SyncCoords();
                            if (TView.ActiveNodeSprite.DrawP != null)
                            {
                                moveForm.Set((int)TView.ActiveNodeSprite.DrawP[0].X, (int)TView.ActiveNodeSprite.DrawP[0].Y, 64, 64);
                                //  TView.Graph.X = -32 + TView.W / 2;
                            }
                        }
                        // TView.Graph.Y = -32 + TView.H / 2;
                        // Console.WriteLine("MX:" + x + " MY:" + y);
                    }
                    else
                    {
                        ClearHL(TView);
                    }
                }
            };


            AfterSet = () =>
            {
                Tab.W = W;
                Tab.H = body.H;
                View.Set(0, 0, body.W, body.H);
                View.UpdateGraph();
            };
        }
Exemplo n.º 11
0
        public override void InitState()
        {
            base.InitState();
            MenuSongSrc   = new VSoundSource("Foom/Song/intro1.mp3");
            MenuSongSound = MenuSongSrc.Play2D(true);

            var img = new ImageForm().Set(300, 800, 300, 300, "").SetImage(new Texture2D("Foom/Img/Intro/img1.jpg", LoadMethod.Single, true));

            UI.BootAlpha = 0.0f;
            int tc = 0;

            void ImgUp1()
            {
                img.Y = img.Y - 3;
            }

            bool ImgUpR()
            {
                if (img.Y < 200)
                {
                    return(true);
                }
                return(false);
            }

            void Img1Text()
            {
            }

            bool Img1TextD()
            {
                if (Environment.TickCount > (tc + 3000))
                {
                    return(true);
                }
                return(false);
            }

            //int tc = 0;


            void FadeUi1()
            {
            }

            void UI3()
            {
            }

            bool UI3D()
            {
                if (Environment.TickCount > (tc + 3500))
                {
                    return(true);
                }
                return(false);
            }

            void UI4S()
            {
                SUI.Root.Forms.Clear();

                var img1 = new ImageForm().Set(50, 50, 600, 600).SetImage(new Texture2D("Foom/Img/Intro/img3.jpg", LoadMethod.Single, false));
                var tex1 = new ImageForm().Set(100, 300, 600, 250).SetImage(new Texture2D("Foom/Img/Intro/text2.png", LoadMethod.Single, true));

                SUI.Root.Forms.Add(img1);
                SUI.Root.Add(img1);
                img1.Add(tex1);
                UI.TarAlpha = 1.0f;
            }

            bool FadeDone1()
            {
                if (Environment.TickCount > (tc + 3500))
                {
                    UI.TarAlpha = 0.0f;
                    if (UI.BootAlpha < 0.01f)
                    {
                        UI.TarAlpha = 1.0f;
                        return(true);
                    }
                }
                return(false);
            }

            void UI3S()
            {
                tc = Environment.TickCount;
                SUI.Root.Forms.Clear();

                var img2 = new ImageForm().Set(100, 100, 400, 400).SetImage(new Texture2D("Foom/Img/Intro/img2.jpg", LoadMethod.Single, true));

                SUI.Root.Add(img2);
                var log1 = new ImageForm().Set(220, 350, 500, 250).SetImage(new Texture2D("Foom/Img/Intro/text1.png", LoadMethod.Single, true));

                SUI.Root.Add(log1);
                Logics.When(FadeDone1, UI4S);

                UI.TarAlpha = 1.0f;
                Logics.Do(UI3, UI3D);
            }

            // bool UI3D()
            // {
            //    return false;
            //}


            bool FadeUID()
            {
                if (UI.BootAlpha < 0.01f)
                {
                    return(true);
                }
                return(false);
            }

            void FadeUI()
            {
                UI.TarAlpha = 0.0f;
                Logics.Do(FadeUi1, FadeUID, UI3S);
                //    UI.BootAlpha += (0.0f - UI.BootAlpha) * 0.1f;
            }

            void NextImg()
            {
                tc = Environment.TickCount;
                Logics.Do(Img1Text, Img1TextD, FadeUI);

                var text = new LabelForm().Set(600, 250, 200, 80, "The Dawn Of Hell...");

                SUI.Root.Forms.Add(text);
            }

            Logics.Do(ImgUp1, ImgUpR, NextImg);



            SUI = new UI();

            SUI.Root.Add(img);
        }