コード例 #1
0
ファイル: Main.cs プロジェクト: wangscript007/Fusee
        public static void Main()
        {
            // Inject Fusee.Engine.Base InjectMe dependencies
            IO.IOImp = new Fusee.Base.Imp.Desktop.IOImp();

            var fap = new Fusee.Base.Imp.Desktop.FileAssetProvider("Assets");

            fap.RegisterTypeHandler(
                new AssetHandler
            {
                ReturnedType = typeof(Font),
                Decoder      = delegate(string id, object storage)
                {
                    if (!Path.GetExtension(id).Contains("ttf", System.StringComparison.OrdinalIgnoreCase))
                    {
                        return(null);
                    }
                    return(new Font {
                        _fontImp = new FontImp((Stream)storage)
                    });
                },
                Checker = id => Path.GetExtension(id).Contains("ttf", System.StringComparison.OrdinalIgnoreCase)
            });
            fap.RegisterTypeHandler(
                new AssetHandler
            {
                ReturnedType = typeof(SceneContainer),
                Decoder      = (string id, object storage) =>
                {
                    if (!Path.GetExtension(id).Contains("fus", System.StringComparison.OrdinalIgnoreCase))
                    {
                        return(null);
                    }
                    return(FusSceneConverter.ConvertFrom(ProtoBuf.Serializer.Deserialize <FusFile>((Stream)storage)));
                },
                Checker = id => Path.GetExtension(id).Contains("fus", System.StringComparison.OrdinalIgnoreCase)
            });

            AssetStorage.RegisterProvider(fap);

            var app = new Core.Picking();

            // Inject Fusee.Engine InjectMe dependencies (hard coded)
            System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
            app.CanvasImplementor  = new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasImp(appIcon);
            app.ContextImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderContextImp(app.CanvasImplementor);
            Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasInputDriverImp(app.CanvasImplementor));
            Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.WindowsTouchInputDriverImp(app.CanvasImplementor));
            // app.InputImplementor = new Fusee.Engine.Imp.Graphics.Desktop.InputImp(app.CanvasImplementor);
            // app.AudioImplementor = new Fusee.Engine.Imp.Sound.Desktop.AudioImp();
            // app.NetworkImplementor = new Fusee.Engine.Imp.Network.Desktop.NetworkImp();
            // app.InputDriverImplementor = new Fusee.Engine.Imp.Input.Desktop.InputDriverImp();
            // app.VideoManagerImplementor = ImpFactory.CreateIVideoManagerImp();

            // Start the app
            app.Run();
        }
コード例 #2
0
        public static void Main()
        {
            /*
             * SimpleType st = new SimpleType {Header = new SceneHeaderTest
             * {
             *  Version = 1,
             *  Generator = "Test",
             *  CreatedBy = "Patrick",
             *  CreationDate = "13-12-2016",
             * } };
             * var seri = new Serializer();
             * // var schem = ProtoBuf.Serializer.GetProto<SimpleType>();
             *
             * using (FileStream str = new FileStream("FuseeSimpleType.st", System.IO.FileMode.Create))
             * {
             *  seri.Serialize(str, st);
             * }
             */

            // Inject Fusee.Engine.Base InjectMe dependencies
            IO.IOImp = new Fusee.Base.Imp.Desktop.IOImp();

            var fap = new Fusee.Base.Imp.Desktop.FileAssetProvider("Assets");

            fap.RegisterTypeHandler(
                new AssetHandler
            {
                ReturnedType = typeof(Font),
                Decoder      = delegate(string id, object storage)
                {
                    if (!Path.GetExtension(id).ToLower().Contains("ttf"))
                    {
                        return(null);
                    }
                    return(new Font {
                        _fontImp = new FontImp((Stream)storage)
                    });
                },
                Checker = id => Path.GetExtension(id).ToLower().Contains("ttf")
            });
            fap.RegisterTypeHandler(
                new AssetHandler
            {
                ReturnedType = typeof(SceneContainer),
                Decoder      = delegate(string id, object storage)
                {
                    if (!Path.GetExtension(id).ToLower().Contains("fus"))
                    {
                        return(null);
                    }
                    var ser = new Serializer();
                    return(new ConvertSceneGraph().Convert(ser.Deserialize((Stream)storage, null, typeof(SceneContainer)) as SceneContainer));
                },
                Checker = id => Path.GetExtension(id).ToLower().Contains("fus")
            });

            AssetStorage.RegisterProvider(fap);

            var app = new Core.Picking();

            // Inject Fusee.Engine InjectMe dependencies (hard coded)
            System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
            app.CanvasImplementor  = new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasImp(appIcon);
            app.ContextImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderContextImp(app.CanvasImplementor);
            Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasInputDriverImp(app.CanvasImplementor));
            Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.WindowsTouchInputDriverImp(app.CanvasImplementor));
            // app.InputImplementor = new Fusee.Engine.Imp.Graphics.Desktop.InputImp(app.CanvasImplementor);
            // app.AudioImplementor = new Fusee.Engine.Imp.Sound.Desktop.AudioImp();
            // app.NetworkImplementor = new Fusee.Engine.Imp.Network.Desktop.NetworkImp();
            // app.InputDriverImplementor = new Fusee.Engine.Imp.Input.Desktop.InputDriverImp();
            // app.VideoManagerImplementor = ImpFactory.CreateIVideoManagerImp();

            // Start the app
            app.Run();
        }